Merge "Fix SetupSkipDialogTest" into tm-dev
diff --git a/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java b/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
index 9be0896..fab1f03 100644
--- a/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
@@ -18,24 +18,24 @@
import static com.google.common.truth.Truth.assertThat;
-import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
+import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
-import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowAlertDialog;
+import org.robolectric.shadows.ShadowApplication;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowUtils.class, ShadowAlertDialogCompat.class})
-@Ignore
+@Config(shadows = {ShadowUtils.class, ShadowAlertDialog.class})
public class SetupSkipDialogTest {
private FragmentActivity mActivity;
@@ -45,19 +45,25 @@
mActivity = Robolectric.setupActivity(FragmentActivity.class);
}
+ private ShadowAlertDialog getShadowAlertDialog() {
+ ShadowApplication shadowApplication = Shadow.extract(
+ ApplicationProvider.getApplicationContext());
+ ShadowAlertDialog shadowAlertDialog = shadowApplication.getLatestAlertDialog();
+ assertThat(shadowAlertDialog).isNotNull();
+ return shadowAlertDialog;
+ }
+
@Test
public void frpMessages_areShownCorrectly_whenNotSupported() {
SetupSkipDialog setupSkipDialog =
SetupSkipDialog.newInstance(false, false, false, false, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_title)).isEqualTo(
- shadowAlertDialog.getTitle());
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text)).isEqualTo(
- shadowAlertDialog.getMessage());
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_title));
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_dialog_text));
}
@Test
@@ -66,29 +72,24 @@
SetupSkipDialog.newInstance(true, false, false, false, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_title)).isEqualTo(
- shadowAlertDialog.getTitle());
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text_frp)).isEqualTo(
- shadowAlertDialog.getMessage());
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_title));
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_dialog_text_frp));
}
@Test
- @Ignore
public void dialogMessage_whenSkipPinSetupForFace_shouldShownCorrectly() {
SetupSkipDialog setupSkipDialog =
SetupSkipDialog.newInstance(true, false, false, false, true, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
- mActivity.getString(R.string.lock_screen_pin_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
- mActivity.getString(R.string.lock_screen_pin_skip_biometrics_message));
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_pin_skip_face_title));
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_pin_skip_face_message));
}
@Test
@@ -97,12 +98,10 @@
SetupSkipDialog.newInstance(true, false, true, false, true, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_face_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_face_message));
}
@@ -112,12 +111,10 @@
SetupSkipDialog.newInstance(true, true, false, false, true, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_face_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_face_message));
}
@@ -127,12 +124,10 @@
SetupSkipDialog.newInstance(true, false, false, true, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_fingerprint_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_fingerprint_message));
}
@@ -142,12 +137,10 @@
SetupSkipDialog.newInstance(true, false, true, true, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_fingerprint_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_fingerprint_message));
}
@@ -157,28 +150,23 @@
SetupSkipDialog.newInstance(true, true, false, true, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_fingerprint_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_fingerprint_message));
}
-
@Test
public void dialogMessage_whenSkipPinSetupForBiometrics_shouldShownCorrectly() {
SetupSkipDialog setupSkipDialog =
SetupSkipDialog.newInstance(true, false, false, false, false, true);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_biometrics_message));
}
@@ -188,12 +176,10 @@
SetupSkipDialog.newInstance(true, false, true, false, false, true);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_biometrics_message));
}
@@ -203,12 +189,10 @@
SetupSkipDialog.newInstance(true, true, false, false, false, true);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_biometrics_message));
}
}