Android Open Source - sample_testing Starts Methods






From Project

Back to project page sample_testing.

License

The source code is released under:

Apache License

If you think the Android project sample_testing listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.elsinga.calculator;
//from  w  w w .  jav  a2s .  c om
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class StartsMethods extends UiAutomatorTestCase
{

  public StartsMethods()
  {
  }

  public void simulateHomeButton()
  {
    getUiDevice().pressHome();
  }

  public void openAllAppsScreen() throws UiObjectNotFoundException
  {
    UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
    allAppsButton.clickAndWaitForNewWindow();
  }

  public void openAppsTab() throws UiObjectNotFoundException
  {
    UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
    appsTab.click();
  }

  public void swipAndOpen() throws UiObjectNotFoundException
  {
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    appViews.setAsHorizontalList();

    UiObject calculatorApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), "Calculator app");
    calculatorApp.clickAndWaitForNewWindow();
  }

}




Java Source Code List

com.elsinga.calculator.MainActivityTest.java
com.elsinga.calculator.MainActivity.java
com.elsinga.calculator.StartsMethods.java