From 6f6c0cd4b8f59a6d6bb67196177ee964f6704da3 Mon Sep 17 00:00:00 2001 From: Chris Wren Date: Wed, 8 Feb 2017 17:21:53 -0500 Subject: [PATCH] avoid race condition on very fast tests most of the use cases for this involve uiautomator tests, which are slow anyway. In this case it may be possible for the checkpoint to record the current time, and then the test event arrive before the clock ticks over to the next millisecond, which would cause them to be ignored. If this fixes the flakiness we should consider a more gneeral fix. Test: runtest --path frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java Bug: 35138327 Change-Id: Idc4aec50df1a75be710c5a69522af058f7e68ec1 --- .../com/android/systemui/statusbar/phone/StatusBarTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index 21c7fce445796..e8eee24b8dc05 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -79,6 +79,12 @@ public class StatusBarTest extends SysuiTestCase { mMetricsReader = new MetricsReader(); mMetricsReader.checkpoint(); // clear out old logs + try { + // pause so that no new events arrive in the rest of this millisecond. + Thread.sleep(2); + } catch (InterruptedException e) { + // pass + } } @Test