OSDN Git Service

DO NOT MERGE: ConnectivityServiceTest: fix testAvoidBadWifiSettings
authorHugo Benichi <hugobenichi@google.com>
Tue, 15 Nov 2016 04:42:34 +0000 (13:42 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Fri, 9 Dec 2016 04:59:19 +0000 (13:59 +0900)
commit53d83d51424a496978d2ff2d86845a2284515712
tree94963686c3f8f79cb065b7f30871275539d63f0c
parentcbf8ff83a8b342e6ebeaa83794dace3c6d0b1488
DO NOT MERGE: ConnectivityServiceTest: fix testAvoidBadWifiSettings

This patch introduces an assertEventuallyThat helper function in
ConnectivityServiceTest which given a boolean function retries until the
function returns true or until a maximum retry time is reached.

This function is used to fix flakyness of testAvoidBadWifiSetting where
the Message posted by reevaluate() could reach the Handler's
MessageQueue after waitForIdle takes effect, resulting in the test to
fail.

Instead of fixing the flakyness by introdcing hard sleep times,
assertEventuallyThat is used to reduce the overall test time.

With this change the test has been observed to pass with 100% success
rate over 50000 invocations.

Test: $ runtest frameworks-net
Bug: 32561414

(cherry picked from commit 99c8294ef0c7a720364abb5884063e0a9d1bb5fe)

Change-Id: If41a24989d5f65aeb439f68741f511b5eb53b18d
tests/net/java/com/android/server/ConnectivityServiceTest.java