• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package io.appium.droiddriver.manualtest;
2 
3 import android.app.Activity;
4 
5 import io.appium.droiddriver.finders.By;
6 import io.appium.droiddriver.finders.Finder;
7 import io.appium.droiddriver.helpers.BaseDroidDriverTest;
8 import io.appium.droiddriver.helpers.DroidDrivers;
9 import io.appium.droiddriver.helpers.DroidDriversInitializer;
10 import 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 with
20  *
21  * <pre>
22  * ../gradlew :connectedAndroidTest
23  * </pre>
24  */
25 public class ManualTest extends BaseDroidDriverTest<Activity> {
ManualTest()26   public ManualTest() {
27     super(Activity.class);
28   }
29 
30   // This does not instrument a certain AUT, so InstrumentationDriver won't work
classSetUp()31   protected void classSetUp() {
32     DroidDrivers.checkUiAutomation();
33     DroidDriversInitializer.get(new UiAutomationDriver(getInstrumentation())).singleRun();
34   }
35 
testSetTextForPassword()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