Merge "Use regular preference theme for setup wizard"
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 6438e70..a61f105 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -96,6 +96,7 @@
<style name="PreferenceTheme.SetupWizard" parent="PreferenceTheme">
<item name="preferenceFragmentStyle">@style/SetupWizardPreferenceFragmentStyle</item>
+ <item name="preferenceStyle">@style/Preference.Material</item>
</style>
<style name="SetupWizardPreferenceFragmentStyle" parent="PreferenceFragment.Material">
diff --git a/tests/app/src/com/android/settings/dashboard/FirstIdViewMatcher.java b/tests/app/src/com/android/settings/dashboard/FirstIdViewMatcher.java
index 15290b1..910d791 100644
--- a/tests/app/src/com/android/settings/dashboard/FirstIdViewMatcher.java
+++ b/tests/app/src/com/android/settings/dashboard/FirstIdViewMatcher.java
@@ -34,7 +34,16 @@
private boolean mMatched;
public void describeTo(Description description) {
- description.appendText(" is the first view that matches id.");
+ String idDescription = Integer.toString(id);
+ if (resources != null) {
+ try {
+ idDescription = resources.getResourceName(id);
+ } catch (Resources.NotFoundException e) {
+ // No big deal, will just use the int value.
+ idDescription = String.format("%s (resource name not found)", id);
+ }
+ }
+ description.appendText("with first id: " + idDescription);
}
public boolean matchesSafely(View view) {
@@ -42,7 +51,7 @@
if (mMatched) {
return false;
} else {
- mMatched |= id == view.getId();
+ mMatched = id == view.getId();
return mMatched;
}
}
diff --git a/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java b/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java
index b99f753e..22723a6 100644
--- a/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java
+++ b/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
+import android.support.test.espresso.matcher.ViewMatchers.Visibility;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
@@ -33,9 +34,12 @@
import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static com.android.settings.dashboard.FirstIdViewMatcher.withFirstId;
+import static org.hamcrest.Matchers.allOf;
+
@RunWith(AndroidJUnit4.class)
@SmallTest
public class PreferenceThemeTest {
@@ -54,10 +58,19 @@
@Test
public void startPhoneStatus_preferenceIconSpaceReserved() throws InterruptedException {
launchPhoneStatus();
- onView(withId(android.R.id.icon_frame)).check(doesNotExist());
+ onView(withId(R.id.icon_frame)).check(doesNotExist());
onView(withFirstId(R.id.icon_container)).check(matches(isDisplayed()));
}
+ @Test
+ public void startSetupWizardLockScreen_preferenceIconSpaceNotReserved() {
+ launchSetupWizardLockScreen();
+ // Icons should not be shown, and the frame should not occupy extra space.
+ onView(allOf(withId(R.id.icon_frame), withEffectiveVisibility(Visibility.VISIBLE)))
+ .check(doesNotExist());
+ onView(withId(R.id.icon_container)).check(doesNotExist());
+ }
+
private void launchPhoneStatus() {
final Intent settingsIntent = new Intent("android.settings.DEVICE_INFO_SETTINGS")
.addCategory(Intent.CATEGORY_DEFAULT)
@@ -65,4 +78,12 @@
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
InstrumentationRegistry.getInstrumentation().startActivitySync(settingsIntent);
}
+
+ private void launchSetupWizardLockScreen() {
+ final Intent settingsIntent = new Intent("com.android.settings.SETUP_LOCK_SCREEN")
+ .addCategory(Intent.CATEGORY_DEFAULT)
+ .setPackage(mTargetPackage)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ InstrumentationRegistry.getInstrumentation().startActivitySync(settingsIntent);
+ }
}