Search in sources :

Example 1 with ShadowSupportDrawerLayout

use of io.github.hidroh.materialistic.test.shadow.ShadowSupportDrawerLayout in project materialistic by hidroh.

the class DrawerActivityLoginTest method testAddAccount.

@Test
public void testAddAccount() {
    ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
    drawerAccount.performClick();
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
    alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
    assertThat(alertDialog).isNotShowing();
    ((ShadowSupportDrawerLayout) ShadowExtractor.extract(activity.findViewById(R.id.drawer_layout))).getDrawerListeners().get(0).onDrawerClosed(activity.findViewById(R.id.drawer));
    assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, LoginActivity.class);
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) ShadowSupportDrawerLayout(io.github.hidroh.materialistic.test.shadow.ShadowSupportDrawerLayout) Account(android.accounts.Account) Test(org.junit.Test)

Aggregations

Account (android.accounts.Account)1 AlertDialog (android.app.AlertDialog)1 ShadowSupportDrawerLayout (io.github.hidroh.materialistic.test.shadow.ShadowSupportDrawerLayout)1 Test (org.junit.Test)1 ShadowAlertDialog (org.robolectric.shadows.ShadowAlertDialog)1