diff options
Diffstat (limited to 'tests/src/com')
-rw-r--r-- | tests/src/com/android/dialer/calllog/BlockReportSpamListenerTest.java | 72 | ||||
-rw-r--r-- | tests/src/com/android/dialer/calllog/ContactInfoHelperTest.java | 29 |
2 files changed, 98 insertions, 3 deletions
diff --git a/tests/src/com/android/dialer/calllog/BlockReportSpamListenerTest.java b/tests/src/com/android/dialer/calllog/BlockReportSpamListenerTest.java new file mode 100644 index 000000000..c63027d6b --- /dev/null +++ b/tests/src/com/android/dialer/calllog/BlockReportSpamListenerTest.java @@ -0,0 +1,72 @@ +package com.android.dialer.calllog; + +import android.app.Activity; +import android.support.v7.widget.RecyclerView; +import android.test.ActivityInstrumentationTestCase2; + +import com.android.dialer.DialtactsActivity; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler; +import com.android.dialer.service.ExtendedCallInfoService; + +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * Unit tests for {@link BlockReportSpamListener}. + */ +public class BlockReportSpamListenerTest extends ActivityInstrumentationTestCase2<DialtactsActivity> { + + private static final String TEST_DISPLAY_NUMBER = "(123)456-7890"; + private static final String TEST_NUMBER = "1234567890"; + private static final String TEST_COUNTRY_ISO = "us"; + private static final int TEST_CALL_TYPE = 0; + private static final int TEST_CALL_BLOCK_ID = 1; + + private BlockReportSpamListener blockReportSpamListener; + + @Mock private RecyclerView.Adapter adapter; + @Mock private ExtendedCallInfoService extendedCallInfoService; + @Mock private FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; + + public BlockReportSpamListenerTest() { + super(DialtactsActivity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + + MockitoAnnotations.initMocks(this); + + blockReportSpamListener = new BlockReportSpamListener( + ((Activity) getActivity()).getFragmentManager(), adapter, + extendedCallInfoService, filteredNumberAsyncQueryHandler); + } + + public void testOnBlockReportSpam() { + blockReportSpamListener.onBlockReportSpam( + TEST_DISPLAY_NUMBER, TEST_NUMBER, TEST_COUNTRY_ISO, TEST_CALL_TYPE); + } + + public void testOnBlock() { + blockReportSpamListener.onBlock( + TEST_DISPLAY_NUMBER, TEST_NUMBER, TEST_COUNTRY_ISO, TEST_CALL_TYPE); + } + + public void testOnUnlock_isSpam() { + blockReportSpamListener.onUnblock( + TEST_DISPLAY_NUMBER, TEST_NUMBER, TEST_COUNTRY_ISO, TEST_CALL_BLOCK_ID, + true, TEST_CALL_TYPE); + } + + public void testOnUnlock_isNotSpam() { + blockReportSpamListener.onUnblock( + TEST_DISPLAY_NUMBER, TEST_NUMBER, TEST_COUNTRY_ISO, TEST_CALL_BLOCK_ID, + false, TEST_CALL_TYPE); + } + + public void testOnReportNotSpam() { + blockReportSpamListener.onReportNotSpam( + TEST_DISPLAY_NUMBER, TEST_NUMBER, TEST_COUNTRY_ISO, TEST_CALL_TYPE); + } +} diff --git a/tests/src/com/android/dialer/calllog/ContactInfoHelperTest.java b/tests/src/com/android/dialer/calllog/ContactInfoHelperTest.java index e53eb7893..df385f425 100644 --- a/tests/src/com/android/dialer/calllog/ContactInfoHelperTest.java +++ b/tests/src/com/android/dialer/calllog/ContactInfoHelperTest.java @@ -17,6 +17,7 @@ package com.android.dialer.calllog; import android.net.Uri; +import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.PhoneLookup; import android.test.AndroidTestCase; @@ -101,14 +102,14 @@ public class ContactInfoHelperTest extends AndroidTestCase { public void testLookupDisplayNameAlternative_NullLookup() { Assert.assertNull(mContactInfoHelper.lookUpDisplayNameAlternative(mContext, null, - ContactsUtils.USER_TYPE_CURRENT)); + ContactsUtils.USER_TYPE_CURRENT, null)); } public void testLookupDisplayNameAlternative_NoResults() { setUpQueryExpectations(displayNameAlternativeUri, PhoneQuery.DISPLAY_NAME_ALTERNATIVE_PROJECTION); Assert.assertNull(mContactInfoHelper.lookUpDisplayNameAlternative(mContext, - TEST_LOOKUP_KEY, ContactsUtils.USER_TYPE_CURRENT)); + TEST_LOOKUP_KEY, ContactsUtils.USER_TYPE_CURRENT, null)); mContext.verify(); } @@ -117,10 +118,32 @@ public class ContactInfoHelperTest extends AndroidTestCase { PhoneQuery.DISPLAY_NAME_ALTERNATIVE_PROJECTION, TEST_DISPLAY_NAME_ALTERNATIVE_ROW); Assert.assertEquals(TEST_DISPLAY_NAME_ALTERNATIVE, mContactInfoHelper.lookUpDisplayNameAlternative(mContext, TEST_LOOKUP_KEY - , ContactsUtils.USER_TYPE_CURRENT)); + , ContactsUtils.USER_TYPE_CURRENT, null)); mContext.verify(); } + public void testLookupDisplayNameAlternative_EnterpriseLocalDirectory() { + Assert.assertNull(mContactInfoHelper.lookUpDisplayNameAlternative(mContext, TEST_LOOKUP_KEY, + ContactsUtils.USER_TYPE_WORK, ContactsContract.Directory.ENTERPRISE_DEFAULT)); + Assert.assertNull(mContactInfoHelper.lookUpDisplayNameAlternative(mContext, TEST_LOOKUP_KEY, + ContactsUtils.USER_TYPE_CURRENT, ContactsContract.Directory.ENTERPRISE_DEFAULT)); + } + + public void testLookupDisplayNameAlternative_EnterpriseRemoteDirectory() { + Assert.assertNull(mContactInfoHelper.lookUpDisplayNameAlternative(mContext, TEST_LOOKUP_KEY, + ContactsUtils.USER_TYPE_WORK, + ContactsContract.Directory.ENTERPRISE_DEFAULT + 10)); + Assert.assertNull(mContactInfoHelper.lookUpDisplayNameAlternative(mContext, TEST_LOOKUP_KEY, + ContactsUtils.USER_TYPE_CURRENT, + ContactsContract.Directory.ENTERPRISE_DEFAULT + 10)); + } + + public void testLookupDisplayNameAlternative_PersonalRemoteDirectory() { + Assert.assertNull(mContactInfoHelper.lookUpDisplayNameAlternative(mContext, null, + ContactsUtils.USER_TYPE_CURRENT, + ContactsContract.Directory.DEFAULT + 10)); + } + /* * Sets up query expectations to return the given row for all queries for the given * uri and projection. If row is null, an empty cursor is returned for query calls |