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
This commit is contained in:
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user