Merge "WifiManagerTest: Make traffic state change test more robust" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-19 19:03:59 +00:00
committed by Android (Google) Code Review

View File

@@ -1956,11 +1956,13 @@ public class WifiManagerTest extends AndroidTestCase {
private static class TestTrafficStateCallback implements WifiManager.TrafficStateCallback {
private final Object mLock;
private final int mWaitForState;
public boolean onStateChangedCalled = false;
public int state = -1;
TestTrafficStateCallback(Object lock) {
TestTrafficStateCallback(Object lock, int waitForState) {
mLock = lock;
mWaitForState = waitForState;
}
@Override
@@ -1968,7 +1970,9 @@ public class WifiManagerTest extends AndroidTestCase {
synchronized (mLock) {
onStateChangedCalled = true;
this.state = state;
mLock.notify();
if (mWaitForState == state) { // only notify if we got the expected state.
mLock.notify();
}
}
}
}
@@ -2002,7 +2006,8 @@ public class WifiManagerTest extends AndroidTestCase {
// skip the test if WiFi is not supported
return;
}
TestTrafficStateCallback trafficStateCallback = new TestTrafficStateCallback(mLock);
TestTrafficStateCallback trafficStateCallback =
new TestTrafficStateCallback(mLock, DATA_ACTIVITY_INOUT);
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
try {
uiAutomation.adoptShellPermissionIdentity();