summaryrefslogtreecommitdiff
path: root/library/test/robotest
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2017-12-05 18:52:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-12-05 18:52:12 +0000
commitac5ce544be357085d4c28475db7613d4da4a32c0 (patch)
tree0a3c2652a2f4641674611a17c5426f8b56ba21f3 /library/test/robotest
parenta5cc73845d6c947d0277478c6a09e2c99e45b6e6 (diff)
parent8b52391bba333441da82aed544bd58fae9586f15 (diff)
downloadsetupwizard-ac5ce544be357085d4c28475db7613d4da4a32c0.tar.gz
Merge "Add GLIF v3 theme and make buttons Google Blue 600"
Diffstat (limited to 'library/test/robotest')
-rw-r--r--library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java140
1 files changed, 61 insertions, 79 deletions
diff --git a/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java b/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java
index c236bb5..9195de2 100644
--- a/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java
+++ b/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java
@@ -39,6 +39,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
@RunWith(SuwLibRobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Config.NEWEST_SDK)
public class WizardManagerHelperTest {
@@ -104,75 +108,57 @@ public class WizardManagerHelperTest {
}
@Test
- public void testHoloIsNotLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "holo");
- assertFalse("Theme holo should not be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- public void testHoloLightIsLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "holo_light");
- assertTrue("Theme holo_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, false));
- }
-
- @Test
- public void testMaterialIsNotLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "material");
- assertFalse("Theme material should not be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- public void testMaterialLightIsLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "material_light");
- assertTrue("Theme material_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, false));
- }
-
- @Test
- public void testGlifIsDarkTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif");
- assertFalse("Theme glif should be dark theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertFalse("Theme glif should be dark theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- public void testGlifLightIsLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif_light");
- assertTrue("Theme glif_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertTrue("Theme glif_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
- }
-
- @Test
- public void testGlifV2IsDarkTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif_v2");
- assertFalse("Theme glif_v2 should be dark theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertFalse("Theme glif_v2 should be dark theme",
- WizardManagerHelper.isLightTheme(intent, true));
+ public void isLightTheme_shouldReturnTrue_whenThemeIsLight() {
+ List<String> lightThemes = Arrays.asList(
+ "holo_light",
+ "material_light",
+ "glif_light",
+ "glif_v2_light",
+ "glif_v3_light"
+ );
+ ArrayList<String> unexpectedIntentThemes = new ArrayList<>();
+ ArrayList<String> unexpectedStringThemes = new ArrayList<>();
+ for (final String theme : lightThemes) {
+ Intent intent = new Intent();
+ intent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
+ if (!WizardManagerHelper.isLightTheme(intent, false)) {
+ unexpectedIntentThemes.add(theme);
+ }
+ if (!WizardManagerHelper.isLightTheme(theme, false)) {
+ unexpectedStringThemes.add(theme);
+ }
+ }
+ assertTrue("Intent themes " + unexpectedIntentThemes + " should be light",
+ unexpectedIntentThemes.isEmpty());
+ assertTrue("String themes " + unexpectedStringThemes + " should be light",
+ unexpectedStringThemes.isEmpty());
}
@Test
- public void testGlifV2LightIsLightTheme() {
- final Intent intent = new Intent();
- intent.putExtra("theme", "glif_v2_light");
- assertTrue("Theme glif_v2_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, false));
- assertTrue("Theme glif_v2_light should be light theme",
- WizardManagerHelper.isLightTheme(intent, true));
+ public void isLightTheme_shouldReturnFalse_whenThemeIsNotLight() {
+ List<String> lightThemes = Arrays.asList(
+ "holo",
+ "material",
+ "glif",
+ "glif_v2",
+ "glif_v3"
+ );
+ ArrayList<String> unexpectedIntentThemes = new ArrayList<>();
+ ArrayList<String> unexpectedStringThemes = new ArrayList<>();
+ for (final String theme : lightThemes) {
+ Intent intent = new Intent();
+ intent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
+ if (WizardManagerHelper.isLightTheme(intent, true)) {
+ unexpectedIntentThemes.add(theme);
+ }
+ if (WizardManagerHelper.isLightTheme(theme, true)) {
+ unexpectedStringThemes.add(theme);
+ }
+ }
+ assertTrue("Intent themes " + unexpectedIntentThemes + " should not be light",
+ unexpectedIntentThemes.isEmpty());
+ assertTrue("String themes " + unexpectedStringThemes + " should not be light",
+ unexpectedStringThemes.isEmpty());
}
@Test
@@ -195,19 +181,15 @@ public class WizardManagerHelperTest {
}
@Test
- public void testIsLightThemeString() {
- assertTrue("isLightTheme should return true for material_light",
- WizardManagerHelper.isLightTheme("material_light", false));
- assertFalse("isLightTheme should return false for material",
- WizardManagerHelper.isLightTheme("material", false));
- assertTrue("isLightTheme should return true for holo_light",
- WizardManagerHelper.isLightTheme("holo_light", false));
- assertFalse("isLightTheme should return false for holo",
- WizardManagerHelper.isLightTheme("holo", false));
- assertTrue("isLightTheme should return default value true",
- WizardManagerHelper.isLightTheme("abracadabra", true));
- assertFalse("isLightTheme should return default value false",
- WizardManagerHelper.isLightTheme("abracadabra", false));
+ public void testGetThemeResGlifV3Light() {
+ assertEquals(R.style.SuwThemeGlifV3_Light,
+ WizardManagerHelper.getThemeRes("glif_v3_light", 0));
+ }
+
+ @Test
+ public void testGetThemeResGlifV3() {
+ assertEquals(R.style.SuwThemeGlifV3,
+ WizardManagerHelper.getThemeRes("glif_v3", 0));
}
@Test