Merge "Ensure Display Settings Overrides Do Not Impact TestDisplayContent" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
19d042f7b9
@@ -1974,6 +1974,81 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertEquals(new Rect(500, 0, 2000, 700), rotateBounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TestDisplayContent using the constructor that takes in display width and height as
|
||||
* parameters and validates that the newly-created TestDisplayContent's DisplayInfo and
|
||||
* WindowConfiguration match the parameters passed into the constructor. Additionally, this test
|
||||
* checks that device-specific overrides are not applied.
|
||||
*/
|
||||
@Test
|
||||
public void testCreateTestDisplayContentFromDimensions() {
|
||||
final int displayWidth = 1000;
|
||||
final int displayHeight = 2000;
|
||||
final int windowingMode = WINDOWING_MODE_FULLSCREEN;
|
||||
final boolean ignoreOrientationRequests = false;
|
||||
final float fixedOrientationLetterboxRatio = 0;
|
||||
final DisplayContent testDisplayContent = new TestDisplayContent.Builder(mAtm, displayWidth,
|
||||
displayHeight).build();
|
||||
|
||||
// test display info
|
||||
final DisplayInfo di = testDisplayContent.getDisplayInfo();
|
||||
assertEquals(displayWidth, di.logicalWidth);
|
||||
assertEquals(displayHeight, di.logicalHeight);
|
||||
assertEquals(TestDisplayContent.DEFAULT_LOGICAL_DISPLAY_DENSITY, di.logicalDensityDpi);
|
||||
|
||||
// test configuration
|
||||
final WindowConfiguration windowConfig = testDisplayContent.getConfiguration()
|
||||
.windowConfiguration;
|
||||
assertEquals(displayWidth, windowConfig.getBounds().width());
|
||||
assertEquals(displayHeight, windowConfig.getBounds().height());
|
||||
assertEquals(windowingMode, windowConfig.getWindowingMode());
|
||||
|
||||
// test misc display overrides
|
||||
assertEquals(ignoreOrientationRequests, testDisplayContent.mIgnoreOrientationRequest);
|
||||
assertEquals(fixedOrientationLetterboxRatio, mWm.getFixedOrientationLetterboxAspectRatio(),
|
||||
0 /* delta */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TestDisplayContent using the constructor that takes in a DisplayInfo as a parameter
|
||||
* and validates that the newly-created TestDisplayContent's DisplayInfo and WindowConfiguration
|
||||
* match the width, height, and density values set in the DisplayInfo passed as a parameter.
|
||||
* Additionally, this test checks that device-specific overrides are not applied.
|
||||
*/
|
||||
@Test
|
||||
public void testCreateTestDisplayContentFromDisplayInfo() {
|
||||
final int displayWidth = 1000;
|
||||
final int displayHeight = 2000;
|
||||
final int windowingMode = WINDOWING_MODE_FULLSCREEN;
|
||||
final boolean ignoreOrientationRequests = false;
|
||||
final float fixedOrientationLetterboxRatio = 0;
|
||||
final DisplayInfo testDisplayInfo = new DisplayInfo();
|
||||
mContext.getDisplay().getDisplayInfo(testDisplayInfo);
|
||||
testDisplayInfo.logicalWidth = displayWidth;
|
||||
testDisplayInfo.logicalHeight = displayHeight;
|
||||
testDisplayInfo.logicalDensityDpi = TestDisplayContent.DEFAULT_LOGICAL_DISPLAY_DENSITY;
|
||||
final DisplayContent testDisplayContent = new TestDisplayContent.Builder(mAtm,
|
||||
testDisplayInfo).build();
|
||||
|
||||
// test display info
|
||||
final DisplayInfo di = testDisplayContent.getDisplayInfo();
|
||||
assertEquals(displayWidth, di.logicalWidth);
|
||||
assertEquals(displayHeight, di.logicalHeight);
|
||||
assertEquals(TestDisplayContent.DEFAULT_LOGICAL_DISPLAY_DENSITY, di.logicalDensityDpi);
|
||||
|
||||
// test configuration
|
||||
final WindowConfiguration windowConfig = testDisplayContent.getConfiguration()
|
||||
.windowConfiguration;
|
||||
assertEquals(displayWidth, windowConfig.getBounds().width());
|
||||
assertEquals(displayHeight, windowConfig.getBounds().height());
|
||||
assertEquals(windowingMode, windowConfig.getWindowingMode());
|
||||
|
||||
// test misc display overrides
|
||||
assertEquals(ignoreOrientationRequests, testDisplayContent.mIgnoreOrientationRequest);
|
||||
assertEquals(fixedOrientationLetterboxRatio, mWm.getFixedOrientationLetterboxAspectRatio(),
|
||||
0 /* delta */);
|
||||
}
|
||||
|
||||
private boolean isOptionsPanelAtRight(int displayId) {
|
||||
return (mWm.getPreferredOptionsPanelGravity(displayId) & Gravity.RIGHT) == Gravity.RIGHT;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DisplayWindowSettingsProviderTests extends WindowTestsBase {
|
||||
|
||||
SettingsEntry expectedSettings = new SettingsEntry();
|
||||
expectedSettings.mWindowingMode = WINDOWING_MODE_PINNED;
|
||||
readAndAssertExpectedSettings(mPrimaryDisplay, expectedSettings);
|
||||
readAndAssertExpectedSettings(mSecondaryDisplay, expectedSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,17 +176,17 @@ public class DisplayWindowSettingsProviderTests extends WindowTestsBase {
|
||||
// Expected settings should be empty because the default is to read from the primary vendor
|
||||
// settings location.
|
||||
SettingsEntry expectedSettings = new SettingsEntry();
|
||||
assertEquals(expectedSettings, provider.getSettings(mPrimaryDisplay.getDisplayInfo()));
|
||||
assertEquals(expectedSettings, provider.getSettings(mSecondaryDisplay.getDisplayInfo()));
|
||||
|
||||
// Now switch to secondary vendor settings and assert proper settings.
|
||||
provider.setBaseSettingsStorage(mSecondaryVendorSettingsStorage);
|
||||
expectedSettings.mWindowingMode = WINDOWING_MODE_FULLSCREEN;
|
||||
assertEquals(expectedSettings, provider.getSettings(mPrimaryDisplay.getDisplayInfo()));
|
||||
assertEquals(expectedSettings, provider.getSettings(mSecondaryDisplay.getDisplayInfo()));
|
||||
|
||||
// Switch back to primary and assert settings are empty again.
|
||||
provider.setBaseSettingsStorage(mDefaultVendorSettingsStorage);
|
||||
expectedSettings.mWindowingMode = WINDOWING_MODE_UNDEFINED;
|
||||
assertEquals(expectedSettings, provider.getSettings(mPrimaryDisplay.getDisplayInfo()));
|
||||
assertEquals(expectedSettings, provider.getSettings(mSecondaryDisplay.getDisplayInfo()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -204,7 +204,7 @@ public class DisplayWindowSettingsProviderTests extends WindowTestsBase {
|
||||
// take precedence over the vendor provided settings.
|
||||
SettingsEntry expectedSettings = new SettingsEntry();
|
||||
expectedSettings.mWindowingMode = WINDOWING_MODE_PINNED;
|
||||
assertEquals(expectedSettings, provider.getSettings(mPrimaryDisplay.getDisplayInfo()));
|
||||
assertEquals(expectedSettings, provider.getSettings(mSecondaryDisplay.getDisplayInfo()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -37,6 +37,8 @@ import android.view.DisplayInfo;
|
||||
|
||||
class TestDisplayContent extends DisplayContent {
|
||||
|
||||
public static final int DEFAULT_LOGICAL_DISPLAY_DENSITY = 300;
|
||||
|
||||
/** Please use the {@link Builder} to create, visible for use in test builder overrides only. */
|
||||
TestDisplayContent(RootWindowContainer rootWindowContainer, Display display) {
|
||||
super(display, rootWindowContainer);
|
||||
@@ -82,12 +84,21 @@ class TestDisplayContent extends DisplayContent {
|
||||
mService.mContext.getDisplay().getDisplayInfo(mInfo);
|
||||
mInfo.logicalWidth = width;
|
||||
mInfo.logicalHeight = height;
|
||||
mInfo.logicalDensityDpi = 300;
|
||||
mInfo.logicalDensityDpi = DEFAULT_LOGICAL_DISPLAY_DENSITY;
|
||||
mInfo.displayCutout = null;
|
||||
// Set unique ID so physical display overrides are not inheritted from
|
||||
// DisplayWindowSettings.
|
||||
mInfo.uniqueId = generateUniqueId();
|
||||
}
|
||||
Builder(ActivityTaskManagerService service, DisplayInfo info) {
|
||||
mService = service;
|
||||
mInfo = info;
|
||||
// Set unique ID so physical display overrides are not inheritted from
|
||||
// DisplayWindowSettings.
|
||||
mInfo.uniqueId = generateUniqueId();
|
||||
}
|
||||
private String generateUniqueId() {
|
||||
return "TEST_DISPLAY_CONTENT_" + System.currentTimeMillis();
|
||||
}
|
||||
Builder setSystemDecorations(boolean yes) {
|
||||
mSystemDecorations = yes;
|
||||
|
||||
Reference in New Issue
Block a user