Java Code Examples for android.support.test.uiautomator.UiObject#dragTo()

The following examples show how to use android.support.test.uiautomator.UiObject#dragTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutomatorServiceImpl.java    From android-uiautomator-server with MIT License 4 votes vote down vote up
private boolean dragTo(UiObject obj, Selector destObj, int steps) throws UiObjectNotFoundException, NotImplementedException {
    return obj.dragTo(device.findObject(destObj.toUiSelector()), steps);
}
 
Example 2
Source File: AutomatorServiceImpl.java    From android-uiautomator-server with MIT License 4 votes vote down vote up
private boolean dragTo(UiObject obj, int destX, int destY, int steps) throws UiObjectNotFoundException, NotImplementedException {
    return obj.dragTo(destX, destY, steps);
}
 
Example 3
Source File: MainActivityTest.java    From otp-authenticator with MIT License 4 votes vote down vote up
public void test004Rearrange() throws InterruptedException, UiObjectNotFoundException {
    UiDevice mDevice = UiDevice.getInstance(getInstrumentation());


    UiObject start =  mDevice.findObject(new UiSelector().textContains(codes[0][0]));
    UiObject end =  mDevice.findObject(new UiSelector().textContains(codes[1][0]));

    start.dragTo(start, 10);
    start.dragTo(end, 10);

    mDevice.pressBack();

    Thread.sleep(2000);

    String t = codes[0][0];
    codes[0][0] = codes[1][0];
    codes[1][0] = t;

    for(int i = 0; i < codes.length; i++){
        onData(anything()).inAdapterView(withId(R.id.listView))
                .atPosition(i)
                .onChildView(withId(R.id.textViewLabel))
                .check(matches(withText(codes[i][0])));
    }

    start =  mDevice.findObject(new UiSelector().textContains(codes[0][0]));
    end =  mDevice.findObject(new UiSelector().textContains(codes[1][0]));

    start.dragTo(start, 10);
    start.dragTo(end, 10);

    mDevice.pressBack();

    Thread.sleep(2000);

    t = codes[0][0];
    codes[0][0] = codes[1][0];
    codes[1][0] = t;

    for(int i = 0; i < codes.length; i++){
        onData(anything()).inAdapterView(withId(R.id.listView))
                .atPosition(i)
                .onChildView(withId(R.id.textViewLabel))
                .check(matches(withText(codes[i][0])));
    }
}