Merge "Fix Settings test that uses OverlayInfo"

This commit is contained in:
Ryan Mitchell
2019-03-22 21:39:41 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 11 deletions

View File

@@ -221,6 +221,7 @@ public class OverlayCategoryPreferenceControllerTest {
return new OverlayInfo(pkg /* packageName */, return new OverlayInfo(pkg /* packageName */,
"android" /* targetPackageName */, "android" /* targetPackageName */,
null /* targetOverlayableName */,
TEST_CATEGORY/* category */, TEST_CATEGORY/* category */,
pkg + ".baseCodePath" /* baseCodePath */, pkg + ".baseCodePath" /* baseCodePath */,
state /* state */, state /* state */,

View File

@@ -84,7 +84,7 @@ public class ThemePreferenceControllerTest {
when(mPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn( when(mPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(
new PackageInfo()); new PackageInfo());
when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt())) when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt()))
.thenReturn(Arrays.asList(new OverlayInfo("", "", "", "", 0, 0, 0, false))); .thenReturn(Arrays.asList(new OverlayInfo("", "", "", "", "", 0, 0, 0, false)));
assertThat(mController.isAvailable()).isFalse(); assertThat(mController.isAvailable()).isFalse();
} }
@@ -94,8 +94,9 @@ public class ThemePreferenceControllerTest {
new PackageInfo()); new PackageInfo());
when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt())) when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt()))
.thenReturn(Arrays.asList( .thenReturn(Arrays.asList(
new OverlayInfo("", "", OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true), new OverlayInfo("", "", "", OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true),
new OverlayInfo("", "", OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true))); new OverlayInfo("", "", "", OverlayInfo.CATEGORY_THEME, "", 0, 0, 0,
true)));
assertThat(mController.isAvailable()).isTrue(); assertThat(mController.isAvailable()).isTrue();
} }
@@ -140,9 +141,9 @@ public class ThemePreferenceControllerTest {
@Test @Test
public void getCurrentTheme_withEnabledState() throws Exception { public void getCurrentTheme_withEnabledState() throws Exception {
OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", "",
OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true);
OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", "",
OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true);
when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt())).thenReturn( when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt())).thenReturn(
Arrays.asList(info1, info2)); Arrays.asList(info1, info2));
@@ -154,9 +155,9 @@ public class ThemePreferenceControllerTest {
@Test @Test
public void testGetCurrentTheme_withoutEnabledState() throws Exception { public void testGetCurrentTheme_withoutEnabledState() throws Exception {
OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", "",
OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_DISABLED, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_DISABLED, 0, 0, true);
OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", "",
OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true);
when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt())).thenReturn( when(mOverlayManager.getOverlayInfosForTarget(any(), anyInt())).thenReturn(
Arrays.asList(info1, info2)); Arrays.asList(info1, info2));

View File

@@ -69,9 +69,9 @@ public class ThemePreferenceControllerTest {
@Test @Test
public void testUpdateState() throws Exception { public void testUpdateState() throws Exception {
OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", "",
OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true);
OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", "",
OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true);
when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> { when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> {
ApplicationInfo info = mock(ApplicationInfo.class); ApplicationInfo info = mock(ApplicationInfo.class);
@@ -105,9 +105,9 @@ public class ThemePreferenceControllerTest {
@Test @Test
public void testUpdateState_withStaticOverlay() throws Exception { public void testUpdateState_withStaticOverlay() throws Exception {
OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", "",
OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true);
OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", "",
OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true); OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true);
when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> { when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> {
ApplicationInfo info = mock(ApplicationInfo.class); ApplicationInfo info = mock(ApplicationInfo.class);