Set fit insets type for decor insets test

Otherwise because since the key of InsetsState#mSources is based
on hashcode (InsetsSource.createId), the order to iterate mSources
may be indeterministic for the same insets type.
Then WindowLayout#computeFrames may compute different results
according to the hashcode, that causes the test to be flaky.

By setting fit insets type to 0, the insets won't affect each other.

Fix: 284435531
Test: DisplayPolicyTests#testUpdateDisplayConfigurationByDecor

Change-Id: I30ea22c051f84264a03d0b698d50d83c62059869
This commit is contained in:
Riddle Hsu
2023-05-29 20:02:52 +08:00
parent 25aa2d3c87
commit 614ed9e0e9
2 changed files with 3 additions and 0 deletions

View File

@@ -362,10 +362,12 @@ public class DisplayPolicyTests extends WindowTestsBase {
new InsetsFrameProvider(bar2, 0, WindowInsets.Type.statusBars())
.setInsetsSize(Insets.of(0, STATUS_BAR_HEIGHT, 0, 0))
};
bar2.mAttrs.setFitInsetsTypes(0);
bar2.mAttrs.paramsForRotation = new WindowManager.LayoutParams[4];
final int doubleHeightFor90 = STATUS_BAR_HEIGHT * 2;
for (int i = ROTATION_0; i <= Surface.ROTATION_270; i++) {
final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.setFitInsetsTypes(0);
if (i == Surface.ROTATION_90) {
params.providedInsets = new InsetsFrameProvider[] {
new InsetsFrameProvider(bar2, 0, WindowInsets.Type.statusBars())

View File

@@ -485,6 +485,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
new InsetsFrameProvider(owner, 0, WindowInsets.Type.statusBars())
.setInsetsSize(Insets.of(0, STATUS_BAR_HEIGHT, 0, 0))
};
statusBar.mAttrs.setFitInsetsTypes(0);
dc.getDisplayPolicy().addWindowLw(statusBar, statusBar.mAttrs);
return statusBar;
}