Add config to disable app tray preview in display size.

Also move some files

Change-Id: I4636fcd81425991acadede0b703e09513c82543c
Merged-In: I4636fcd81425991acadede0b703e09513c82543c
Fixes: 113374067
Test: robotests
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 29de06b..9e039c9 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -174,6 +174,9 @@
     <!-- Whether wifi_mac_address should be shown or not. -->
     <bool name="config_show_wifi_mac_address">true</bool>
 
-    <!-- Whether to disable "Uninstall Updates" menu item for System apps or not.. -->
+    <!-- Whether to disable "Uninstall Updates" menu item for System apps or not. -->
     <bool name="config_disable_uninstall_update">false</bool>
+
+    <!-- Whether or not extra preview panels should be used for screen zoom setting. -->
+    <bool name="config_enable_extra_screen_zoom_preview">true</bool>
 </resources>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 060868e..c192faa 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -44,7 +44,7 @@
             android:title="@string/display_category_title">
 
         <Preference
-            android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+            android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
             android:key="font_size_preference_screen"
             android:title="@string/title_font_size" />
 
diff --git a/res/xml/accessibility_settings_for_setup_wizard.xml b/res/xml/accessibility_settings_for_setup_wizard.xml
index c1141ab..738bb8e 100644
--- a/res/xml/accessibility_settings_for_setup_wizard.xml
+++ b/res/xml/accessibility_settings_for_setup_wizard.xml
@@ -33,7 +33,7 @@
 
     <Preference
         android:fragment=
-                "com.android.settings.accessibility.FontSizePreferenceFragmentForSetupWizard"
+                "com.android.settings.display.FontSizePreferenceFragmentForSetupWizard"
         android:key="font_size_preference"
         android:title="@string/title_font_size"
         android:summary="@string/short_summary_font_size" />
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index c75b90c..9e1ee4c 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -80,9 +80,8 @@
     <Preference
         android:key="font_size"
         android:title="@string/title_font_size"
-        android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
-        settings:controller="com.android.settings.display.FontSizePreferenceController"
-        settings:keywords="@string/keywords_display_font_size" />
+        android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
+        settings:controller="com.android.settings.display.FontSizePreferenceController" />
 
     <com.android.settings.display.ScreenZoomPreference
         android:key="display_settings_screen_zoom"
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 88e709a..528f52e 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -55,6 +55,7 @@
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.Utils;
+import com.android.settings.display.ToggleFontSizePreferenceFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settingslib.RestrictedLockUtils;
diff --git a/src/com/android/settings/display/FontSizePreferenceController.java b/src/com/android/settings/display/FontSizePreferenceController.java
index 3d6b6b4..28c7922 100644
--- a/src/com/android/settings/display/FontSizePreferenceController.java
+++ b/src/com/android/settings/display/FontSizePreferenceController.java
@@ -18,7 +18,6 @@
 import android.provider.Settings;
 
 import com.android.settings.R;
