Add ability to show/hide default_home preference.

This adds a new boolean flag, config_show_default_home, which when set
to false will hide the default_home preference item.

Bug: 62378256
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=DefaultHomePreferenceControllerTest

Change-Id: Ibbf17ebb76b61fc8b2eac84016e3d874ca15a513
This commit is contained in:
Ben Lin
2017-12-18 17:55:40 -08:00
parent 86097b0e19
commit b60d2cbb5b
5 changed files with 21 additions and 10 deletions

View File

@@ -45,6 +45,7 @@ import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
import java.util.Arrays;
@@ -54,18 +55,18 @@ import java.util.Arrays;
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DefaultHomePreferenceControllerTest {
@Mock
private Context mContext;
@Mock
private UserManager mUserManager;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PackageManagerWrapper mPackageManager;
private Context mContext;
private DefaultHomePreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mController = spy(new DefaultHomePreferenceController(mContext));
@@ -73,10 +74,16 @@ public class DefaultHomePreferenceControllerTest {
}
@Test
public void isAlwaysAvailable() {
public void testDefaultHome_byDefault_shouldBeShown() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
@Config(qualifiers = "mcc999")
public void testDefaultHome_ifDisabled_shouldNotBeShown() {
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void getDefaultApp_shouldGetDefaultBrowserPackage() {
assertThat(mController.getDefaultAppInfo()).isNotNull();