Merge "UI Tweak for eSIM related" into pi-dev am: 2a6b9ff315

am: c3d81ef8ab

Change-Id: Id80cd9d315dd63fb7bcd4bdd44798675de1d9595
This commit is contained in:
Qingxi Li
2018-03-20 23:22:13 +00:00
committed by android-build-merger
5 changed files with 42 additions and 11 deletions

View File

@@ -45,6 +45,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ScrollView;
@@ -142,27 +143,43 @@ public class MasterClearTest {
@Test
public void testShowWipeEuicc_euiccDisabled() {
prepareEuiccState(false /* isEuiccEnabled */, true /* isEuiccProvisioned */);
prepareEuiccState(
false /* isEuiccEnabled */,
true /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
}
@Test
public void testShowWipeEuicc_euiccEnabled_unprovisioned() {
prepareEuiccState(true /* isEuiccEnabled */, false /* isEuiccProvisioned */);
prepareEuiccState(
true /* isEuiccEnabled */,
false /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
}
@Test
public void testShowWipeEuicc_euiccEnabled_provisioned() {
prepareEuiccState(true /* isEuiccEnabled */, true /* isEuiccProvisioned */);
prepareEuiccState(
true /* isEuiccEnabled */,
true /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue();
}
private void prepareEuiccState(boolean isEuiccEnabled, boolean isEuiccProvisioned) {
doReturn(mActivity).when(mMasterClear).getContext();
doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
ContentResolver cr = mActivity.getContentResolver();
Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
@Test
public void testShowWipeEuicc_developerMode_unprovisioned() {
prepareEuiccState(
true /* isEuiccEnabled */,
false /* isEuiccProvisioned */,
true /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue();
}
@Test
public void testEsimRecheckBoxDefaultChecked() {
assertThat(((CheckBox) mContentView.findViewById(R.id.erase_esim)).isChecked()).isTrue();
}
@Test
@@ -373,6 +390,16 @@ public class MasterClearTest {
verify(viewTreeObserver, never()).removeOnGlobalLayoutListener(mMasterClear);
}
private void prepareEuiccState(
boolean isEuiccEnabled, boolean isEuiccProvisioned, boolean isDeveloper) {
doReturn(mActivity).when(mMasterClear).getContext();
doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
ContentResolver cr = mActivity.getContentResolver();
Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
Settings.Global.putInt(
cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, isDeveloper ? 1 : 0);
}
private void initScrollView(int height, int scrollY, int childBottom) {
when(mScrollView.getHeight()).thenReturn(height);
when(mScrollView.getScrollY()).thenReturn(scrollY);