-import com.android.settings.accessibility.ToggleFontSizePreferenceFragment;
 import com.android.settings.core.BasePreferenceController;
 
 public class FontSizePreferenceController extends BasePreferenceController {
diff --git a/src/com/android/settings/accessibility/FontSizePreferenceFragmentForSetupWizard.java b/src/com/android/settings/display/FontSizePreferenceFragmentForSetupWizard.java
similarity index 92%
rename from src/com/android/settings/accessibility/FontSizePreferenceFragmentForSetupWizard.java
rename to src/com/android/settings/display/FontSizePreferenceFragmentForSetupWizard.java
index 8dfb2b4..703ec9c 100644
--- a/src/com/android/settings/accessibility/FontSizePreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/display/FontSizePreferenceFragmentForSetupWizard.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.accessibility;
+package com.android.settings.display;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 
diff --git a/src/com/android/settings/PreviewPagerAdapter.java b/src/com/android/settings/display/PreviewPagerAdapter.java
similarity index 82%
rename from src/com/android/settings/PreviewPagerAdapter.java
rename to src/com/android/settings/display/PreviewPagerAdapter.java
index 8d83cb4..4d5b47a 100644
--- a/src/com/android/settings/PreviewPagerAdapter.java
+++ b/src/com/android/settings/display/PreviewPagerAdapter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings;
+package com.android.settings.display;
 
 import android.animation.Animator;
 import android.animation.Animator.AnimatorListener;
@@ -32,6 +32,8 @@
 
 import androidx.viewpager.widget.PagerAdapter;
 
+import com.android.settings.support.actionbar.HelpResourceProvider;
+
 /**
  * A PagerAdapter used by PreviewSeekBarPreferenceFragment that for showing multiple preview screen
  * regarding a single setting and allowing the user to swipe across them.
@@ -76,16 +78,12 @@
                 final Context configContext = context.createConfigurationContext(configurations[j]);
                 configContext.getTheme().setTo(context.getTheme());
 
-                final LayoutInflater configInflater = LayoutInflater.from(configContext);
                 final ViewStub sampleViewStub = new ViewStub(configContext);
                 sampleViewStub.setLayoutResource(previewSampleResIds[i]);
                 final int fi = i, fj = j;
-                sampleViewStub.setOnInflateListener(new OnInflateListener() {
-                    @Override
-                    public void onInflate(ViewStub stub, View inflated) {
-                        inflated.setVisibility(stub.getVisibility());
-                        mViewStubInflated[fi][fj] = true;
-                    }
+                sampleViewStub.setOnInflateListener((stub, inflated) -> {
+                    inflated.setVisibility(stub.getVisibility());
+                    mViewStubInflated[fi][fj] = true;
                 });
 
                 mPreviewFrames[p].addView(sampleViewStub);
@@ -94,7 +92,7 @@
     }
 
     @Override
-    public void destroyItem (ViewGroup container, int position, Object object) {
+    public void destroyItem(ViewGroup container, int position, Object object) {
         container.removeView((View) object);
     }
 
@@ -164,29 +162,29 @@
             if (visibility == View.VISIBLE) {
                 // Fade in animation.
                 view.animate()
-                .alpha(alpha)
-                .setInterpolator(FADE_IN_INTERPOLATOR)
-                .setDuration(CROSS_FADE_DURATION_MS)
-                .setListener(new PreviewFrameAnimatorListener())
-                .withStartAction(new Runnable() {
-                    @Override
-                    public void run() {
-                        view.setVisibility(visibility);
-                    }
-                });
+                        .alpha(alpha)
+                        .setInterpolator(FADE_IN_INTERPOLATOR)
+                        .setDuration(CROSS_FADE_DURATION_MS)
+                        .setListener(new PreviewFrameAnimatorListener())
+                        .withStartAction(new Runnable() {
+                            @Override
+                            public void run() {
+                                view.setVisibility(visibility);
+                            }
+                        });
             } else {
                 // Fade out animation.
                 view.animate()
-                .alpha(alpha)
-                .setInterpolator(FADE_OUT_INTERPOLATOR)
-                .setDuration(CROSS_FADE_DURATION_MS)
-                .setListener(new PreviewFrameAnimatorListener())
-                .withEndAction(new Runnable() {
-                    @Override
-                    public void run() {
-                        view.setVisibility(visibility);
-                    }
-                });
+                        .alpha(alpha)
+                        .setInterpolator(FADE_OUT_INTERPOLATOR)
+                        .setDuration(CROSS_FADE_DURATION_MS)
+                        .setListener(new PreviewFrameAnimatorListener())
+                        .withEndAction(new Runnable() {
+                            @Override
+                            public void run() {
+                                view.setVisibility(visibility);
+                            }
+                        });
             }
         }
     }
diff --git a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java b/src/com/android/settings/display/PreviewSeekBarPreferenceFragment.java
similarity index 80%
rename from src/com/android/settings/PreviewSeekBarPreferenceFragment.java
rename to src/com/android/settings/display/PreviewSeekBarPreferenceFragment.java
index 6cbd619..3669118 100644
--- a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java
+++ b/src/com/android/settings/display/PreviewSeekBarPreferenceFragment.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,14 +14,13 @@
  * limitations under the License.
  */
 
-package com.android.settings;
+package com.android.settings.display;
 
 import android.content.Context;
 import android.content.res.Configuration;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityEvent;
 import android.widget.SeekBar;
@@ -31,6 +30,8 @@
 import androidx.viewpager.widget.ViewPager;
 import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
 
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.widget.DotsPageIndicator;
 import com.android.settings.widget.LabeledSeekBar;
 
@@ -48,12 +49,6 @@
     /** Index of the entry corresponding to current value of the settings. */
     protected int mCurrentIndex;
 
-    /** Resource id of the layout for this preference fragment. */
-    protected int mActivityLayoutResId;
-
-    /** Resource id of the layout that defines the contents inside preview screen. */
-    protected int[] mPreviewSampleResIds;
-
     private ViewPager mPreviewPager;
     private PreviewPagerAdapter mPreviewPagerAdapter;
     private DotsPageIndicator mPageIndicator;
@@ -82,12 +77,7 @@
         @Override
         public void onStopTrackingTouch(SeekBar seekBar) {
             if (mPreviewPagerAdapter.isAnimating()) {
-                mPreviewPagerAdapter.setAnimationEndAction(new Runnable() {
-                    @Override
-                    public void run() {
-                        commit();
-                    }
-                });
+                mPreviewPagerAdapter.setAnimationEndAction(() -> commit());
             } else {
                 commit();
             }
@@ -102,39 +92,33 @@
         final ViewGroup listContainer = (ViewGroup) root.findViewById(android.R.id.list_container);
         listContainer.removeAllViews();
 
-        final View content = inflater.inflate(mActivityLayoutResId, listContainer, false);
+        final View content = inflater.inflate(getActivityLayoutResId(), listContainer, false);
         listContainer.addView(content);
 
-        mLabel = (TextView) content.findViewById(R.id.current_label);
+        mLabel = content.findViewById(R.id.current_label);
 
         // The maximum SeekBar value always needs to be non-zero. If there's
         // only one available value, we'll handle this by disabling the
         // seek bar.
         final int max = Math.max(1, mEntries.length - 1);
 
-        mSeekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar);
+        mSeekBar = content.findViewById(R.id.seek_bar);
         mSeekBar.setLabels(mEntries);
         mSeekBar.setMax(max);
 
         mSmaller = content.findViewById(R.id.smaller);
-        mSmaller.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                final int progress = mSeekBar.getProgress();
-                if (progress > 0) {
-                    mSeekBar.setProgress(progress - 1, true);
-                }
+        mSmaller.setOnClickListener(v -> {
+            final int progress = mSeekBar.getProgress();
+            if (progress > 0) {
+                mSeekBar.setProgress(progress - 1, true);
             }
         });
 
         mLarger = content.findViewById(R.id.larger);
-        mLarger.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                final int progress = mSeekBar.getProgress();
-                if (progress < mSeekBar.getMax()) {
-                    mSeekBar.setProgress(progress + 1, true);
-                }
+        mLarger.setOnClickListener(v -> {
+            final int progress = mSeekBar.getProgress();
+            if (progress < mSeekBar.getMax()) {
+                mSeekBar.setProgress(progress + 1, true);
             }
         });
 
@@ -152,15 +136,16 @@
             configurations[i] = createConfig(origConfig, i);
         }
 
