Cutout emulation: string changes and ordering

Updates strings according to spec. Also ensures
that the emulation overlays are shown in the
order of their priority.

Bug: 112876936
Test: Open developer options, go to "display cutout", verify strings.
Change-Id: If2d05595d02a277896202ab2a6262c99508a3a17
This commit is contained in:
Adrian Roos
2018-08-21 18:26:29 +02:00
parent 85a5f96051
commit 1be35697ed
3 changed files with 28 additions and 11 deletions

View File

@@ -17,6 +17,8 @@
package com.android.settings.development;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.AdditionalMatchers.aryEq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -36,6 +38,7 @@ import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.AdditionalMatchers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -48,10 +51,10 @@ import androidx.preference.PreferenceScreen;
@RunWith(SettingsRobolectricTestRunner.class)
public class EmulateDisplayCutoutPreferenceControllerTest {
private static final OverlayInfo ONE_DISABLED = createFakeOverlay("emulation.one", false);
private static final OverlayInfo ONE_ENABLED = createFakeOverlay("emulation.one", true);
private static final OverlayInfo TWO_DISABLED = createFakeOverlay("emulation.two", false);
private static final OverlayInfo TWO_ENABLED = createFakeOverlay("emulation.two", true);
private static final OverlayInfo ONE_DISABLED = createFakeOverlay("emulation.one", false, 1);
private static final OverlayInfo ONE_ENABLED = createFakeOverlay("emulation.one", true, 1);
private static final OverlayInfo TWO_DISABLED = createFakeOverlay("emulation.two", false, 2);
private static final OverlayInfo TWO_ENABLED = createFakeOverlay("emulation.two", true, 2);
@Mock
private Context mContext;
@@ -134,6 +137,16 @@ public class EmulateDisplayCutoutPreferenceControllerTest {
verify(mPreference).setValueIndex(0);
}
@Test
public void ordered_by_priority() throws Exception {
mockCurrentOverlays(TWO_DISABLED, ONE_DISABLED);
mController.updateState(null);
verify(mPreference).setEntryValues(
aryEq(new String[]{"", ONE_DISABLED.packageName, TWO_DISABLED.packageName}));
}
@Test
public void onDeveloperOptionsSwitchDisabled() throws Exception {
mockCurrentOverlays(ONE_ENABLED, TWO_DISABLED);
@@ -152,16 +165,16 @@ public class EmulateDisplayCutoutPreferenceControllerTest {
mOverlayManager);
}
private static OverlayInfo createFakeOverlay(String pkg, boolean enabled) {
private static OverlayInfo createFakeOverlay(String pkg, boolean enabled, int priority) {
final int state = (enabled) ? OverlayInfo.STATE_ENABLED : OverlayInfo.STATE_DISABLED;
return new OverlayInfo(pkg /* packageName */,
pkg + ".target" /* targetPackageName */,
"android" /* targetPackageName */,
DisplayCutout.EMULATION_OVERLAY_CATEGORY /* category */,
pkg + ".baseCodePath" /* baseCodePath */,
state /* state */,
0 /* userId */,
0 /* priority */,
priority,
true /* isStatic */);
}
}