Search in sources :

Example 31 with UiObject2

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

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

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

the class ExternalSourcesSettingsTest method testManageExternalSourcesList.

@Test
public void testManageExternalSourcesList() throws Exception {
    final String testAppLabel = getApplicationLabel(mPackageName);
    mContext.startActivity(createManageExternalSourcesListIntent());
    final BySelector preferenceListSelector = By.clazz(ListView.class).res("android:id/list");
    final UiObject2 preferenceList = mUiDevice.wait(Until.findObject(preferenceListSelector), START_ACTIVITY_TIMEOUT);
    assertNotNull("App list not shown", preferenceList);
    final BySelector appLabelTextViewSelector = By.clazz(TextView.class).res("android:id/title").text(testAppLabel);
    List<UiObject2> listOfMatchingTextViews;
    do {
        listOfMatchingTextViews = preferenceList.findObjects(appLabelTextViewSelector);
    // assuming the number of profiles will be sufficiently small so that all the entries
    // for the same package will fit in one screen at some time during the scroll.
    } while (listOfMatchingTextViews.size() != mProfiles.size() && preferenceList.scroll(Direction.DOWN, 0.2f));
    assertEquals("Test app not listed for each profile", mProfiles.size(), listOfMatchingTextViews.size());
    for (UiObject2 matchingObject : listOfMatchingTextViews) {
        matchingObject.click();
        findAndVerifySwitchState(true);
        mUiDevice.pressBack();
    }
}
Also used : BySelector(android.support.test.uiautomator.BySelector) ListView(android.widget.ListView) UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 33 with UiObject2

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

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

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

the class TestUtils method setEditTextWithValue.

/**
 * Find {@link android.widget.EditText} with {@code res} and set its {@code value}
 */
public static void setEditTextWithValue(UiDevice uiDevice, String res, long value) {
    final UiObject2 editText = uiDevice.findObject(By.res(res));
    assertWithMessage("Cannot find editText with res: " + res).that(editText).isNotNull();
    editText.setText(String.valueOf(value));
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 35 with UiObject2

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

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)

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