Java Code Examples for android.support.test.uiautomator.UiDevice.pressHome()

The following are Jave code examples for showing how to use pressHome() of the android.support.test.uiautomator.UiDevice class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: SimpleMarkdown   File: MainActivityTests.java   Source Code and License Vote up 8 votes
@Test
public void openAppTest() throws Exception {
    UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
    mDevice.pressHome();
    // Bring up the default launcher by searching for a UI component
    // that matches the content description for the launcher button.
    UiObject allAppsButton = mDevice
            .findObject(new UiSelector().description("Apps"));

    // Perform a click on the button to load the launcher.
    allAppsButton.clickAndWaitForNewWindow();
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.wbrawner.simplemarkdown", appContext.getPackageName());
    UiScrollable appView = new UiScrollable(new UiSelector().scrollable(true));
    UiSelector simpleMarkdownSelector = new UiSelector().text("Simple Markdown");
    appView.scrollIntoView(simpleMarkdownSelector);
    mDevice.findObject(simpleMarkdownSelector).clickAndWaitForNewWindow();
}
 
Example 2
Project: ChimpCheck   File: EspressoChimpDriver.java   Source Code and License Vote up 5 votes
@Override
protected void launchClickHome() {
    Log.i(runner.chimpTag("[email protected]"), "ClickHome");

    // Espresso.onView(isRoot()).perform( new ChimpStagingAction() );

    UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
    mDevice.pressHome();

    // Espresso.onView(isRoot()).perform(pressKey(KeyEvent.KEYCODE_HOME));
    // kickBackExperiment();
}
 
Example 3
Project: SmoothClicker   File: AbstractTest.java   Source Code and License Vote up 5 votes
/**
 * <i>The tests have to start from the screen home</i>
 */
@BeforeClass
public static void start(){
    l("AbstractTest","@BeforeClass start");
    UiDevice d = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    d.pressHome();
}
 
Example 4
Project: SmoothClicker   File: AbstractTest.java   Source Code and License Vote up 5 votes
/**
 * <i>The device should be at its initial state when all tests are done</i>
 */
@AfterClass
public static void end(){
    l("AbstractTest","@AfterClass end");
    UiDevice d = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    d.pressHome();
}