Android Open Source - sample_testing Main Activity Test






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  .  j  av a2 s . co  m*/
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class MainActivityTest extends UiAutomatorTestCase
{

  public void testDemo() throws UiObjectNotFoundException
  {

    StartsMethods start = new StartsMethods();

    start.openAllAppsScreen();
    start.openAppsTab();
    start.swipAndOpen();

    UiObject oneButton = new UiObject(new UiSelector().text("1"));
    oneButton.click();

    UiObject plusButton = new UiObject(new UiSelector().text("+"));
    plusButton.click();

    UiObject threeButton = new UiObject(new UiSelector().text("3"));
    threeButton.click();

    UiObject eqButton = new UiObject(new UiSelector().text("="));
    eqButton.click();

    UiObject text = new UiObject(new UiSelector().className("android.widget.EditText").text("4"));
    assertTrue(text.exists());
  }
}




Java Source Code List

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