summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2020-07-06 18:58:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-07-06 18:58:06 +0000
commit4d67769d0680687e696186f0bb456ee08b53a2cd (patch)
tree237244fd61326457c0eda0644925913a513fe16e /tests
parentc8d001912a0d37fcea4146c3333ea48b0a0f0b6f (diff)
parent9e80c7bb6a53d2a4ba1df348ea36b43707167840 (diff)
Merge "Fix quickly toggling airplane mode on then off could leave Wifi disabled" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
index ceaf76dc8..8294bdb04 100644
--- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
@@ -2240,6 +2240,43 @@ public class ActiveModeWardenTest extends WifiBaseTest {
}
@Test
+ public void airplaneModeToggleOffIsDeferredWhileProcessingToggleOnWithOneModeManager2()
+ throws Exception {
+ enterClientModeActiveState();
+ assertInEnabledState();
+
+ // APM toggle on
+ assertWifiShutDown(() -> {
+ when(mSettingsStore.isAirplaneModeOn()).thenReturn(true);
+ mActiveModeWarden.airplaneModeToggled();
+ mLooper.dispatchAll();
+ });
+
+
+ // APM toggle off before the stop is complete.
+ assertInEnabledState();
+ when(mClientModeManager.isStopping()).thenReturn(true);
+ when(mSettingsStore.isAirplaneModeOn()).thenReturn(false);
+ mActiveModeWarden.airplaneModeToggled();
+ // This test is identical to
+ // airplaneModeToggleOffIsDeferredWhileProcessingToggleOnWithOneModeManager, except the
+ // dispatchAll() here is removed. There could be a race between airplaneModeToggled and
+ // mClientListener.onStopped(). See b/160105640#comment5.
+
+ mClientListener.onStopped();
+ mLooper.dispatchAll();
+
+ verify(mClientModeManager, times(2)).start();
+ verify(mClientModeManager, times(2)).setRole(ROLE_CLIENT_PRIMARY);
+
+ mClientListener.onStarted();
+ mLooper.dispatchAll();
+
+ // We should be back to enabled state.
+ assertInEnabledState();
+ }
+
+ @Test
public void airplaneModeToggleOffIsDeferredWhileProcessingToggleOnWithTwoModeManager()
throws Exception {
enterClientModeActiveState();