use of android.app.AlertDialog in project SmartAndroidSource by jaychou2012.
the class GoogleHandle method accountDialog.
private void accountDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(act);
//builder.setTitle("Select a Google account");
accs = am.getAccountsByType("com.google");
int size = accs.length;
if (size == 1) {
auth(accs[0]);
} else {
String[] names = new String[size];
for (int i = 0; i < size; i++) {
names[i] = accs[i].name;
}
builder.setItems(names, this);
builder.setOnCancelListener(this);
//.show();
AlertDialog dialog = builder.create();
new AQuery(act).show(dialog);
}
}
use of android.app.AlertDialog in project materialistic by hidroh.
the class DrawerActivityLoginTest method testNoExistingAccount.
@Test
public void testNoExistingAccount() {
assertThat(drawerAccount).hasText(R.string.login);
assertThat(drawerLogout).isNotVisible();
assertThat(drawerUser).isNotVisible();
Preferences.setUsername(activity, "username");
assertThat(drawerAccount).hasText("username");
assertThat(drawerLogout).isVisible();
assertThat(drawerUser).isVisible();
drawerLogout.performClick();
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
assertNotNull(alertDialog);
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
assertThat(drawerAccount).hasText(R.string.login);
assertThat(drawerLogout).isNotVisible();
}
use of android.app.AlertDialog in project materialistic by hidroh.
the class DrawerActivityLoginTest method testRemoveAccount.
@Config(sdk = 21)
@Test
public void testRemoveAccount() {
ShadowAccountManager.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(ShadowAccountManager.get(activity).getAccounts()).isEmpty();
}
use of android.app.AlertDialog in project materialistic by hidroh.
the class DrawerActivityLoginTest method testExistingAccount.
@Test
public void testExistingAccount() {
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);
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);
}
use of android.app.AlertDialog 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);
}
Aggregations