Search in sources :

Example 1 with UiObject2

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

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 2 with UiObject2

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

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)

Example 3 with UiObject2

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

the class UiBot method findMenuWithName.

UiObject2 findMenuWithName(String label) {
    List<UiObject2> menuItems = mDevice.findObjects(By.clazz("android.widget.LinearLayout"));
    Iterator<UiObject2> it = menuItems.iterator();
    UiObject2 menuItem = null;
    while (it.hasNext()) {
        menuItem = it.next();
        UiObject2 text = menuItem.findObject(By.text(label));
        if (text != null) {
            break;
        }
    }
    return menuItem;
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 4 with UiObject2

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

the class UiBot method assertMenuEnabled.

public void assertMenuEnabled(int id, boolean enabled) {
    UiObject2 menu = findMenuWithName(mContext.getString(id));
    assertNotNull(menu);
    assertEquals(enabled, menu.isEnabled());
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 5 with UiObject2

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

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)

Aggregations

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