aboutsummaryrefslogtreecommitdiff
path: root/manualtest/src/io/appium/droiddriver/manualtest/ManualTest.java
blob: 59beac4c6bff2fca108de50e697ef1b51ac2a880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package io.appium.droiddriver.manualtest;

import android.app.Activity;

import io.appium.droiddriver.finders.By;
import io.appium.droiddriver.finders.Finder;
import io.appium.droiddriver.helpers.BaseDroidDriverTest;
import io.appium.droiddriver.helpers.DroidDrivers;
import io.appium.droiddriver.helpers.DroidDriversInitializer;
import io.appium.droiddriver.uiautomation.UiAutomationDriver;

/**
 * This is for manually testing DroidDriver. It is not meant for continuous
 * testing. Instead it is used for debugging failures. It assumes the device is
 * in a condition that is ready to reproduce a failure. For example,
 * {@link #testSetTextForPassword} assumes the password_edit field is displayed
 * on screen.
 * <p>
 * Run it with
 *
 * <pre>
 * ../gradlew :connectedAndroidTest
 * </pre>
 */
public class ManualTest extends BaseDroidDriverTest<Activity> {
  public ManualTest() {
    super(Activity.class);
  }

  // This does not instrument a certain AUT, so InstrumentationDriver won't work
  protected void classSetUp() {
    DroidDrivers.checkUiAutomation();
    DroidDriversInitializer.get(new UiAutomationDriver(getInstrumentation())).singleRun();
  }

  public void testSetTextForPassword() {
    Finder password_edit = By.resourceId("com.google.android.gsf.login:id/password_edit");
    String oldPassword = "A fake password that is not empty and needs to be cleared by setText";
    String newPassword = "1";
    driver.on(password_edit).setText(oldPassword);
    driver.on(password_edit).setText(newPassword);
    // This won't work because password_edit does not reveal text to
    // Accessibility service. But you can see the length changed on screen.
    // assertEquals(newPassword, driver.on(password_edit).getText());
    assertEquals(null, driver.on(password_edit).getText());
  }
}