Search in sources :

Example 51 with Account

use of android.accounts.Account in project robolectric by robolectric.

the class ShadowAccountTest method shouldHaveParcelConstructor.

@Test
public void shouldHaveParcelConstructor() throws Exception {
    Account expected = new Account("name", "type");
    Parcel p = Parcel.obtain();
    expected.writeToParcel(p, 0);
    p.setDataPosition(0);
    Account actual = new Account(p);
    assertThat(actual).isEqualTo(expected);
}
Also used : Account(android.accounts.Account) Parcel(android.os.Parcel) Test(org.junit.Test)

Example 52 with Account

use of android.accounts.Account in project robolectric by robolectric.

the class ShadowAccountTest method shouldHaveToString.

@Test
public void shouldHaveToString() throws Exception {
    Account account = new Account("name", "type");
    assertThat(account.toString()).isEqualTo("Account {name=name, type=type}");
}
Also used : Account(android.accounts.Account) Test(org.junit.Test)

Example 53 with Account

use of android.accounts.Account in project robolectric by robolectric.

the class ShadowAccountTest method shouldBeParcelable.

@Test
public void shouldBeParcelable() throws Exception {
    Account expected = new Account("name", "type");
    Parcel p = Parcel.obtain();
    expected.writeToParcel(p, 0);
    p.setDataPosition(0);
    Account actual = Account.CREATOR.createFromParcel(p);
    assertThat(actual).isEqualTo(expected);
}
Also used : Account(android.accounts.Account) Parcel(android.os.Parcel) Test(org.junit.Test)

Example 54 with Account

use of android.accounts.Account in project robolectric by robolectric.

the class ShadowAccountTest method shouldHaveStringsConstructor.

@Test
public void shouldHaveStringsConstructor() throws Exception {
    Account account = new Account("name", "type");
    assertThat(account.name).isEqualTo("name");
    assertThat(account.type).isEqualTo("type");
}
Also used : Account(android.accounts.Account) Test(org.junit.Test)

Example 55 with Account

use of android.accounts.Account in project robolectric by robolectric.

the class ShadowAccountManagerTest method whenPaused_getAuthToken.

@Test
public void whenPaused_getAuthToken() throws Exception {
    scheduler.pause();
    Account account = new Account("name", "google.com");
    shadowOf(am).addAccount(account);
    shadowOf(am).addAuthenticator("google.com");
    am.setAuthToken(account, "auth_token_type", "token1");
    TestAccountManagerCallback<Bundle> callback = new TestAccountManagerCallback<>();
    AccountManagerFuture<Bundle> future = am.getAuthToken(account, "auth_token_type", new Bundle(), activity, callback, new Handler());
    assertThat(future.isDone()).isFalse();
    assertThat(callback.hasBeenCalled()).isFalse();
    scheduler.unPause();
    assertThat(future.isDone()).isTrue();
    assertThat(callback.hasBeenCalled()).isTrue();
}
Also used : Account(android.accounts.Account) Bundle(android.os.Bundle) Handler(android.os.Handler) 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