Question

Dear Robotium/Android community. Am new to Robotium so am hoping someone can help give me a steer on the correct way to detect & verify the page currently in view following a swipe (drag) to change the page.

The test is to verify the operation of changing pages in Android Home. So the script starts the launcher activity and the test steps use a 'solo.drag' to simulate swipe left/right gestures to change pages from Default Home.

More specifically my question is:

1) Prior to changing pages I need a single test step that verifies that the default page on startup is indeed the Default Homepage (indicated by the small white home icon). 2) Having performed the page change (via solo.drag) the test step needs to detect the change and return the success or fail

For reference the test step with solo.drag currently looks as below without any form of verification:

    public void testScrollRight() throws Exception {
    // *** require verification of current page here ***
    //drag(float fromX, float toX, float fromY, float toY, int stepCount)
    solo.drag(400, 950, 1500, 1440, 40);
    // *** require verification of page change here ***
}
Was it helpful?

Solution

You can use one of this method to assert about the activity you expect to see on the screen:

void    assertCurrentActivity(String message, Class activityClass)
// Asserts that the Activity matching the specified class is active.

void    assertCurrentActivity(String message, Class activityClass, boolean isNewInstance)
// Asserts that the Activity matching the specified class is active, with the possibility to  // verify that the expected Activity is a new instance of the Activity.

void    assertCurrentActivity(String message, String name)
//Asserts that the Activity matching the specified name is active.

void    assertCurrentActivity(String message, String name, boolean isNewInstance)
//Asserts that the Activity matching the specified name is active, with the possibility to //verify that the expected Activity is a new instance of the Activity.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top