use of android.accounts.Account in project materialistic by hidroh.
the class LoginActivity method addAccount.
private void addAccount(String username, String password) {
Account account = new Account(username, BuildConfig.APPLICATION_ID);
mAccountManager.addAccountExplicitly(account, password, null);
// for re-login with updated password
mAccountManager.setPassword(account, password);
Bundle bundle = new Bundle();
bundle.putString(AccountManager.KEY_ACCOUNT_NAME, username);
bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, BuildConfig.APPLICATION_ID);
setAccountAuthenticatorResult(bundle);
Preferences.setUsername(this, username);
finish();
}
use of android.accounts.Account in project FastDev4Android by jiangqqlmj.
the class AndroidAuthenticatorTest method setUp.
@Before
public void setUp() {
mAccountManager = mock(AccountManager.class);
mFuture = mock(AccountManagerFuture.class);
mAccount = new Account("coolperson", "cooltype");
mAuthenticator = new AndroidAuthenticator(mAccountManager, mAccount, "cooltype", false);
}
use of android.accounts.Account 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.accounts.Account 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.accounts.Account 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