OSDN Git Service

Fix a race condition in DeviceIdleControllerTest.
authorRobin Lee <rgl@google.com>
Mon, 17 Dec 2018 16:43:57 +0000 (17:43 +0100)
committerRobin Lee <rgl@google.com>
Mon, 17 Dec 2018 19:33:02 +0000 (19:33 +0000)
commit54d44962bef76d567ad597a26eff0f0de7e4de6b
tree5c1a5f9fa9f923381d4e46d9a4c424bd9c7d2678
parentaf7deaba65fd18a8366356c3048bae2496c3563e
Fix a race condition in DeviceIdleControllerTest.

I noticed that the real ACTION_BATTERY_CHANGED races against the mocked
calls to update power state and cycle through idle states. This actually
works on a high-end phone or an emulator because the sticky broadcast
goes through before the test finishes setting up.

But on a slower device we sometimes beat the broadcast queue and wind up
getting our state reset halfway through the test. Flaky tests are bad so
let's not listen to broadcasts at all in the test.

May address issue 118639768 [DeviceIdleControllerTest is flaky].

Bug: 110756616
Bug: 118639768
Test: atest com.android.server.DeviceIdleControllerTest
Change-Id: Ie03ed10f2781ccaba4f39f4f34673a3e073e9f7f
services/tests/mockingservicestests/src/com/android/server/DeviceIdleControllerTest.java