-        mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
+        final int[] previews = getPreviewSampleResIds();
+        mPreviewPager = content.findViewById(R.id.preview_pager);
         mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl,
-                mPreviewSampleResIds, configurations);
+                previews, configurations);
         mPreviewPager.setAdapter(mPreviewPagerAdapter);
-        mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0);
+        mPreviewPager.setCurrentItem(isLayoutRtl ? previews.length - 1 : 0);
         mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
 
-        mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
-        if (mPreviewSampleResIds.length > 1) {
+        mPageIndicator = content.findViewById(R.id.page_indicator);
+        if (previews.length > 1) {
             mPageIndicator.setViewPager(mPreviewPager);
             mPageIndicator.setVisibility(View.VISIBLE);
             mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
@@ -187,6 +172,12 @@
         mSeekBar.setOnSeekBarChangeListener(null);
     }
 
+    /** Resource id of the layout for this preference fragment. */
+    protected abstract int getActivityLayoutResId();
+
+    /** Resource id of the layout that defines the contents inside preview screen. */
+    protected abstract int[] getPreviewSampleResIds();
+
     /**
      * Creates new configuration based on the current position of the SeekBar.
      */
@@ -210,8 +201,8 @@
 
     private void setPagerIndicatorContentDescription(int position) {
         mPageIndicator.setContentDescription(
-                getPrefContext().getString(R.string.preview_page_indicator_content_description,
-                        position + 1, mPreviewSampleResIds.length));
+                getString(R.string.preview_page_indicator_content_description,
+                        position + 1, getPreviewSampleResIds().length));
     }
 
     private OnPageChangeListener mPreviewPageChangeListener = new OnPageChangeListener() {
diff --git a/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java b/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java
index 82cb58d..e02579f 100644
--- a/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java
@@ -18,8 +18,7 @@
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 
-public class ScreenZoomPreferenceFragmentForSetupWizard
-        extends ScreenZoomSettings {
+public class ScreenZoomPreferenceFragmentForSetupWizard extends ScreenZoomSettings {
 
     @Override
     public int getMetricsCategory() {
diff --git a/src/com/android/settings/display/ScreenZoomSettings.java b/src/com/android/settings/display/ScreenZoomSettings.java
index 6b5216e..5d7375d 100644
--- a/src/com/android/settings/display/ScreenZoomSettings.java
+++ b/src/com/android/settings/display/ScreenZoomSettings.java
@@ -24,7 +24,6 @@
 import android.view.Display;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.PreviewSeekBarPreferenceFragment;
 import com.android.settings.R;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
@@ -43,16 +42,25 @@
     private int[] mValues;
 
     @Override
+    protected int getActivityLayoutResId() {
+        return R.layout.screen_zoom_activity;
+    }
+
+    @Override
+    protected int[] getPreviewSampleResIds() {
+        return getContext().getResources().getBoolean(
+                R.bool.config_enable_extra_screen_zoom_preview)
+                ? new int[]{
+                        R.layout.screen_zoom_preview_1,
+                        R.layout.screen_zoom_preview_2,
+                        R.layout.screen_zoom_preview_settings}
+                : new int[]{R.layout.screen_zoom_preview_1};
+    }
+
+    @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mActivityLayoutResId = R.layout.screen_zoom_activity;
-
-        // This should be replaced once the final preview sample screen is in place.
-        mPreviewSampleResIds = new int[] {R.layout.screen_zoom_preview_1,
-                R.layout.screen_zoom_preview_2,
-                R.layout.screen_zoom_preview_settings};
-
         final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
 
         final int initialIndex = density.getCurrentIndex();
@@ -61,8 +69,8 @@
             // connect to the window manager service. Just use the current
             // density and don't let the user change anything.
             final int densityDpi = getResources().getDisplayMetrics().densityDpi;
-            mValues = new int[] {densityDpi};
-            mEntries = new String[] {getString(DisplayDensityUtils.SUMMARY_DEFAULT)};
+            mValues = new int[]{densityDpi};
+            mEntries = new String[]{getString(DisplayDensityUtils.SUMMARY_DEFAULT)};
             mInitialIndex = 0;
             mDefaultDensity = densityDpi;
         } else {
@@ -107,7 +115,7 @@
     }
 
     /** Index provider used to expose this fragment in search. */
-    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
                 public List<SearchIndexableRaw> getRawDataToIndex(Context context,
diff --git a/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java b/src/com/android/settings/display/ToggleFontSizePreferenceFragment.java
similarity index 89%
rename from src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
rename to src/com/android/settings/display/ToggleFontSizePreferenceFragment.java
index 45b9def..c87d29d 100644
--- a/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
+++ b/src/com/android/settings/display/ToggleFontSizePreferenceFragment.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.accessibility;
+package com.android.settings.display;
 
 import android.annotation.Nullable;
 import android.content.ContentResolver;
@@ -24,7 +24,6 @@
 import android.provider.Settings;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.PreviewSeekBarPreferenceFragment;
 import com.android.settings.R;
 
 /**
@@ -35,13 +34,20 @@
     private float[] mValues;
 
     @Override
+    protected int getActivityLayoutResId() {
+        return R.layout.font_size_activity;
+    }
+
+    @Override
+    protected int[] getPreviewSampleResIds() {
+        return new int[]{R.layout.font_size_preview};
+    }
+
+    @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mActivityLayoutResId = R.layout.font_size_activity;
-        mPreviewSampleResIds = new int[]{R.layout.font_size_preview};
-
-        Resources res = getContext().getResources();
+        final Resources res = getContext().getResources();
         final ContentResolver resolver = getContext().getContentResolver();
         // Mark the appropriate item in the preferences list.
         mEntries = res.getStringArray(R.array.entries_font_size);
diff --git a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
index be3507c..8e0df9d 100644
--- a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
+++ b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
@@ -1,2 +1,3 @@
+com.android.settings.display.FontSizePreferenceFragmentForSetupWizard
 com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
 com.android.settings.search.indexing.FakeSettingsFragment
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index cecc9c5..3706983 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -63,6 +63,12 @@
     <bool name="config_show_wifi_mac_address">false</bool>
     <bool name="config_disable_uninstall_update">true</bool>
 
+    <!-- Whether or not extra preview panels should be used for screen zoom setting. -->
+    <bool name="config_enable_extra_screen_zoom_preview">false</bool>
+
+    <!-- Whether or not extra preview panels should be used for screen zoom setting. -->
+    <bool name="config_enable_extra_screen_zoom_preview">false</bool>
+
     <!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
     <string-array name="config_settings_slices_accessibility_components" translatable="false">
         <item>fake_package/fake_service</item>
diff --git a/tests/robotests/src/com/android/settings/display/ScreenZoomSettingsTest.java b/tests/robotests/src/com/android/settings/display/ScreenZoomSettingsTest.java
new file mode 100644
index 0000000..0822076
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/ScreenZoomSettingsTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.display;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ScreenZoomSettingsTest {
+
+    private ScreenZoomSettings mSettings;
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mSettings = spy(new ScreenZoomSettings());
+        doReturn(mContext).when(mSettings).getContext();
+    }
+
+    @Test
+    public void getPreviewSampleResIds_default_return3Previews() {
+        assertThat(mSettings.getPreviewSampleResIds()).hasLength(3);
+    }
+
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void getPreviewSampleResIds_extraPreviewDisabled_return1Preview() {
+        assertThat(mSettings.getPreviewSampleResIds()).hasLength(1);
+    }
+}