1package io.appium.droiddriver.manualtest;
2
3import android.app.Activity;
4
5import io.appium.droiddriver.finders.By;
6import io.appium.droiddriver.finders.Finder;
7import io.appium.droiddriver.helpers.BaseDroidDriverTest;
8import io.appium.droiddriver.helpers.DroidDrivers;
9import io.appium.droiddriver.helpers.DroidDriversInitializer;
10import io.appium.droiddriver.uiautomation.UiAutomationDriver;
11
12/**
13 * This is for manually testing DroidDriver. It is not meant for continuous
14 * testing. Instead it is used for debugging failures. It assumes the device is
15 * in a condition that is ready to reproduce a failure. For example,
16 * {@link #testSetTextForPassword} assumes the password_edit field is displayed
17 * on screen.
18 * <p>
19 * Run it as (optionally with -e debug true)
20 *
21 * <pre>
22 * adb shell am instrument -w io.appium.droiddriver.manualtest/io.appium.droiddriver.runner.TestRunner
23 * </pre>
24 */
25public class ManualTest extends BaseDroidDriverTest<Activity> {
26  public ManualTest() {
27    super(Activity.class);
28  }
29
30  // This does not instrument a certain AUT, so InstrumentationDriver won't work
31  protected void classSetUp() {
32    DroidDrivers.checkUiAutomation();
33    DroidDriversInitializer.get(new UiAutomationDriver(getInstrumentation())).singleRun();
34  }
35
36  public void testSetTextForPassword() {
37    Finder password_edit = By.resourceId("com.google.android.gsf.login:id/password_edit");
38    String oldPassword = "A fake password that is not empty and needs to be cleared by setText";
39    String newPassword = "1";
40    driver.on(password_edit).setText(oldPassword);
41    driver.on(password_edit).setText(newPassword);
42    // This won't work because password_edit does not reveal text to
43    // Accessibility service. But you can see the length changed on screen.
44    // assertEquals(newPassword, driver.on(password_edit).getText());
45    assertEquals(null, driver.on(password_edit).getText());
46  }
47}
48