I am trying to test the following scenario, enter a letter in the autocomplete text box, scroll down and select one of the options, and then click the button. Pressing a button starts a new action. I want to check if a new action has begun or not. This is a testing method.
public void testSpinnerUI() {
mActivity.runOnUiThread(new Runnable() {
public void run() {
mFromLocation.requestFocusFromTouch();
}
});
this.sendKeys(KeyEvent.KEYCODE_W);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
for (int i = 1; i <= 4; i++) {
this.sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
}
this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
assertEquals("Welcome", mFromLocation.getText().toString());
this.sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
this.sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
assertEquals(com.myApp.RouteListActivity.class, getActivity());
}
The test fails with the last assertEquals (com.myApp.RouteListActivity.class, getActivity ()). Can you advise me how to check if a new action has been launched or not?
source
share