Enable controllers to use a custom key.

Test: atest SettingsUnitTests
Test: m -j45 RunSettingsRoboTests
Bug: 191763369
Change-Id: I48eea95613600580c80c8850f0a3fd543a7e0a43
This commit is contained in:
Jan Tomljanovic
2021-06-25 01:45:30 +01:00
parent 37b1831d0d
commit c6667337ca
18 changed files with 171 additions and 27 deletions

View File

@@ -65,6 +65,7 @@ public class SimLockPreferenceControllerTest {
private SimLockPreferenceController mController;
private Preference mPreference;
private Context mContext;
@Before
public void setUp() {
@@ -75,8 +76,9 @@ public class SimLockPreferenceControllerTest {
shadowApplication.setSystemService(Context.CARRIER_CONFIG_SERVICE, mCarrierManager);
shadowApplication.setSystemService(Context.USER_SERVICE, mUserManager);
shadowApplication.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
mController = new SimLockPreferenceController(RuntimeEnvironment.application);
mPreference = new Preference(RuntimeEnvironment.application);
mContext = RuntimeEnvironment.application;
mController = new SimLockPreferenceController(mContext);
mPreference = new Preference(mContext);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
@@ -136,6 +138,18 @@ public class SimLockPreferenceControllerTest {
assertThat(mPreference.isEnabled()).isTrue();
}
@Test
public void getPreferenceKey_byDefault_returnsDefaultValue() {
assertThat(mController.getPreferenceKey()).isEqualTo("sim_lock_settings");
}
@Test
public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
mController = new SimLockPreferenceController(mContext, "key");
assertThat(mController.getPreferenceKey()).isEqualTo("key");
}
private void setupMockIcc() {
final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
SubscriptionInfo info = mock(SubscriptionInfo.class);