Font size page support light theme in deferred setup

Bug:124470158
Test: atest & manually test
Change-Id: I41e1e98a9a64e516a294c4a94c8b5f335434078f
Merged-In: I41e1e98a9a64e516a294c4a94c8b5f335434078f
This commit is contained in:
cnchen
2019-05-06 10:19:10 +08:00
parent 26ff84d3f4
commit 3eee5cf02e
9 changed files with 171 additions and 11 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings;
import static com.google.common.truth.Truth.assertThat;
import android.content.Intent;
import android.os.Bundle;
import android.sysprop.SetupWizardProperties;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -31,9 +32,6 @@ import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class SetupWizardUtilsTest {
private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
private static final String EXTRA_IS_FIRST_RUN = "firstRun";
@Test
public void testCopySetupExtras() {
Intent fromIntent = new Intent();
@@ -46,6 +44,25 @@ public class SetupWizardUtilsTest {
assertThat(theme).isEqualTo(toIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, false))
.isTrue();
assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true))
.isFalse();
}
@Test
public void testCopyLifecycleExtra() {
Intent fromIntent = new Intent();
final String theme = "TEST_THEME";
fromIntent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
fromIntent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
Bundle dstBundle = new Bundle();
dstBundle = SetupWizardUtils.copyLifecycleExtra(fromIntent.getExtras(), dstBundle);
assertThat(dstBundle).isNotNull();
assertThat(dstBundle.getString(WizardManagerHelper.EXTRA_THEME)).isNull();
assertThat(dstBundle.getBoolean(WizardManagerHelper.EXTRA_IS_SETUP_FLOW))
.isTrue();
assertThat(dstBundle.getBoolean(WizardManagerHelper.EXTRA_IS_FIRST_RUN))
.isFalse();
}
@Test
@@ -87,7 +104,7 @@ public class SetupWizardUtilsTest {
private Intent createSetupWizardIntent() {
return new Intent()
.putExtra(EXTRA_IS_SETUP_FLOW, true)
.putExtra(EXTRA_IS_FIRST_RUN, true);
.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)
.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
}
}

View File

@@ -16,18 +16,27 @@
package com.android.settings.accessibility;
import static com.android.settings.accessibility.AccessibilitySettingsForSetupWizardActivity.CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW;
import static com.google.common.truth.Truth.assertThat;
import android.content.ComponentName;
import android.content.Intent;
import androidx.test.filters.SmallTest;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
import com.google.android.setupcompat.util.WizardManagerHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
@RunWith(RobolectricTestRunner.class)
@SmallTest
@@ -41,4 +50,37 @@ public class AccessibilitySettingsForSetupWizardActivityTest {
assertThat(activity.getThemeResId()).isEqualTo(R.style.GlifV3Theme_Light);
}
@Test
public void onCreate_hasFontSizeComponent_shouldGoToFontSizePreferenceDirectly() {
AccessibilitySettingsForSetupWizardActivity activity =
Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
new Intent(Intent.ACTION_MAIN).setComponent(new ComponentName(
RuntimeEnvironment.application, CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW)).
putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
activity.tryLaunchFontSizeSettings();
final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
assertThat(launchIntent).isNotNull();
assertThat(launchIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
FontSizePreferenceFragmentForSetupWizard.class.getName());
assertThat(activity.isFinishing()).isTrue();
}
@Test
public void onCreate_noFontSizeComponent_shouldNotFinishCurrentActivity() {
AccessibilitySettingsForSetupWizardActivity activity =
Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
new Intent(Intent.ACTION_MAIN).
putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
activity.tryLaunchFontSizeSettings();
final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
assertThat(launchIntent).isNull();
assertThat(activity.isFinishing()).isFalse();
}
}