From 8e14ca0058d65174de1c48e6c074dd3fc1e02fe1 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Tue, 27 Nov 2018 13:06:44 -0800 Subject: [PATCH] Remove obsolete logic in SettingsActivity. mIsShowingDashboard is always false, it used to be true when we are displaying homepage, but now homepage is hosted in a entirely different activity. so all related logic can now be removed. Test: robotests Misc clean up: remove unused colors Test: rebuild, color-lint Change-Id: I1e1628c1e9606c2b7dc40ef3c21d4ed1391a8c03 --- AndroidManifest.xml | 7 - color-check-baseline.xml | 356 ++++-------------- res/layout/settings_main_dashboard.xml | 33 -- res/values/colors.xml | 20 - .../android/settings/SettingsActivity.java | 26 +- .../search/SearchFeatureProvider.java | 6 +- .../settings/SettingsActivityTest.java | 31 +- .../search/SearchFeatureProviderImplTest.java | 20 +- .../widget/RoundedHomepageIconTest.java | 4 +- 9 files changed, 103 insertions(+), 400 deletions(-) delete mode 100644 res/layout/settings_main_dashboard.xml diff --git a/AndroidManifest.xml b/AndroidManifest.xml index cc7f909680e..7689b11cb1c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -114,13 +114,6 @@ - - - - + errorLine1=" <color name="bluetooth_dialog_text_color">#8a000000</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - @@ -253,7 +237,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -269,7 +253,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -285,7 +269,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -301,23 +285,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - @@ -333,7 +301,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -349,7 +317,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -365,7 +333,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -381,7 +349,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -397,7 +365,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -413,7 +381,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -429,7 +397,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -445,7 +413,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -461,7 +429,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -477,7 +445,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -493,23 +461,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - @@ -525,103 +477,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - - - - - - - - - - - - - - - - - @@ -637,39 +493,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - @@ -685,7 +509,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -701,7 +525,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -717,7 +541,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -733,7 +557,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -749,7 +573,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -765,7 +589,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -781,7 +605,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -797,7 +621,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -813,7 +637,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -829,7 +653,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -845,7 +669,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -861,7 +685,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -877,7 +701,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -893,7 +717,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -909,7 +733,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -925,7 +749,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -941,7 +765,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -957,7 +781,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -973,7 +797,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -989,39 +813,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - @@ -1037,7 +829,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1053,7 +845,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1069,7 +861,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1085,7 +877,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1101,7 +893,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1117,7 +909,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1133,7 +925,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1149,7 +941,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1165,7 +957,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1181,7 +973,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1197,7 +989,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1213,7 +1005,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1229,7 +1021,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1245,7 +1037,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1261,7 +1053,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1277,7 +1069,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1293,7 +1085,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1309,7 +1101,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1325,7 +1117,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1341,7 +1133,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1357,7 +1149,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1373,7 +1165,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1389,7 +1181,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1405,7 +1197,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1421,7 +1213,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1437,7 +1229,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1453,7 +1245,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1469,7 +1261,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1485,7 +1277,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2669,7 +2461,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2701,7 +2493,7 @@ errorLine2=" ^"> @@ -2717,7 +2509,7 @@ errorLine2=" ^"> @@ -2733,7 +2525,7 @@ errorLine2=" ^"> @@ -2749,7 +2541,7 @@ errorLine2=" ^"> diff --git a/res/layout/settings_main_dashboard.xml b/res/layout/settings_main_dashboard.xml deleted file mode 100644 index 39940925e2b..00000000000 --- a/res/layout/settings_main_dashboard.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - diff --git a/res/values/colors.xml b/res/values/colors.xml index 6a6a2b3fe8f..d10cb5f4fa0 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -19,8 +19,6 @@ #F00 #00F - #FFCED7DB - #8a000000 #ff9a9a9a @@ -30,7 +28,6 @@ #20ffffff @android:color/holo_blue_light - #ffbdbdbd @color/lock_pattern_view_regular_color #ff84ffff @color/suw_color_accent_light @@ -52,25 +49,13 @@ #ff384248 #ffced7db - #ffe0e0e0 @*android:color/accent_device_default_light #60000000 - #33b5e5 - - #ff009587 - #ffF3B300 - #ffff9700 - #ffff5621 - - #ff384248 #ffabffec - #8a000000 - #4d000000 - #4285F4 #3367D6 @@ -78,7 +63,6 @@ #ffffff #ff80868B - #ffffffff #ff323232 #99323232 @@ -102,10 +86,6 @@ #8A000000 - - #f2f2f2 - #f8f8f8 - #2196F3 #72B70F diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index 07f59e2b4d6..222c18c77b9 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -38,7 +38,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; -import android.widget.Toolbar; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -169,8 +168,6 @@ public class SettingsActivity extends SettingsBaseActivity private Button mNextButton; - private boolean mIsShowingDashboard; - private ViewGroup mContent; // Categories @@ -241,9 +238,6 @@ public class SettingsActivity extends SettingsBaseActivity // Getting Intent properties can only be done after the super.onCreate(...) final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); - mIsShowingDashboard = TextUtils.equals( - SettingsActivity.class.getName(), intent.getComponent().getClassName()); - // This is a "Sub Settings" when: // - this is a real SubSettings // - or :settings:show_fragment_as_subsetting is passed to the Intent @@ -256,8 +250,7 @@ public class SettingsActivity extends SettingsBaseActivity setTheme(R.style.Theme_SubSettings); } - setContentView(mIsShowingDashboard ? - R.layout.settings_main_dashboard : R.layout.settings_main_prefs); + setContentView(R.layout.settings_main_prefs); mContent = findViewById(R.id.main_content); @@ -276,25 +269,16 @@ public class SettingsActivity extends SettingsBaseActivity setTitleFromBackStack(); } } else { - launchSettingFragment(initialFragmentName, isSubSettings, intent); + launchSettingFragment(initialFragmentName, intent); } final boolean deviceProvisioned = Utils.isDeviceProvisioned(this); - if (mIsShowingDashboard) { - findViewById(R.id.search_bar).setVisibility( - deviceProvisioned ? View.VISIBLE : View.INVISIBLE); - findViewById(R.id.action_bar).setVisibility(View.GONE); - final Toolbar toolbar = findViewById(R.id.search_action_bar); - setActionBar(toolbar); - FeatureFactory.getFactory(this).getSearchFeatureProvider() - .initSearchToolbar(this, toolbar); - } ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(deviceProvisioned); actionBar.setHomeButtonEnabled(deviceProvisioned); - actionBar.setDisplayShowTitleEnabled(!mIsShowingDashboard); + actionBar.setDisplayShowTitleEnabled(true); } mSwitchBar = findViewById(R.id.switch_bar); if (mSwitchBar != null) { @@ -372,8 +356,8 @@ public class SettingsActivity extends SettingsBaseActivity } @VisibleForTesting - void launchSettingFragment(String initialFragmentName, boolean isSubSettings, Intent intent) { - if (!mIsShowingDashboard && initialFragmentName != null) { + void launchSettingFragment(String initialFragmentName, Intent intent) { + if (initialFragmentName != null) { setTitleFromIntent(intent); Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java index 3c1c62b43c7..34f8629c6e0 100644 --- a/src/com/android/settings/search/SearchFeatureProvider.java +++ b/src/com/android/settings/search/SearchFeatureProvider.java @@ -68,8 +68,10 @@ public interface SearchFeatureProvider { if (activity == null || toolbar == null) { return; } - if (!Utils.isPackageEnabled(activity, getSettingsIntelligencePkgName(activity))) { - final ViewGroup parent = (ViewGroup)toolbar.getParent(); + + if (!Utils.isDeviceProvisioned(activity) || + !Utils.isPackageEnabled(activity, getSettingsIntelligencePkgName(activity))) { + final ViewGroup parent = (ViewGroup) toolbar.getParent(); if (parent != null) { parent.setVisibility(View.GONE); } diff --git a/tests/robotests/src/com/android/settings/SettingsActivityTest.java b/tests/robotests/src/com/android/settings/SettingsActivityTest.java index 2c98f70c2b4..aa414649e70 100644 --- a/tests/robotests/src/com/android/settings/SettingsActivityTest.java +++ b/tests/robotests/src/com/android/settings/SettingsActivityTest.java @@ -28,9 +28,6 @@ import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.content.Context; import android.content.Intent; -import android.os.Bundle; -import android.provider.Settings.Global; -import android.view.View; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -38,16 +35,13 @@ import androidx.fragment.app.FragmentTransaction; import com.android.settings.core.OnActivityResultListener; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settings.testutils.shadow.ShadowUtils; 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.RuntimeEnvironment; -import org.robolectric.annotation.Config; import java.util.ArrayList; import java.util.List; @@ -70,29 +64,6 @@ public class SettingsActivityTest { mActivity = spy(new SettingsActivity()); } - @Test - @Config(shadows = ShadowUtils.class) - public void onCreate_deviceNotProvisioned_shouldDisableSearch() { - Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 0); - final SettingsActivity activity = Robolectric.buildActivity(SettingsActivity.class) - .create(Bundle.EMPTY) - .get(); - - assertThat(activity.findViewById(R.id.search_bar).getVisibility()) - .isEqualTo(View.INVISIBLE); - } - - @Test - @Config(shadows = ShadowUtils.class) - public void onCreate_deviceProvisioned_shouldEnableSearch() { - Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 1); - final SettingsActivity activity = Robolectric.buildActivity(SettingsActivity.class) - .create(Bundle.EMPTY) - .get(); - - assertThat(activity.findViewById(R.id.search_bar).getVisibility()).isEqualTo(View.VISIBLE); - } - @Test public void launchSettingFragment_nullExtraShowFragment_shouldNotCrash() { when(mActivity.getSupportFragmentManager()).thenReturn(mFragmentManager); @@ -101,7 +72,7 @@ public class SettingsActivityTest { doReturn(RuntimeEnvironment.application.getClassLoader()).when(mActivity).getClassLoader(); - mActivity.launchSettingFragment(null, true, mock(Intent.class)); + mActivity.launchSettingFragment(null, mock(Intent.class)); } @Test diff --git a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java index b0e40255622..37fd88801d2 100644 --- a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java +++ b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java @@ -53,6 +53,8 @@ public class SearchFeatureProviderImplTest { mActivity = Robolectric.setupActivity(Activity.class); mProvider = new SearchFeatureProviderImpl(); mPackageManager = Shadows.shadowOf(mActivity.getPackageManager()); + Settings.Global.putInt(mActivity.getContentResolver(), + Settings.Global.DEVICE_PROVISIONED, 1); } @Test @@ -82,7 +84,7 @@ public class SearchFeatureProviderImplTest { @Test @Config(shadows = ShadowUtils.class) - public void initSearchToolbar_NotHaveResolvedInfo_shouldNotStartActivity() { + public void initSearchToolbar_noResolvedInfo_shouldNotStartActivity() { final Toolbar toolbar = new Toolbar(mActivity); // This ensures navigationView is created. toolbar.setNavigationContentDescription("test"); @@ -90,9 +92,21 @@ public class SearchFeatureProviderImplTest { toolbar.performClick(); - final Intent launchIntent = Shadows.shadowOf(mActivity).getNextStartedActivity(); + assertThat(Shadows.shadowOf(mActivity).getNextStartedActivity()).isNull(); + } - assertThat(launchIntent).isNull(); + @Test + public void initSearchToolbar_deviceNotProvisioned_shouldNotCreateSearchBar() { + final Toolbar toolbar = new Toolbar(mActivity); + // This ensures navigationView is created. + toolbar.setNavigationContentDescription("test"); + + Settings.Global.putInt(mActivity.getContentResolver(), + Settings.Global.DEVICE_PROVISIONED, 0); + + toolbar.performClick(); + + assertThat(Shadows.shadowOf(mActivity).getNextStartedActivity()).isNull(); } @Test(expected = IllegalArgumentException.class) diff --git a/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java index aaffa93ba0b..5bc8ddae4fb 100644 --- a/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java +++ b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java @@ -101,7 +101,7 @@ public class RoundedHomepageIconTest { public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() { final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE)); mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT, - R.color.memory_critical); + R.color.material_blue_500); doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings)) .when(tile).getIcon(mContext); @@ -110,7 +110,7 @@ public class RoundedHomepageIconTest { icon.setBackgroundColor(mContext, tile); assertThat(icon.mBackgroundColor) - .isEqualTo(mContext.getColor(R.color.memory_critical)); + .isEqualTo(mContext.getColor(R.color.material_blue_500)); } }