Search in sources :

Example 1 with MockContactPhotoManager

use of com.android.contacts.common.test.mocks.MockContactPhotoManager in project packages_apps_Contacts by AOKP.

the class PeopleActivityTest method setUp.

@Override
public void setUp() {
    mContext = new ContactsMockContext(getInstrumentation().getTargetContext());
    mContactsProvider = mContext.getContactsProvider();
    // The ContactsApplication performs this getType query to warm up the provider - see
    // ContactsApplication#DelayedInitialization.doInBackground
    mContactsProvider.expectTypeQuery(ContentUris.withAppendedId(Contacts.CONTENT_URI, 1), Contacts.CONTENT_ITEM_TYPE);
    mSettingsProvider = mContext.getSettingsProvider();
    InjectedServices services = new InjectedServices();
    services.setContentResolver(mContext.getContentResolver());
    services.setSharedPreferences(new MockSharedPreferences());
    ContactPhotoManager.injectContactPhotoManagerForTesting(new MockContactPhotoManager());
    AccountType accountType = new BaseAccountType() {

        @Override
        public boolean areContactsWritable() {
            return false;
        }
    };
    accountType.accountType = TEST_ACCOUNT_TYPE;
    AccountWithDataSet account = new AccountWithDataSet(TEST_ACCOUNT, TEST_ACCOUNT_TYPE, null);
    ContactsApplication.injectServices(services);
    final MockAccountTypeManager mockManager = new MockAccountTypeManager(new AccountType[] { accountType }, new AccountWithDataSet[] { account });
    AccountTypeManager.setInstanceForTest(mockManager);
}
Also used : InjectedServices(com.android.contacts.common.testing.InjectedServices) BaseAccountType(com.android.contacts.common.model.account.BaseAccountType) MockContactPhotoManager(com.android.contacts.common.test.mocks.MockContactPhotoManager) MockAccountTypeManager(com.android.contacts.common.test.mocks.MockAccountTypeManager) AccountWithDataSet(com.android.contacts.common.model.account.AccountWithDataSet) MockSharedPreferences(com.android.contacts.common.test.mocks.MockSharedPreferences) ContactsMockContext(com.android.contacts.common.test.mocks.ContactsMockContext) BaseAccountType(com.android.contacts.common.model.account.BaseAccountType) AccountType(com.android.contacts.common.model.account.AccountType)

Aggregations

AccountType (com.android.contacts.common.model.account.AccountType)1 AccountWithDataSet (com.android.contacts.common.model.account.AccountWithDataSet)1 BaseAccountType (com.android.contacts.common.model.account.BaseAccountType)1 ContactsMockContext (com.android.contacts.common.test.mocks.ContactsMockContext)1 MockAccountTypeManager (com.android.contacts.common.test.mocks.MockAccountTypeManager)1 MockContactPhotoManager (com.android.contacts.common.test.mocks.MockContactPhotoManager)1 MockSharedPreferences (com.android.contacts.common.test.mocks.MockSharedPreferences)1 InjectedServices (com.android.contacts.common.testing.InjectedServices)1