Search in sources :

Example 81 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_frameworks_base by AOSPA.

the class BaseBot method assertHasFocus.

/**
     * Asserts that the specified view or one of its descendents has focus.
     */
protected void assertHasFocus(String resourceName) {
    UiObject2 candidate = mDevice.findObject(By.res(resourceName));
    assertNotNull("Expected " + resourceName + " to have focus, but it didn't.", candidate.findObject(By.focused(true)));
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 82 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_frameworks_base by ResurrectionRemix.

the class Utils method waitForActivity.

private static UiObject2 waitForActivity(Instrumentation instrumentation, BySelector selector) {
    UiDevice device = UiDevice.getInstance(instrumentation);
    UiObject2 window = device.wait(Until.findObject(selector), WAIT_FOR_ACTIVITY_TIMEOUT);
    if (window == null) {
        throw new RuntimeException(selector.toString() + " has not been started.");
    }
    // Get root object.
    while (window.getParent() != null) {
        window = window.getParent();
    }
    return window;
}
Also used : UiDevice(android.support.test.uiautomator.UiDevice) UiObject2(android.support.test.uiautomator.UiObject2)

Example 83 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project weex-example by KalicyZhou.

the class BenchmarkTest method testFlingFPS.

@Repeat(TIMES)
@Test
@SdkSuppress(minSdkVersion = 23)
public void testFlingFPS() {
    UiObject2 uiObject2 = loadPageForFPS();
    if (uiObject2 != null) {
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        processGfxInfo(flingFrameSeconds);
    }
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test) SdkSuppress(android.support.test.filters.SdkSuppress)

Example 84 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project weex-example by KalicyZhou.

the class BenchmarkTest method testScrollFPS.

@Repeat(TIMES)
@Test
@SdkSuppress(minSdkVersion = 23)
public void testScrollFPS() {
    UiObject2 uiObject2 = loadPageForFPS();
    if (uiObject2 != null) {
        uiObject2.scroll(Direction.DOWN, 6, SCROLL_SPEED);
        processGfxInfo(scrollFrameSeconds);
    }
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test) SdkSuppress(android.support.test.filters.SdkSuppress)

Example 85 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_frameworks_base by DirtyUnicorns.

the class UiBot method assertWindowTitle.

public void assertWindowTitle(String expected) {
    // Turns out the title field on a window does not have
    // an id associated with it at runtime (which confuses the hell out of me)
    // In code we address this via "android.R.id.title".
    UiObject2 o = find(By.text(expected));
    // It's a bit of a conceit that we then *assert* that the title
    // is the value that we used to identify the UiObject2.
    // If the preceeding lookup fails, this'll choke with an NPE.
    // But given the issue described in the comment above, we're
    // going to do it anyway. Because we shouldn't be looking up
    // the uiobject by it's expected content :|
    assertEquals(expected, o.getText());
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Aggregations

UiObject2 (android.support.test.uiautomator.UiObject2)133 Test (org.junit.Test)30 BySelector (android.support.test.uiautomator.BySelector)18 MediumTest (android.test.suitebuilder.annotation.MediumTest)16 ListView (android.widget.ListView)8 MediumTest (androidx.test.filters.MediumTest)8 Switch (android.widget.Switch)7 Intent (android.content.Intent)6 RemoteException (android.os.RemoteException)6 LargeTest (android.support.test.filters.LargeTest)6 UiDevice (android.support.test.uiautomator.UiDevice)6 Presubmit (android.platform.test.annotations.Presubmit)4 SdkSuppress (android.support.test.filters.SdkSuppress)4 Activity (android.app.Activity)2 NfcAdapter (android.nfc.NfcAdapter)2 NfcManager (android.nfc.NfcManager)2 Bundle (android.os.Bundle)2 CancellationSignal (android.os.CancellationSignal)2 ParcelFileDescriptor (android.os.ParcelFileDescriptor)2 PrintAttributes (android.print.PrintAttributes)2