Loading res/values/bools.xml +3 −0 Original line number Diff line number Diff line Loading @@ -54,4 +54,7 @@ <!-- Whether wallpaper attribution should be shown or not. --> <bool name="config_show_wallpaper_attribution">true</bool> <!-- Whether default_home should be shown or not. --> <bool name="config_show_default_home">true</bool> </resources> src/com/android/settings/applications/defaultapps/DefaultHomePreferenceController.java +2 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import com.android.settings.R; import com.android.settingslib.wrapper.PackageManagerWrapper; import java.util.ArrayList; Loading Loading @@ -53,7 +54,7 @@ public class DefaultHomePreferenceController extends DefaultAppPreferenceControl @Override public boolean isAvailable() { return true; return mContext.getResources().getBoolean(R.bool.config_show_default_home); } @Override Loading tests/robotests/res/values-mcc999/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,5 @@ <bool name="config_display_recent_apps">false</bool> <bool name="config_location_mode_available">false</bool> <bool name="config_show_wallpaper_attribution">false</bool> <bool name="config_show_default_home">false</bool> </resources> tests/robotests/src/com/android/settings/applications/DefaultAppSettingsTest.java +5 −6 Original line number Diff line number Diff line Loading @@ -147,20 +147,19 @@ public class DefaultAppSettingsTest { @Test public void testNonIndexableKeys_existInXmlLayout() { final Context context = spy(RuntimeEnvironment.application); final Context mockContext = mock(Context.class); when(mockContext.getApplicationContext()).thenReturn(mockContext); when(context.getApplicationContext()).thenReturn(context); final UserManager userManager = mock(UserManager.class, RETURNS_DEEP_STUBS); when(mockContext.getSystemService(Context.USER_SERVICE)) when(context.getSystemService(Context.USER_SERVICE)) .thenReturn(userManager); when(userManager.getUserInfo(anyInt()).isRestricted()).thenReturn(true); when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)) when(context.getSystemService(Context.TELEPHONY_SERVICE)) .thenReturn(mock(TelephonyManager.class)); when(mockContext.getPackageManager()) when(context.getPackageManager()) .thenReturn(mock(PackageManager.class)); final List<String> niks = DefaultAppSettings.SEARCH_INDEX_DATA_PROVIDER .getNonIndexableKeys(mockContext); .getNonIndexableKeys(context); final int xmlId = (new DefaultAppSettings()).getPreferenceScreenResId(); Loading tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java +10 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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)); Loading @@ -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(); Loading Loading
res/values/bools.xml +3 −0 Original line number Diff line number Diff line Loading @@ -54,4 +54,7 @@ <!-- Whether wallpaper attribution should be shown or not. --> <bool name="config_show_wallpaper_attribution">true</bool> <!-- Whether default_home should be shown or not. --> <bool name="config_show_default_home">true</bool> </resources>
src/com/android/settings/applications/defaultapps/DefaultHomePreferenceController.java +2 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import com.android.settings.R; import com.android.settingslib.wrapper.PackageManagerWrapper; import java.util.ArrayList; Loading Loading @@ -53,7 +54,7 @@ public class DefaultHomePreferenceController extends DefaultAppPreferenceControl @Override public boolean isAvailable() { return true; return mContext.getResources().getBoolean(R.bool.config_show_default_home); } @Override Loading
tests/robotests/res/values-mcc999/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,5 @@ <bool name="config_display_recent_apps">false</bool> <bool name="config_location_mode_available">false</bool> <bool name="config_show_wallpaper_attribution">false</bool> <bool name="config_show_default_home">false</bool> </resources>
tests/robotests/src/com/android/settings/applications/DefaultAppSettingsTest.java +5 −6 Original line number Diff line number Diff line Loading @@ -147,20 +147,19 @@ public class DefaultAppSettingsTest { @Test public void testNonIndexableKeys_existInXmlLayout() { final Context context = spy(RuntimeEnvironment.application); final Context mockContext = mock(Context.class); when(mockContext.getApplicationContext()).thenReturn(mockContext); when(context.getApplicationContext()).thenReturn(context); final UserManager userManager = mock(UserManager.class, RETURNS_DEEP_STUBS); when(mockContext.getSystemService(Context.USER_SERVICE)) when(context.getSystemService(Context.USER_SERVICE)) .thenReturn(userManager); when(userManager.getUserInfo(anyInt()).isRestricted()).thenReturn(true); when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)) when(context.getSystemService(Context.TELEPHONY_SERVICE)) .thenReturn(mock(TelephonyManager.class)); when(mockContext.getPackageManager()) when(context.getPackageManager()) .thenReturn(mock(PackageManager.class)); final List<String> niks = DefaultAppSettings.SEARCH_INDEX_DATA_PROVIDER .getNonIndexableKeys(mockContext); .getNonIndexableKeys(context); final int xmlId = (new DefaultAppSettings()).getPreferenceScreenResId(); Loading
tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java +10 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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)); Loading @@ -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(); Loading