mercredi 31 août 2016

Check which Intent open Espresso

Whether it is possible to trace which the Activiti opened after pressing the button?
I have a test, after clicking on the button sends a request to the server, and as long as they are sent, opens Activiti to the successful execution of the test to check what is open Activiti
Example of my test:

 private void startTest() {
    recreateAuthData(InstrumentationRegistry.getTargetContext(), "d78269d9-9e00-4b8d-9242-815204b0a2f6", "3f32da21-914d-4adc-b6a1-891b842a2972");

    InstrumentationRegistry.getTargetContext().getSharedPreferences(ActivitySplashScreen.class.getSimpleName(),
            Context.MODE_PRIVATE).edit().putInt(ActivitySplashScreen.PROPERTY_APP_VERSION, ActivitySplashScreen.getAppVersion(InstrumentationRegistry.getTargetContext())).commit();
    InstrumentationRegistry.getTargetContext().getSharedPreferences(ActivitySplashScreen.class.getSimpleName(),
            Context.MODE_PRIVATE).edit().putString(ActivitySplashScreen.PROPERTY_REG_ID, "testKey").commit();

    mActivityRule.launchActivity(setIntent());
    // inputPinCode("2794");
}

@Test
public void testIdent() {
    startTest();
    onView(withText("ПРО")).perform(click());
    putDelay(500);
    onView(withId(R.id.get_pro)).perform(click());
    onView(withText("Авторизация по паспортным данным")).perform(click());
    putDelay(500);
    closeSoftKeyboard();
    onView(withId(R.id.btn_goto_passport)).perform(click());
    onView(withHint("Серия и номер паспорта")).perform(replaceText("9894657891"));
    onView(withHint("Дата выдачи паспорта")).perform(replaceText("17032014"));
    onView(withHint("Дата рождения")).perform(replaceText("31091994"));
    onView(withHint("СНИЛС")).perform(replaceText("54665285919"));
    putDelay(500);
    Log.d("TestWidget", hasComponent(hasShortClassName("ActivityMain")).toString());
    onView(withId(R.id.btn_next)).perform(click());
    // some code which check which activity is display now
    putDelay(500);

}

Aucun commentaire:

Enregistrer un commentaire