use of android.accounts.Account in project robolectric by robolectric.
the class ShadowAccountManagerTest method removeAllAccounts.
@Test
public void removeAllAccounts() throws Exception {
Account account = new Account("name@gmail.com", "gmail.com");
shadowOf(am).addAccount(account);
assertThat(am.getAccounts()).isNotEmpty();
shadowOf(am).removeAllAccounts();
assertThat(am.getAccounts()).isEmpty();
}
use of android.accounts.Account in project robolectric by robolectric.
the class ShadowAccountManagerTest method whenSchedulerPaused_getHasFeatures_returnsTrueWhenAllFeaturesSatisfied.
@Test
public void whenSchedulerPaused_getHasFeatures_returnsTrueWhenAllFeaturesSatisfied() throws Exception {
scheduler.pause();
Account account = new Account("name", "google.com");
shadowOf(am).addAccount(account);
shadowOf(am).setFeatures(account, new String[] { "FEATURE_1", "FEATURE_2" });
TestAccountManagerCallback<Boolean> callback = new TestAccountManagerCallback<>();
AccountManagerFuture<Boolean> future = am.hasFeatures(account, new String[] { "FEATURE_1", "FEATURE_2" }, callback, new Handler());
assertThat(future.isDone()).isFalse();
assertThat(callback.hasBeenCalled()).isFalse();
assertThat(future.getResult()).isNull();
scheduler.unPause();
assertThat(future.getResult().booleanValue()).isEqualTo(true);
assertThat(future.isDone()).isTrue();
assertThat(callback.hasBeenCalled()).isTrue();
}
use of android.accounts.Account in project robolectric by robolectric.
the class ShadowAccountManagerTest method testGetSetUserData_remove.
@Test
public void testGetSetUserData_remove() {
Account account = new Account("name", "type");
boolean accountAdded = am.addAccountExplicitly(account, null, null);
assertThat(accountAdded).isTrue();
am.setUserData(account, "key123", "value123");
assertThat(am.getUserData(account, "key123")).isEqualTo("value123");
am.setUserData(account, "key123", null);
assertThat(am.getUserData(account, "key123")).isNull();
}
use of android.accounts.Account in project robolectric by robolectric.
the class ShadowAccountManagerTest method testGetSetPassword_remove.
@Test
public void testGetSetPassword_remove() {
Account account = new Account("name", "type");
boolean accountAdded = am.addAccountExplicitly(account, "passwd1", null);
assertThat(accountAdded).isTrue();
assertThat(am.getPassword(account)).isEqualTo("passwd1");
am.setPassword(account, null);
assertThat(am.getPassword(account)).isNull();
}
use of android.accounts.Account in project robolectric by robolectric.
the class ShadowAccountManagerTest method testGetSetUserData_overwrite.
@Test
public void testGetSetUserData_overwrite() {
Account account = new Account("name", "type");
boolean accountAdded = am.addAccountExplicitly(account, null, null);
assertThat(accountAdded).isTrue();
am.setUserData(account, "key123", "value123");
assertThat(am.getUserData(account, "key123")).isEqualTo("value123");
am.setUserData(account, "key123", "value456");
assertThat(am.getUserData(account, "key123")).isEqualTo("value456");
}
Aggregations