aboutsummaryrefslogtreecommitdiff
path: root/tests/telephonytests
diff options
context:
space:
mode:
authorXiangyu/Malcolm Chen <refuhoo@google.com>2020-06-02 23:02:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-02 23:02:55 +0000
commitc75299947407b09cb87a802986a29ddca689daf2 (patch)
treed82e000fb6e7b0ff228da4a95e8b0942b7f4946e /tests/telephonytests
parent3ebf56564e2c209419235a0bd5dbb61768c69736 (diff)
parentb4723375b6771c3a21ef55fb20b9b4abe15c9d96 (diff)
downloadtelephony-c75299947407b09cb87a802986a29ddca689daf2.tar.gz
Merge "Fix bug that setOperatorBrandOverride applies on wrong subId." into rvc-dev
Diffstat (limited to 'tests/telephonytests')
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/uicc/UiccProfileTest.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/telephonytests/src/com/android/internal/telephony/uicc/UiccProfileTest.java b/tests/telephonytests/src/com/android/internal/telephony/uicc/UiccProfileTest.java
index f4bd633bd5..61a5e13bb9 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/uicc/UiccProfileTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/uicc/UiccProfileTest.java
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.atLeast;
@@ -35,6 +37,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionInfo;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -547,6 +550,47 @@ public class UiccProfileTest extends TelephonyTest {
assertTrue(carrierFound);
}
+ @Mock
+ private SubscriptionInfo mSubscriptionInfo;
+
+ @Test
+ public void testSetOperatorBrandOverride() {
+ testUpdateUiccProfileApplication();
+ String fakeIccId = "1234567";
+ String fakeBrand = "operator";
+
+ mUiccProfile.getApplicationIndex(0).getIccRecords().mIccId = fakeIccId;
+ doReturn(fakeIccId).when(mSubscriptionInfo).getIccId();
+ doReturn(mSubscriptionInfo).when(mSubscriptionController)
+ .getActiveSubscriptionInfoForSimSlotIndex(eq(0), any(), any());
+
+ mUiccProfile.setOperatorBrandOverride(fakeBrand);
+ String brandInSharedPreference = mContext.getSharedPreferences("file name", 0)
+ .getString("operator_branding_" + fakeIccId, null);
+ assertEquals(fakeBrand, brandInSharedPreference);
+ }
+
+ @Test
+ public void testSetOperatorBrandOverrideIccNotMatch() {
+ testUpdateUiccProfileApplication();
+ String fakeIccId1 = "1234567";
+ String fakeIccId2 = "7654321";
+ String fakeBrand = "operator";
+
+ mUiccProfile.getApplicationIndex(0).getIccRecords().mIccId = fakeIccId1;
+ doReturn(fakeIccId2).when(mSubscriptionInfo).getIccId();
+ doReturn(mSubscriptionInfo).when(mSubscriptionController)
+ .getActiveSubscriptionInfoForSimSlotIndex(eq(0), any(), any());
+
+ mUiccProfile.setOperatorBrandOverride(fakeBrand);
+ String brandInSharedPreference = mContext.getSharedPreferences("file name", 0)
+ .getString("operator_branding_" + fakeIccId1, null);
+ assertNull(brandInSharedPreference);
+ brandInSharedPreference = mContext.getSharedPreferences("file name", 0)
+ .getString("operator_branding_" + fakeIccId2, null);
+ assertNull(brandInSharedPreference);
+ }
+
@Test
@SmallTest
public void testIsEmptyProfile() {