Search in sources :

Example 1 with ContactsMockContext

use of com.android.contacts.common.test.mocks.ContactsMockContext 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)

Example 2 with ContactsMockContext

use of com.android.contacts.common.test.mocks.ContactsMockContext in project android_packages_apps_Dialer by MoKee.

the class FilteredNumbersUtilTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    mContext = new ContactsMockContext(getContext(), FilteredNumberContract.AUTHORITY);
    // Reset whether an emergency number was dialed
    PreferenceManager.getDefaultSharedPreferences(mContext).edit().putLong(FilteredNumbersUtil.LAST_EMERGENCY_CALL_MS_PREF_KEY, 0).apply();
}
Also used : ContactsMockContext(com.android.contacts.common.test.mocks.ContactsMockContext)

Example 3 with ContactsMockContext

use of com.android.contacts.common.test.mocks.ContactsMockContext in project android_packages_apps_Dialer by MoKee.

the class PhoneNumberInteractionTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mContext = new ContactsMockContext(getInstrumentation().getTargetContext());
    mContactsProvider = mContext.getContactsProvider();
}
Also used : ContactsMockContext(com.android.contacts.common.test.mocks.ContactsMockContext)

Example 4 with ContactsMockContext

use of com.android.contacts.common.test.mocks.ContactsMockContext in project android_packages_apps_Dialer by MoKee.

the class ContactInfoHelperTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    displayNameAlternativeUri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, TEST_LOOKUP_KEY);
    mContext = new ContactsMockContext(getContext());
    mContactInfo = new ContactInfo();
    mContactInfo.name = TEST_DISPLAY_NAME;
    mContactInfo.nameAlternative = TEST_DISPLAY_NAME_ALTERNATIVE;
    mContactInfoHelper = new ContactInfoHelper(mContext, TEST_COUNTRY_ISO);
}
Also used : ContactsMockContext(com.android.contacts.common.test.mocks.ContactsMockContext)

Example 5 with ContactsMockContext

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

the class ContactDeletionInteractionTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    // This test requires that the screen be turned on.
    mUtils = new IntegrationTestUtils(getInstrumentation());
    mUtils.acquireScreenWakeLock(getInstrumentation().getTargetContext());
    mContext = new ContactsMockContext(getInstrumentation().getTargetContext());
    InjectedServices services = new InjectedServices();
    services.setContentResolver(mContext.getContentResolver());
    AccountType readOnlyAccountType = new BaseAccountType() {

        @Override
        public boolean areContactsWritable() {
            return false;
        }
    };
    readOnlyAccountType.accountType = READONLY_ACCOUNT_TYPE;
    AccountType writableAccountType = new BaseAccountType() {

        @Override
        public boolean areContactsWritable() {
            return true;
        }
    };
    writableAccountType.accountType = WRITABLE_ACCOUNT_TYPE;
    ContactsApplication.injectServices(services);
    final MockAccountTypeManager mockManager = new MockAccountTypeManager(new AccountType[] { writableAccountType, readOnlyAccountType }, null);
    AccountTypeManager.setInstanceForTest(mockManager);
    mContactsProvider = mContext.getContactsProvider();
}
Also used : InjectedServices(com.android.contacts.common.testing.InjectedServices) BaseAccountType(com.android.contacts.common.model.account.BaseAccountType) MockAccountTypeManager(com.android.contacts.common.test.mocks.MockAccountTypeManager) IntegrationTestUtils(com.android.contacts.common.test.IntegrationTestUtils) 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

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