コード例 #1
0
 @org.junit.Test
 public void BVT() throws Exception {
   UiObject fooLabel =
       new UiObject(
           new UiSelector().call("text", "Foo").call("className", "android.widget.TextView"));
   assertTrue(fooLabel.call("exists").getBoolean(0));
   fooLabel.call("click");
   UiObject fooPage =
       new UiObject(
           new UiSelector().call("text", "Foo page").call("className", "android.widget.TextView"));
   assertTrue(fooPage.call("exists").getBoolean(0));
 }
コード例 #2
0
  @org.junit.Test
  public void NotificationTest() throws Exception {
    // click Notification
    UiObject fooLabel =
        new UiObject(
            new UiSelector()
                .call("text", "Notification")
                .call("className", "android.widget.TextView"));
    assertTrue(fooLabel.call("exists").getBoolean(0));
    fooLabel.call("click");

    // open the notification shade
    UiDevice.openNotification();

    // identify and click notification
    UiSelector selector =
        new UiSelector()
            .call("className", "android.widget.TextView")
            .call("text", "Test App Notification");
    UiObject notification = new UiObject(selector);
    assertTrue(notification.call("exists").getBoolean(0));
    notification.call("clickAndWaitForNewWindow");

    // verify page
    UiObject notificationPage =
        new UiObject(
            new UiSelector()
                .call("text", "Notification page")
                .call("className", "android.widget.TextView"));
    assertTrue(notificationPage.call("exists").getBoolean(0));
  }