Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39c10adf authored by Alex Li's avatar Alex Li Committed by Android (Google) Code Review
Browse files

Merge "[Settings] Adds an intent extra when setup wizard start the WallpaperSuggestionActivity"

parents 6df1b4b5 c310eb94
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -26,8 +26,10 @@ import androidx.annotation.VisibleForTesting;
import com.android.settings.display.WallpaperPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.search.SearchIndexableRaw;

import com.google.android.setupcompat.util.WizardManagerHelper;

import java.util.ArrayList;
import java.util.List;
@@ -37,11 +39,16 @@ public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase imp

    private static final String WALLPAPER_FLAVOR_EXTRA = "com.android.launcher3.WALLPAPER_FLAVOR";
    private static final String WALLPAPER_FOCUS = "focus_wallpaper";
    private static final String WALLPAPER_ONLY = "wallpaper_only";

    @Override
    protected void addExtras(Intent intent) {
        if (WizardManagerHelper.isAnySetupWizard(intent)) {
            intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_ONLY);
        } else {
            intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_FOCUS);
        }
    }

    @VisibleForTesting
    public static boolean isSuggestionComplete(Context context) {
+37 −0
Original line number Diff line number Diff line
@@ -22,15 +22,20 @@ import static org.mockito.Mockito.when;

import android.app.Application;
import android.app.WallpaperManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;

import com.google.android.setupcompat.util.WizardManagerHelper;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
@@ -48,6 +53,10 @@ public class WallpaperSuggestionActivityTest {
    @Mock
    private Resources mResources;

    private static final String PACKAGE_WALLPAPER_ACTIVITY =
            "com.android.settings.wallpaper.WallpaperSuggestionActivity";
    private static final String WALLPAPER_FLAVOR = "com.android.launcher3.WALLPAPER_FLAVOR";

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
@@ -90,6 +99,34 @@ public class WallpaperSuggestionActivityTest {
                .isTrue();
    }

    @Test
    public void addExtras_intentFromSetupWizard_extrasHasWallpaperOnly() {
        WallpaperSuggestionActivity activity =
                Robolectric.buildActivity(WallpaperSuggestionActivity.class, new Intent(
                        Intent.ACTION_MAIN).setComponent(
                        new ComponentName(RuntimeEnvironment.application,
                                PACKAGE_WALLPAPER_ACTIVITY)).putExtra(
                        WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).putExtra(
                        WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).setup().get();
        Intent intent = Shadows.shadowOf(activity).getNextStartedActivity();

        assertThat(intent).isNotNull();
        assertThat(intent.getStringExtra(WALLPAPER_FLAVOR)).isEqualTo("wallpaper_only");
    }

    @Test
    public void addExtras_intentNotFromSetupWizard_extrasHasFocusWallpaper() {
        WallpaperSuggestionActivity activity = Robolectric.buildActivity(
                WallpaperSuggestionActivity.class, new Intent(Intent.ACTION_MAIN).setComponent(
                        new ComponentName(RuntimeEnvironment.application,
                                PACKAGE_WALLPAPER_ACTIVITY))).setup().get();
        Intent intent = Shadows.shadowOf(activity).getNextStartedActivity();

        assertThat(intent).isNotNull();
        assertThat(intent.getStringExtra(WALLPAPER_FLAVOR)).isEqualTo("focus_wallpaper");
    }


    @Implements(WallpaperManager.class)
    public static class ShadowWallpaperManager extends
        org.robolectric.shadows.ShadowWallpaperManager {