Search in sources :

Example 1 with MockContentProvider

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

the class FilteredNumberAsyncQueryHandlerTest method testBlockNumber_Disabled.

public void testBlockNumber_Disabled() throws Throwable {
    if (!CompatUtils.isNCompatible()) {
        return;
    }
    FilteredNumberCompat.setIsEnabledForTest(false);
    final MockContentResolver resolver = new MockContentResolver();
    MockContentProvider disabledProvider = new MockContentProvider();
    resolver.addProvider(FilteredNumberContract.AUTHORITY, disabledProvider);
    disabledProvider.expectInsert(BLOCKED_NUMBER_URI_M, newBlockNumberContentValuesM(), EXPECTED_URI);
    final BlockNumberListener listener = new BlockNumberListener();
    runTestOnUiThread(new Runnable() {

        @Override
        public void run() {
            new FilteredNumberAsyncQueryHandler(resolver).blockNumber(listener, E164_NUMBER, NUMBER, COUNTRY_ISO);
        }
    });
    assertSame(EXPECTED_URI, listener.waitForCallback());
    disabledProvider.verify();
}
Also used : MockContentProvider(com.android.contacts.common.test.mocks.MockContentProvider) OnBlockNumberListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnBlockNumberListener) MockContentResolver(android.test.mock.MockContentResolver)

Example 2 with MockContentProvider

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

the class FilteredNumberAsyncQueryHandlerTest method testIsBlockedNumber_Disabled.

public void testIsBlockedNumber_Disabled() throws Throwable {
    if (!CompatUtils.isNCompatible()) {
        return;
    }
    FilteredNumberCompat.setIsEnabledForTest(false);
    final MockContentResolver resolver = new MockContentResolver();
    MockContentProvider disabledProvider = new MockContentProvider();
    resolver.addProvider(FilteredNumberContract.AUTHORITY, disabledProvider);
    disabledProvider.expectQuery(BLOCKED_NUMBER_URI_M).withProjection(FilteredNumberColumns._ID, FilteredNumberColumns.TYPE).withSelection(FilteredNumberColumns.NORMALIZED_NUMBER + " = ?", E164_NUMBER).returnRow(ID, FilteredNumberTypes.BLOCKED_NUMBER);
    final CheckBlockedListener listener = new CheckBlockedListener();
    runTestOnUiThread(new Runnable() {

        @Override
        public void run() {
            new FilteredNumberAsyncQueryHandler(resolver).isBlockedNumber(listener, NUMBER, COUNTRY_ISO);
        }
    });
    assertEquals(ID, listener.waitForCallback());
    mContentProvider.verify();
}
Also used : MockContentProvider(com.android.contacts.common.test.mocks.MockContentProvider) OnCheckBlockedListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener) MockContentResolver(android.test.mock.MockContentResolver)

Example 3 with MockContentProvider

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

the class FilteredNumberAsyncQueryHandlerTest method testUnblockNumber_Disabled.

public void testUnblockNumber_Disabled() throws Throwable {
    if (!CompatUtils.isNCompatible()) {
        return;
    }
    FilteredNumberCompat.setIsEnabledForTest(false);
    final MockContentResolver resolver = new MockContentResolver();
    MockContentProvider disabledProvider = new MockContentProvider();
    resolver.addProvider(FilteredNumberContract.AUTHORITY, disabledProvider);
    Uri uriWithId = ContentUris.withAppendedId(BLOCKED_NUMBER_URI_M, ID);
    disabledProvider.expectQuery(uriWithId).withProjection(null).withDefaultProjection(FilteredNumberCompat.getIdColumnName()).withSelection(null, null).withSortOrder(null).returnRow(ID);
    disabledProvider.expectDelete(uriWithId).returnRowsAffected(1);
    final UnblockNumberListener listener = new UnblockNumberListener();
    runTestOnUiThread(new Runnable() {

        @Override
        public void run() {
            new FilteredNumberAsyncQueryHandler(resolver).unblock(listener, ID);
        }
    });
    assertNotNull(listener.waitForCallback());
    disabledProvider.verify();
}
Also used : MockContentProvider(com.android.contacts.common.test.mocks.MockContentProvider) MockContentResolver(android.test.mock.MockContentResolver) OnUnblockNumberListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener) Uri(android.net.Uri)

Example 4 with MockContentProvider

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

the class FilteredNumberAsyncQueryHandlerTest method testHasBlockedNumbers_Disabled.

public void testHasBlockedNumbers_Disabled() throws Throwable {
    if (!CompatUtils.isNCompatible()) {
        return;
    }
    FilteredNumberCompat.setIsEnabledForTest(false);
    final MockContentResolver resolver = new MockContentResolver();
    MockContentProvider disabledProvider = new MockContentProvider();
    resolver.addProvider(FilteredNumberContract.AUTHORITY, disabledProvider);
    disabledProvider.expectQuery(BLOCKED_NUMBER_URI_M).withProjection(FilteredNumberColumns._ID).withSelection(FilteredNumberColumns.TYPE + "=" + FilteredNumberTypes.BLOCKED_NUMBER, null).returnRow(ID);
    final HasBlockedNumbersListener listener = new HasBlockedNumbersListener();
    runTestOnUiThread(new Runnable() {

        @Override
        public void run() {
            new FilteredNumberAsyncQueryHandler(resolver).hasBlockedNumbers(listener);
        }
    });
    assertTrue(listener.waitForCallback());
    disabledProvider.verify();
}
Also used : MockContentProvider(com.android.contacts.common.test.mocks.MockContentProvider) OnHasBlockedNumbersListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener) MockContentResolver(android.test.mock.MockContentResolver)

Aggregations

MockContentResolver (android.test.mock.MockContentResolver)4 MockContentProvider (com.android.contacts.common.test.mocks.MockContentProvider)4 Uri (android.net.Uri)1 OnBlockNumberListener (com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnBlockNumberListener)1 OnCheckBlockedListener (com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener)1 OnHasBlockedNumbersListener (com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener)1 OnUnblockNumberListener (com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener)1