Hide "Wipe eUICC" option when it isn't useful.
If a user never downloaded a profile onto their eUICC, there's no reason to offer the wipe option, and it would only cause confusion. But show the option nonetheless if developer options are enabled. Bug: 38460669 Test: TreeHugger / Unit test / Manual verification Change-Id: I51fb7b9e75c4f9a46ee0b24e64bddfafcbd48b14
This commit is contained in:
@@ -17,13 +17,18 @@
|
||||
package com.android.settings;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.ContentResolver;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
@@ -82,6 +87,60 @@ public class MasterClearTest {
|
||||
when(mScrollView.getChildCount()).thenReturn(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowWipeEuicc_euiccDisabled() {
|
||||
prepareEuiccState(
|
||||
false /* isEuiccEnabled */, true /* isEuiccProvisioned */,
|
||||
true /* isDevelopmentSettingsEnabled */);
|
||||
assertThat(mMasterClear.showWipeEuicc()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowWipeEuicc_euiccEnabled_unprovisioned() {
|
||||
prepareEuiccState(
|
||||
true /* isEuiccEnabled */, false /* isEuiccProvisioned */,
|
||||
false /* isDevelopmentSettingsEnabled */);
|
||||
assertThat(mMasterClear.showWipeEuicc()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowWipeEuicc_euiccEnabled_provisioned() {
|
||||
prepareEuiccState(
|
||||
true /* isEuiccEnabled */, true /* isEuiccProvisioned */,
|
||||
false /* isDevelopmentSettingsEnabled */);
|
||||
assertThat(mMasterClear.showWipeEuicc()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowWipeEuicc_euiccEnabled_developmentSettingsEnabled() {
|
||||
prepareEuiccState(
|
||||
true /* isEuiccEnabled */, false /* isEuiccProvisioned */,
|
||||
true /* isDevelopmentSettingsEnabled */);
|
||||
assertThat(mMasterClear.showWipeEuicc()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowWipeEuicc_euiccEnabled_provisioned_developmentSettingsEnabled() {
|
||||
prepareEuiccState(
|
||||
true /* isEuiccEnabled */, true /* isEuiccProvisioned */,
|
||||
true /* isDevelopmentSettingsEnabled */);
|
||||
assertThat(mMasterClear.showWipeEuicc()).isTrue();
|
||||
}
|
||||
|
||||
private void prepareEuiccState(
|
||||
boolean isEuiccEnabled,
|
||||
boolean isEuiccProvisioned,
|
||||
boolean isDevelopmentSettingsEnabled) {
|
||||
doReturn(mActivity).when(mMasterClear).getContext();
|
||||
doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
|
||||
ContentResolver cr = mActivity.getContentResolver();
|
||||
Settings.Global.putInt(
|
||||
cr, android.provider.Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
|
||||
Settings.Global.putInt(
|
||||
cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
|
||||
isDevelopmentSettingsEnabled ? 1 : 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowFinalConfirmation_EraseEsimChecked() {
|
||||
ActivityForTest testActivity = new ActivityForTest();
|
||||
|
Reference in New Issue
Block a user