diff options
author | Brandon Maxwell <maxwelb@google.com> | 2016-03-17 16:01:57 -0700 |
---|---|---|
committer | Brandon Maxwell <maxwelb@google.com> | 2016-03-18 19:55:28 -0700 |
commit | 3ec5d25470379acbbf3bb2bcc83e5e897a22a59d (patch) | |
tree | f41f9286374543fd5dbfb2c8a342025128ca9935 /tests/src/com/android | |
parent | f804a91865c7916369e1ab119dfb13d35ca5f033 (diff) |
Only allow primary users to block numbers
+ By design, only the primary user has the capability to block
numbers.
+ This CL ensures that secondary users don't see the option to block
numbers in the call log or call details.
Change-Id: I576925510cfbef417c16910218014d9f7b7dd2a0
Fixes: 27366206
Diffstat (limited to 'tests/src/com/android')
-rw-r--r-- | tests/src/com/android/dialer/compat/FilteredNumberCompatTest.java | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/tests/src/com/android/dialer/compat/FilteredNumberCompatTest.java b/tests/src/com/android/dialer/compat/FilteredNumberCompatTest.java index 5ee2f28e1..3572316db 100644 --- a/tests/src/com/android/dialer/compat/FilteredNumberCompatTest.java +++ b/tests/src/com/android/dialer/compat/FilteredNumberCompatTest.java @@ -18,19 +18,20 @@ package com.android.dialer.compat; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.ComponentName; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; -import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; +import android.os.UserManager; import android.provider.BlockedNumberContract.BlockedNumbers; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; -import android.util.Log; import com.android.contacts.common.compat.CompatUtils; import com.android.dialer.DialerApplication; @@ -41,7 +42,6 @@ import com.android.dialer.database.FilteredNumberContract.FilteredNumberTypes; import com.android.dialer.filterednumber.BlockedNumbersSettingsActivity; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import java.util.Arrays; @@ -227,6 +227,54 @@ public class FilteredNumberCompatTest extends AndroidTestCase { .getComponent())); } + public void testCanCurrentUserOpenBlockSettings_M_SecondaryUser() { + if (CompatUtils.isNCompatible()) { + return; + } + UserManager userManager = mock(UserManager.class); + when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(userManager); + when(userManager.isSystemUser()).thenReturn(false); + assertFalse(FilteredNumberCompat.canCurrentUserOpenBlockSettings(mContext)); + verify(mContext).getSystemService(Context.USER_SERVICE); + verify(userManager).isSystemUser(); + } + + public void testCanCurrentUserOpenBlockSettings_M_PrimaryUser() { + if (CompatUtils.isNCompatible()) { + return; + } + UserManager userManager = mock(UserManager.class); + when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(userManager); + when(userManager.isSystemUser()).thenReturn(true); + assertTrue(FilteredNumberCompat.canCurrentUserOpenBlockSettings(mContext)); + verify(mContext).getSystemService(Context.USER_SERVICE); + verify(userManager).isSystemUser(); + } + + public void testCanAttemptBlockOperations_M_SecondaryUser() { + if (CompatUtils.isNCompatible()) { + return; + } + UserManager userManager = mock(UserManager.class); + when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(userManager); + when(userManager.isSystemUser()).thenReturn(false); + assertFalse(FilteredNumberCompat.canAttemptBlockOperations(mContext)); + verify(mContext).getSystemService(Context.USER_SERVICE); + verify(userManager).isSystemUser(); + } + + public void testCanAttemptBlockOperations_M_PrimaryUser() { + if (CompatUtils.isNCompatible()) { + return; + } + UserManager userManager = mock(UserManager.class); + when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(userManager); + when(userManager.isSystemUser()).thenReturn(true); + assertTrue(FilteredNumberCompat.canAttemptBlockOperations(mContext)); + verify(mContext).getSystemService(Context.USER_SERVICE); + verify(userManager).isSystemUser(); + } + private ContentValues newExpectedContentValuesM(String number, String e164Number, String countryIso) { ContentValues contentValues = new ContentValues(); |