Search in sources :

Example 96 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project incubator-weex by apache.

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

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by SudaMod.

the class TestUtils method clickButton.

/**
 * Find {@link android.widget.Button} with {@code res} and click it
 */
public static void clickButton(UiDevice uiDevice, String res) {
    final UiObject2 button = uiDevice.findObject(By.res(res));
    assertWithMessage("Cannot find button with res: " + res).that(button).isNotNull();
    button.click();
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 98 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by SudaMod.

the class ExternalSourcesSettingsTest method testSwitchToggle.

private void testSwitchToggle(int fromAppOp, int toAppOp) throws Exception {
    final int packageUid = mPackageManager.getPackageUid(mPackageName, 0);
    final boolean initialState = (fromAppOp == MODE_ALLOWED || fromAppOp == MODE_DEFAULT);
    mAppOpsManager.setMode(OP_REQUEST_INSTALL_PACKAGES, packageUid, mPackageName, fromAppOp);
    mContext.startActivity(createManageExternalSourcesAppIntent(mPackageName));
    final UiObject2 switchPref = findAndVerifySwitchState(initialState);
    switchPref.click();
    Thread.sleep(1000);
    assertEquals("Toggling switch did not change app op", toAppOp, mAppOpsManager.checkOpNoThrow(OP_REQUEST_INSTALL_PACKAGES, packageUid, mPackageName));
    mUiDevice.pressBack();
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 99 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by SudaMod.

the class ExternalSourcesSettingsTest method findAndVerifySwitchState.

private UiObject2 findAndVerifySwitchState(boolean checked) {
    final BySelector switchSelector = By.clazz(Switch.class).res("android:id/switch_widget");
    final UiObject2 switchPref = mUiDevice.wait(Until.findObject(switchSelector), START_ACTIVITY_TIMEOUT);
    assertNotNull("Switch not shown", switchPref);
    assertTrue("Switch in invalid state", switchPref.isChecked() == checked);
    return switchPref;
}
Also used : BySelector(android.support.test.uiautomator.BySelector) Switch(android.widget.Switch) UiObject2(android.support.test.uiautomator.UiObject2)

Example 100 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project platform_packages_apps_Settings by BlissRoms.

the class WifiTetherSettingsTest method launchWifiTetherActivity.

private void launchWifiTetherActivity() {
    mInstrumentation.startActivitySync(mTetherActivityIntent);
    onView(withText("Portable Wi‑Fi hotspot")).perform();
    UiObject2 item = mDevice.wait(Until.findObject(By.text("Portable Wi‑Fi hotspot")), TIMEOUT);
    item.click();
}
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