Update eSIM deletion strings.
Adds some conditional behavior for the confirmation screens. When the erase eSIM option is visible and checked, shows alternate string. Fixes: 126262481 Fixes: 118751918 Test: visual inspection & make -j RunSettingsRoboTests Change-Id: I40f983b03ad470d785bf104e645dbc92e7897d2d
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/reset_network_confirm"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
|
@@ -3592,14 +3592,18 @@
|
|||||||
<string name="reset_network_title">Reset Wi-Fi, mobile & Bluetooth</string>
|
<string name="reset_network_title">Reset Wi-Fi, mobile & Bluetooth</string>
|
||||||
<!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] -->
|
||||||
<string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string>
|
<string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string>
|
||||||
|
|
||||||
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=30] -->
|
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=30] -->
|
||||||
<string name="reset_esim_title">Erase eSIMs</string>
|
<string name="reset_esim_title">Erase downloaded SIMs</string>
|
||||||
<!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
|
||||||
<string name="reset_esim_desc">You\u2019ll have to contact your carrier to download replacement eSIMs. This won\u2019t cancel any mobile service plans.</string>
|
<string name="reset_esim_desc">To download replacement SIMs, contact your carrier. This won\u2019t cancel any mobile service plans.</string>
|
||||||
|
|
||||||
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
|
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
|
||||||
<string name="reset_network_button_text">Reset settings</string>
|
<string name="reset_network_button_text">Reset settings</string>
|
||||||
<!-- SD card & phone storage settings screen, message on screen after user selects Reset settings button -->
|
<!-- SD card & phone storage settings screen, message on screen after user selects Reset settings button -->
|
||||||
<string name="reset_network_final_desc">Reset all network settings? You can\u2019t undo this action!</string>
|
<string name="reset_network_final_desc">Reset all network settings? You can\u2019t undo this action.</string>
|
||||||
|
<!-- SD card & phone storage settings screen, message on screen after user selects Reset settings button [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="reset_network_final_desc_esim">Reset all network settings and erase downloaded SIMs? You can\u2019t undo this action.</string>
|
||||||
<!-- SD card & phone storage settings screen, button on screen after user selects Reset settings button -->
|
<!-- SD card & phone storage settings screen, button on screen after user selects Reset settings button -->
|
||||||
<string name="reset_network_final_button_text">Reset settings</string>
|
<string name="reset_network_final_button_text">Reset settings</string>
|
||||||
<!-- Reset settings confirmation screen title [CHAR LIMIT=30] -->
|
<!-- Reset settings confirmation screen title [CHAR LIMIT=30] -->
|
||||||
@@ -3609,9 +3613,9 @@
|
|||||||
<!-- Reset settings complete toast text [CHAR LIMIT=75] -->
|
<!-- Reset settings complete toast text [CHAR LIMIT=75] -->
|
||||||
<string name="reset_network_complete_toast">Network settings have been reset</string>
|
<string name="reset_network_complete_toast">Network settings have been reset</string>
|
||||||
<!-- Title of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
|
<!-- Title of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
|
||||||
<string name="reset_esim_error_title">Cant\u2019t reset eSIMs</string>
|
<string name="reset_esim_error_title">Can\u2019t erase SIMs</string>
|
||||||
<!-- Message of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
|
<!-- Message of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
|
||||||
<string name="reset_esim_error_msg">The eSIMs can\u2019tt be reset due to an error.</string>
|
<string name="reset_esim_error_msg">Downloaded SIMs can\u2019t be erased due to an error.\n\nRestart your device and try again.</string>
|
||||||
|
|
||||||
<!-- Master Clear -->
|
<!-- Master Clear -->
|
||||||
<!-- Button title to factory data reset the entire device -->
|
<!-- Button title to factory data reset the entire device -->
|
||||||
@@ -3649,7 +3653,9 @@
|
|||||||
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
|
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
|
||||||
<string name="master_clear_button_text" product="default">Erase all data</string>
|
<string name="master_clear_button_text" product="default">Erase all data</string>
|
||||||
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button -->
|
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button -->
|
||||||
<string name="master_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action!</string>
|
<string name="master_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action.</string>
|
||||||
|
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="master_clear_final_desc_esim">All of your personal information, including downloaded apps & SIMs, will be deleted. You can\u2019t undo this action.</string>
|
||||||
<!-- SD card & phone storage settings screen, button on screen after user selects Reset phone button -->
|
<!-- SD card & phone storage settings screen, button on screen after user selects Reset phone button -->
|
||||||
<string name="master_clear_final_button_text">Erase everything</string>
|
<string name="master_clear_final_button_text">Erase everything</string>
|
||||||
<!-- Master clear failed message -->
|
<!-- Master clear failed message -->
|
||||||
|
@@ -102,7 +102,8 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
|||||||
private View mExternalStorageContainer;
|
private View mExternalStorageContainer;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
CheckBox mExternalStorage;
|
CheckBox mExternalStorage;
|
||||||
private View mEsimStorageContainer;
|
@VisibleForTesting
|
||||||
|
View mEsimStorageContainer;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
CheckBox mEsimStorage;
|
CheckBox mEsimStorage;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -181,7 +182,8 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
|||||||
void showFinalConfirmation() {
|
void showFinalConfirmation() {
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
||||||
args.putBoolean(ERASE_ESIMS_EXTRA, mEsimStorage.isChecked());
|
args.putBoolean(ERASE_ESIMS_EXTRA,
|
||||||
|
mEsimStorageContainer.getVisibility() == View.VISIBLE && mEsimStorage.isChecked());
|
||||||
new SubSettingLauncher(getContext())
|
new SubSettingLauncher(getContext())
|
||||||
.setDestination(MasterClearConfirm.class.getName())
|
.setDestination(MasterClearConfirm.class.getName())
|
||||||
.setArguments(args)
|
.setArguments(args)
|
||||||
|
@@ -40,6 +40,8 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
|
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
|
||||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||||
@@ -62,9 +64,9 @@ import com.google.android.setupdesign.GlifLayout;
|
|||||||
public class MasterClearConfirm extends InstrumentedFragment {
|
public class MasterClearConfirm extends InstrumentedFragment {
|
||||||
private final static String TAG = "MasterClearConfirm";
|
private final static String TAG = "MasterClearConfirm";
|
||||||
|
|
||||||
private View mContentView;
|
@VisibleForTesting View mContentView;
|
||||||
private boolean mEraseSdCard;
|
private boolean mEraseSdCard;
|
||||||
private boolean mEraseEsims;
|
@VisibleForTesting boolean mEraseEsims;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user has gone through the multiple confirmation, so now we go ahead
|
* The user has gone through the multiple confirmation, so now we go ahead
|
||||||
@@ -199,6 +201,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
|||||||
setUpActionBarAndTitle();
|
setUpActionBarAndTitle();
|
||||||
establishFinalConfirmationState();
|
establishFinalConfirmationState();
|
||||||
setAccessibilityTitle();
|
setAccessibilityTitle();
|
||||||
|
setSubtitle();
|
||||||
return mContentView;
|
return mContentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,6 +215,14 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void setSubtitle() {
|
||||||
|
if (mEraseEsims) {
|
||||||
|
((TextView) mContentView.findViewById(R.id.master_clear_confirm))
|
||||||
|
.setText(R.string.master_clear_final_desc_esim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@@ -42,6 +42,8 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.internal.telephony.PhoneConstants;
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
@@ -74,8 +76,8 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
private View mContentView;
|
private View mContentView;
|
||||||
private Spinner mSubscriptionSpinner;
|
private Spinner mSubscriptionSpinner;
|
||||||
private Button mInitiateButton;
|
private Button mInitiateButton;
|
||||||
private View mEsimContainer;
|
@VisibleForTesting View mEsimContainer;
|
||||||
private CheckBox mEsimCheckbox;
|
@VisibleForTesting CheckBox mEsimCheckbox;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@@ -112,14 +114,16 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFinalConfirmation() {
|
@VisibleForTesting
|
||||||
|
void showFinalConfirmation() {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
if (mSubscriptions != null && mSubscriptions.size() > 0) {
|
if (mSubscriptions != null && mSubscriptions.size() > 0) {
|
||||||
int selectedIndex = mSubscriptionSpinner.getSelectedItemPosition();
|
int selectedIndex = mSubscriptionSpinner.getSelectedItemPosition();
|
||||||
SubscriptionInfo subscription = mSubscriptions.get(selectedIndex);
|
SubscriptionInfo subscription = mSubscriptions.get(selectedIndex);
|
||||||
args.putInt(PhoneConstants.SUBSCRIPTION_KEY, subscription.getSubscriptionId());
|
args.putInt(PhoneConstants.SUBSCRIPTION_KEY, subscription.getSubscriptionId());
|
||||||
}
|
}
|
||||||
args.putBoolean(MasterClear.ERASE_ESIMS_EXTRA, mEsimCheckbox.isChecked());
|
args.putBoolean(MasterClear.ERASE_ESIMS_EXTRA,
|
||||||
|
mEsimContainer.getVisibility() == View.VISIBLE && mEsimCheckbox.isChecked());
|
||||||
new SubSettingLauncher(getContext())
|
new SubSettingLauncher(getContext())
|
||||||
.setDestination(ResetNetworkConfirm.class.getName())
|
.setDestination(ResetNetworkConfirm.class.getName())
|
||||||
.setArguments(args)
|
.setArguments(args)
|
||||||
|
@@ -40,6 +40,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -64,7 +65,7 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
|
|||||||
*/
|
*/
|
||||||
public class ResetNetworkConfirm extends InstrumentedFragment {
|
public class ResetNetworkConfirm extends InstrumentedFragment {
|
||||||
|
|
||||||
private View mContentView;
|
@VisibleForTesting View mContentView;
|
||||||
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
@VisibleForTesting boolean mEraseEsim;
|
@VisibleForTesting boolean mEraseEsim;
|
||||||
@VisibleForTesting EraseEsimAsyncTask mEraseEsimTask;
|
@VisibleForTesting EraseEsimAsyncTask mEraseEsimTask;
|
||||||
@@ -207,6 +208,14 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
|
|||||||
.setOnClickListener(mFinalClickListener);
|
.setOnClickListener(mFinalClickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void setSubtitle() {
|
||||||
|
if (mEraseEsim) {
|
||||||
|
((TextView) mContentView.findViewById(R.id.reset_network_confirm))
|
||||||
|
.setText(R.string.reset_network_final_desc_esim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@@ -224,6 +233,7 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
|
|||||||
}
|
}
|
||||||
mContentView = inflater.inflate(R.layout.reset_network_confirm, null);
|
mContentView = inflater.inflate(R.layout.reset_network_confirm, null);
|
||||||
establishFinalConfirmationState();
|
establishFinalConfirmationState();
|
||||||
|
setSubtitle();
|
||||||
return mContentView;
|
return mContentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class MasterClearConfirmTest {
|
||||||
|
private Activity mActivity;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mActivity = Robolectric.setupActivity(Activity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setSubtitle_eraseEsim() {
|
||||||
|
MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
|
||||||
|
masterClearConfirm.mEraseEsims = true;
|
||||||
|
masterClearConfirm.mContentView =
|
||||||
|
LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
|
||||||
|
|
||||||
|
masterClearConfirm.setSubtitle();
|
||||||
|
|
||||||
|
assertThat(((TextView) masterClearConfirm.mContentView
|
||||||
|
.findViewById(R.id.master_clear_confirm)).getText())
|
||||||
|
.isEqualTo(mActivity.getString(R.string.master_clear_final_desc_esim));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setSubtitle_notEraseEsim() {
|
||||||
|
MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
|
||||||
|
masterClearConfirm.mEraseEsims = false;
|
||||||
|
masterClearConfirm.mContentView =
|
||||||
|
LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
|
||||||
|
|
||||||
|
masterClearConfirm.setSubtitle();
|
||||||
|
|
||||||
|
assertThat(((TextView) masterClearConfirm.mContentView
|
||||||
|
.findViewById(R.id.master_clear_confirm)).getText())
|
||||||
|
.isEqualTo(mActivity.getString(R.string.master_clear_final_desc));
|
||||||
|
}
|
||||||
|
}
|
@@ -108,12 +108,14 @@ public class MasterClearTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShowFinalConfirmation_eraseEsimChecked() {
|
public void testShowFinalConfirmation_eraseEsimVisible_eraseEsimChecked() {
|
||||||
final Context context = mock(Context.class);
|
final Context context = mock(Context.class);
|
||||||
when(mMasterClear.getContext()).thenReturn(context);
|
when(mMasterClear.getContext()).thenReturn(context);
|
||||||
|
|
||||||
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
||||||
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
||||||
|
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
|
||||||
|
mMasterClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
|
||||||
mMasterClear.mEsimStorage.setChecked(true);
|
mMasterClear.mEsimStorage.setChecked(true);
|
||||||
mMasterClear.showFinalConfirmation();
|
mMasterClear.showFinalConfirmation();
|
||||||
|
|
||||||
@@ -126,12 +128,14 @@ public class MasterClearTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShowFinalConfirmation_eraseEsimUnchecked() {
|
public void testShowFinalConfirmation_eraseEsimVisible_eraseEsimUnchecked() {
|
||||||
final Context context = mock(Context.class);
|
final Context context = mock(Context.class);
|
||||||
when(mMasterClear.getContext()).thenReturn(context);
|
when(mMasterClear.getContext()).thenReturn(context);
|
||||||
|
|
||||||
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
||||||
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
||||||
|
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
|
||||||
|
mMasterClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
|
||||||
mMasterClear.mEsimStorage.setChecked(false);
|
mMasterClear.mEsimStorage.setChecked(false);
|
||||||
mMasterClear.showFinalConfirmation();
|
mMasterClear.showFinalConfirmation();
|
||||||
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
|
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
|
||||||
@@ -142,6 +146,45 @@ public class MasterClearTest {
|
|||||||
.isFalse();
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShowFinalConfirmation_eraseEsimGone_eraseEsimChecked() {
|
||||||
|
final Context context = mock(Context.class);
|
||||||
|
when(mMasterClear.getContext()).thenReturn(context);
|
||||||
|
|
||||||
|
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
||||||
|
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
||||||
|
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
|
||||||
|
mMasterClear.mEsimStorageContainer.setVisibility(View.GONE);
|
||||||
|
mMasterClear.mEsimStorage.setChecked(true);
|
||||||
|
mMasterClear.showFinalConfirmation();
|
||||||
|
|
||||||
|
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
|
||||||
|
verify(context).startActivity(intent.capture());
|
||||||
|
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShowFinalConfirmation_eraseEsimGone_eraseEsimUnchecked() {
|
||||||
|
final Context context = mock(Context.class);
|
||||||
|
when(mMasterClear.getContext()).thenReturn(context);
|
||||||
|
|
||||||
|
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
||||||
|
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
||||||
|
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
|
||||||
|
mMasterClear.mEsimStorageContainer.setVisibility(View.GONE);
|
||||||
|
mMasterClear.mEsimStorage.setChecked(false);
|
||||||
|
mMasterClear.showFinalConfirmation();
|
||||||
|
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
|
||||||
|
verify(context).startActivity(intent.capture());
|
||||||
|
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShowWipeEuicc_euiccDisabled() {
|
public void testShowWipeEuicc_euiccDisabled() {
|
||||||
prepareEuiccState(
|
prepareEuiccState(
|
||||||
|
@@ -21,6 +21,8 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.testutils.shadow.ShadowRecoverySystem;
|
import com.android.settings.testutils.shadow.ShadowRecoverySystem;
|
||||||
import com.android.settings.testutils.shadow.ShadowWifiP2pManager;
|
import com.android.settings.testutils.shadow.ShadowWifiP2pManager;
|
||||||
@@ -86,4 +88,30 @@ public class ResetNetworkConfirmTest {
|
|||||||
|
|
||||||
assertThat(ShadowWifiP2pManager.getFactoryResetCount()).isEqualTo(1);
|
assertThat(ShadowWifiP2pManager.getFactoryResetCount()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setSubtitle_eraseEsim() {
|
||||||
|
mResetNetworkConfirm.mEraseEsim = true;
|
||||||
|
mResetNetworkConfirm.mContentView =
|
||||||
|
LayoutInflater.from(mActivity).inflate(R.layout.reset_network_confirm, null);
|
||||||
|
|
||||||
|
mResetNetworkConfirm.setSubtitle();
|
||||||
|
|
||||||
|
assertThat(((TextView) mResetNetworkConfirm.mContentView
|
||||||
|
.findViewById(R.id.reset_network_confirm)).getText())
|
||||||
|
.isEqualTo(mActivity.getString(R.string.reset_network_final_desc_esim));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setSubtitle_notEraseEsim() {
|
||||||
|
mResetNetworkConfirm.mEraseEsim = false;
|
||||||
|
mResetNetworkConfirm.mContentView =
|
||||||
|
LayoutInflater.from(mActivity).inflate(R.layout.reset_network_confirm, null);
|
||||||
|
|
||||||
|
mResetNetworkConfirm.setSubtitle();
|
||||||
|
|
||||||
|
assertThat(((TextView) mResetNetworkConfirm.mContentView
|
||||||
|
.findViewById(R.id.reset_network_confirm)).getText())
|
||||||
|
.isEqualTo(mActivity.getString(R.string.reset_network_final_desc));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.robolectric.Shadows.shadowOf;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class ResetNetworkTest {
|
||||||
|
private Activity mActivity;
|
||||||
|
private ResetNetwork mResetNetwork;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mActivity = Robolectric.setupActivity(Activity.class);
|
||||||
|
mResetNetwork = spy(new ResetNetwork());
|
||||||
|
when(mResetNetwork.getContext()).thenReturn(mActivity);
|
||||||
|
mResetNetwork.mEsimContainer = new View(mActivity);
|
||||||
|
mResetNetwork.mEsimCheckbox = new CheckBox(mActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showFinalConfirmation_checkboxVisible_eraseEsimChecked() {
|
||||||
|
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
|
||||||
|
mResetNetwork.mEsimCheckbox.setChecked(true);
|
||||||
|
|
||||||
|
mResetNetwork.showFinalConfirmation();
|
||||||
|
|
||||||
|
Intent intent = shadowOf(mActivity).getNextStartedActivity();
|
||||||
|
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showFinalConfirmation_checkboxVisible_eraseEsimUnchecked() {
|
||||||
|
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
|
||||||
|
mResetNetwork.mEsimCheckbox.setChecked(false);
|
||||||
|
|
||||||
|
mResetNetwork.showFinalConfirmation();
|
||||||
|
|
||||||
|
Intent intent = shadowOf(mActivity).getNextStartedActivity();
|
||||||
|
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showFinalConfirmation_checkboxGone_eraseEsimChecked() {
|
||||||
|
mResetNetwork.mEsimContainer.setVisibility(View.GONE);
|
||||||
|
mResetNetwork.mEsimCheckbox.setChecked(true);
|
||||||
|
|
||||||
|
mResetNetwork.showFinalConfirmation();
|
||||||
|
|
||||||
|
Intent intent = shadowOf(mActivity).getNextStartedActivity();
|
||||||
|
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showFinalConfirmation_checkboxGone_eraseEsimUnchecked() {
|
||||||
|
mResetNetwork.mEsimContainer.setVisibility(View.GONE);
|
||||||
|
mResetNetwork.mEsimCheckbox.setChecked(false);
|
||||||
|
|
||||||
|
mResetNetwork.showFinalConfirmation();
|
||||||
|
|
||||||
|
Intent intent = shadowOf(mActivity).getNextStartedActivity();
|
||||||
|
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user