Search in sources :

Example 61 with Account

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();
}
Also used : Account(android.accounts.Account) Test(org.junit.Test)

Example 62 with Account

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();
}
Also used : Account(android.accounts.Account) Handler(android.os.Handler) Test(org.junit.Test)

Example 63 with Account

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();
}
Also used : Account(android.accounts.Account) Test(org.junit.Test)

Example 64 with Account

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();
}
Also used : Account(android.accounts.Account) Test(org.junit.Test)

Example 65 with Account

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");
}
Also used : Account(android.accounts.Account) Test(org.junit.Test)

Aggregations

Account (android.accounts.Account)550 Bundle (android.os.Bundle)108 AccountManager (android.accounts.AccountManager)79 Test (org.junit.Test)53 ArrayList (java.util.ArrayList)49 Intent (android.content.Intent)40 File (java.io.File)37 Cursor (android.database.Cursor)31 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)29 PersistableBundle (android.os.PersistableBundle)27 UserInfo (android.content.pm.UserInfo)22 MockContentResolver (android.test.mock.MockContentResolver)22 HashMap (java.util.HashMap)20 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)20 RemoteException (android.os.RemoteException)19 FileOutputStream (java.io.FileOutputStream)19 IOException (java.io.IOException)19 SmallTest (android.test.suitebuilder.annotation.SmallTest)18 HashSet (java.util.HashSet)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16