Search in sources :

Example 91 with UiObject2

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

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

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

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

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

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)

Example 94 with UiObject2

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

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)

Example 95 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android-testing-templates by googlesamples.

the class UiAutomatorTest method findViewPerformActionAndCheckAssertion.

@Test
public void findViewPerformActionAndCheckAssertion() {
    // Click on Button with content description
    final String btnContentDescription = InstrumentationRegistry.getTargetContext().getString(R.string.content_desc_hello_android_testing);
    mDevice.findObject(By.desc(btnContentDescription)).click();
    // Verify that correct text is displayed
    final String textViewResId = "text_view_rocks";
    UiObject2 androidRocksTextView = mDevice.wait(Until.findObject(By.res(TARGET_PACKAGE, textViewResId)), 500);
    assertThat(androidRocksTextView, notNullValue());
    final String androidTestingRocksText = InstrumentationRegistry.getTargetContext().getString(R.string.android_testing_rocks);
    assertThat(androidRocksTextView.getText(), is(equalTo(androidTestingRocksText)));
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

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