Merge "Add new warning dialogue when user is Resetting mobile network settings." into main

This commit is contained in:
Rafael Higuera Silva
2024-04-02 16:26:20 +00:00
committed by Android (Google) Code Review
8 changed files with 195 additions and 17 deletions

View File

@@ -27,6 +27,9 @@ import android.content.Intent;
import android.view.View;
import android.widget.CheckBox;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.EuiccRacConnectivityDialogActivity;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -51,6 +54,7 @@ public class ResetNetworkTest {
@Test
@Ignore
public void showFinalConfirmation_checkboxVisible_eraseEsimChecked() {
SubscriptionUtil.setEnableRacDialogForTesting(true);
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
mResetNetwork.mEsimCheckbox.setChecked(true);
@@ -61,6 +65,21 @@ public class ResetNetworkTest {
.isNotNull();
}
@Test
public void showFinalConfirmation_checkboxVisible_eraseEsimChecked_showRacWarningDialog() {
SubscriptionUtil.setEnableRacDialogForTesting(true);
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
mResetNetwork.mEsimCheckbox.setChecked(true);
mResetNetwork.showFinalConfirmation();
Intent intent = shadowOf(mActivity).getNextStartedActivity();
assertThat(intent).isNotNull();
assertThat(intent.getComponent().getClassName()).isEqualTo(
EuiccRacConnectivityDialogActivity.class.getName());
}
@Test
public void showFinalConfirmation_checkboxVisible_eraseEsimUnchecked() {
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);

View File

@@ -67,7 +67,7 @@ public class SubSettingLauncherTest {
}
@Test(expected = IllegalStateException.class)
public void cannotReuseLauncher() {
public void cannotReuseLauncher_launchMethod() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName())
.setSourceMetricsCategory(123);
@@ -76,6 +76,43 @@ public class SubSettingLauncherTest {
launcher.launch();
}
@Test(expected = IllegalArgumentException.class)
public void verifyIntent_noDestination() {
final SubSettingLauncher launcher =
spy(new SubSettingLauncher(mContext))
.setSourceMetricsCategory(123);
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(launcher.toIntent());
}
@Test(expected = IllegalArgumentException.class)
public void verifyIntent_noMetricsCategory() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName());
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(launcher.toIntent());
}
@Test(expected = IllegalArgumentException.class)
public void verifyIntent_notTheCorrectClass() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName())
.setSourceMetricsCategory(123);
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(new Intent(Intent.ACTION_MAIN));
}
@Test(expected = IllegalStateException.class)
public void cannotReuseLauncher_launchAndLaunchWithIntentMethod() {
final SubSettingLauncher launcher =
spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName())
.setSourceMetricsCategory(123);
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(launcher.toIntent());
launcher.launch();
}
@Test(expected = IllegalArgumentException.class)
public void launch_noSourceMetricsCategory_shouldCrash() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))