public static org.assertj.android.api.widget.ListAdapterAssert assertThat( android.widget.ListAdapter actual) { return new org.assertj.android.api.widget.ListAdapterAssert(actual); }
@Config(sdk = 21) @Test public void testRemoveAccount() { AccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null); Preferences.setUsername(activity, "existing"); drawerAccount.performClick(); AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog(); assertNotNull(alertDialog); assertThat(alertDialog.getListView().getAdapter()).hasCount(1); alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick(); assertThat(alertDialog).isNotShowing(); assertThat(AccountManager.get(activity).getAccounts()).isEmpty(); }
@Test public void testExistingAccount() { AccountManager.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); shadowOf(alertDialog).clickOnItem(0); alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); assertThat(alertDialog).isNotShowing(); assertThat(drawerAccount).hasText("existing"); assertThat(drawerLogout).isVisible(); drawerAccount.performClick(); alertDialog = ShadowAlertDialog.getLatestAlertDialog(); assertThat(alertDialog.getListView().getAdapter()).hasCount(1); }
public static org.assertj.android.api.widget.ListAdapterAssert assertThat( android.widget.ListAdapter actual) { return new org.assertj.android.api.widget.ListAdapterAssert(actual); }
@Test public void testAddAccount() { AccountManager.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) Shadow.extract(activity.findViewById(R.id.drawer_layout))) .getDrawerListeners().get(0) .onDrawerClosed(activity.findViewById(R.id.drawer)); assertThat(shadowOf(activity).getNextStartedActivity()) .hasComponent(activity, LoginActivity.class); }