From 439336a36cccf32b6bb3bc8d855395a29b9fdfd3 Mon Sep 17 00:00:00 2001 From: Marin Shalamanov Date: Tue, 2 Mar 2021 12:28:51 +0100 Subject: [PATCH] Fix flaky test in LocalDisplayAdapter This fixes the flaky test testDisplayChange_withStaleDesiredDisplayModeSpecs. Setting desired display mode specs is async operation so we have to wait for the handler to complete before proceeding. Bug: 181455762 Bug: 181409641 Bug: 181408874 Test: run `atest LocalDisplayAdapterTest` 20 times with and without this change. There were 3 failures w/o this change and 0 with. Change-Id: I667e7cf96765ba58868032825d246ea034a80ee0 --- .../src/com/android/server/display/LocalDisplayAdapterTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java b/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java index 18184b0a82afc..f1d8e6c167d7a 100644 --- a/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java @@ -592,6 +592,7 @@ public class LocalDisplayAdapterTest { new DisplayModeDirector.RefreshRateRange(60f, 60f), new DisplayModeDirector.RefreshRateRange(60f, 60f) )); + waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); verify(mSurfaceControlProxy).setDesiredDisplayModeSpecs(display.token, new SurfaceControl.DesiredDisplayModeSpecs( /* baseModeId */ 0,