summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2019-08-14 14:37:22 -0700
committerDavid Su <dysu@google.com>2019-09-03 13:26:29 -0700
commitee26219c59a5bbabb06996e840d0320b55b7e00e (patch)
tree3dcf8c3c1b683c65427b19398d11b82367e41f84 /tests
parent5adee6f9e86ea1cbab4d0ba206f2df9fa5bc7bc4 (diff)
Move WifiController into ActiveModeWarden as an inner class
Bug: 139157226 Test: entire topic compiles Change-Id: Idacfb4883a23eb6dcffd4ac3eb0ba7bdc0f16f45
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SelfRecoveryTest.java41
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java34
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java7
4 files changed, 43 insertions, 41 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SelfRecoveryTest.java b/tests/wifitests/src/com/android/server/wifi/SelfRecoveryTest.java
index bcef92ca9..ab511fd20 100644
--- a/tests/wifitests/src/com/android/server/wifi/SelfRecoveryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SelfRecoveryTest.java
@@ -31,7 +31,8 @@ import org.mockito.Mock;
@SmallTest
public class SelfRecoveryTest {
SelfRecovery mSelfRecovery;
- @Mock WifiController mWifiController;
+ @Mock
+ ActiveModeWarden.WifiController mWifiController;
@Mock Clock mClock;
@Before
@@ -42,24 +43,24 @@ public class SelfRecoveryTest {
/**
* Verifies that invocations of {@link SelfRecovery#trigger(int)} with valid reasons will send
- * the restart message to {@link WifiController}.
+ * the restart message to {@link ActiveModeWarden.WifiController}.
*/
@Test
public void testValidTriggerReasonsSendMessageToWifiController() {
mSelfRecovery.trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
reset(mWifiController);
when(mClock.getElapsedSinceBootMillis())
.thenReturn(SelfRecovery.MAX_RESTARTS_TIME_WINDOW_MILLIS + 1);
mSelfRecovery.trigger(SelfRecovery.REASON_WIFINATIVE_FAILURE);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
reset(mWifiController);
}
/**
* Verifies that invocations of {@link SelfRecovery#trigger(int)} with invalid reasons will not
- * send the restart message to {@link WifiController}.
+ * send the restart message to {@link ActiveModeWarden.WifiController}.
*/
@Test
public void testInvalidTriggerReasonsDoesNotSendMessageToWifiController() {
@@ -76,7 +77,7 @@ public class SelfRecoveryTest {
@Test
public void testStaIfaceDownDisablesWifi() {
mSelfRecovery.trigger(SelfRecovery.REASON_STA_IFACE_DOWN);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_DISABLE_WIFI));
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_DISABLE_WIFI));
}
/**
@@ -91,57 +92,57 @@ public class SelfRecoveryTest {
// aren't ignored
for (int i = 0; i < SelfRecovery.MAX_RESTARTS_IN_TIME_WINDOW / 2; i++) {
mSelfRecovery.trigger(SelfRecovery.REASON_WIFINATIVE_FAILURE);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI),
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI),
anyInt());
reset(mWifiController);
mSelfRecovery.trigger(SelfRecovery.REASON_WIFINATIVE_FAILURE);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI),
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI),
anyInt());
reset(mWifiController);
}
if ((SelfRecovery.MAX_RESTARTS_IN_TIME_WINDOW % 2) == 1) {
mSelfRecovery.trigger(SelfRecovery.REASON_WIFINATIVE_FAILURE);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI),
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI),
anyInt());
reset(mWifiController);
}
// Verify that further attempts to trigger restarts disable wifi
mSelfRecovery.trigger(SelfRecovery.REASON_WIFINATIVE_FAILURE);
- verify(mWifiController, never()).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI),
+ verify(mWifiController, never()).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI),
anyString());
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_DISABLE_WIFI));
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_DISABLE_WIFI));
reset(mWifiController);
mSelfRecovery.trigger(SelfRecovery.REASON_WIFINATIVE_FAILURE);
- verify(mWifiController, never()).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI),
+ verify(mWifiController, never()).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI),
anyString());
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_DISABLE_WIFI));
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_DISABLE_WIFI));
reset(mWifiController);
// Verify L.R.Watchdog can still restart things (It has its own complex limiter)
mSelfRecovery.trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI),
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI),
anyInt());
reset(mWifiController);
// Verify Sta Interface Down will still disable wifi
mSelfRecovery.trigger(SelfRecovery.REASON_STA_IFACE_DOWN);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_DISABLE_WIFI));
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_DISABLE_WIFI));
reset(mWifiController);
// now TRAVEL FORWARDS IN TIME and ensure that more restarts can occur
when(mClock.getElapsedSinceBootMillis())
.thenReturn(SelfRecovery.MAX_RESTARTS_TIME_WINDOW_MILLIS + 1);
mSelfRecovery.trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
reset(mWifiController);
when(mClock.getElapsedSinceBootMillis())
.thenReturn(SelfRecovery.MAX_RESTARTS_TIME_WINDOW_MILLIS + 1);
mSelfRecovery.trigger(SelfRecovery.REASON_WIFINATIVE_FAILURE);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
reset(mWifiController);
}
@@ -156,7 +157,7 @@ public class SelfRecoveryTest {
for (int i = 0; i < SelfRecovery.MAX_RESTARTS_IN_TIME_WINDOW * 2; i++) {
// Verify L.R.Watchdog can still restart things (It has it's own complex limiter)
mSelfRecovery.trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI),
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI),
anyInt());
reset(mWifiController);
}
@@ -172,9 +173,9 @@ public class SelfRecoveryTest {
public void testTimeWindowLimiting_staIfaceDown_noEffect() {
for (int i = 0; i < SelfRecovery.MAX_RESTARTS_IN_TIME_WINDOW * 2; i++) {
mSelfRecovery.trigger(SelfRecovery.REASON_STA_IFACE_DOWN);
- verify(mWifiController).sendMessage(eq(WifiController.CMD_RECOVERY_DISABLE_WIFI));
+ verify(mWifiController).sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_DISABLE_WIFI));
verify(mWifiController, never())
- .sendMessage(eq(WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
+ .sendMessage(eq(ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI), anyInt());
reset(mWifiController);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
index 72d579268..05ef8819e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
@@ -78,7 +78,7 @@ public class WakeupControllerTest {
@Mock private FrameworkFacade mFrameworkFacade;
@Mock private WifiSettingsStore mWifiSettingsStore;
@Mock private WifiWakeMetrics mWifiWakeMetrics;
- @Mock private WifiController mWifiController;
+ @Mock private ActiveModeWarden.WifiController mWifiController;
@Mock private WifiNative mWifiNative;
@Mock private Clock mClock;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java
index 313e159c9..c308e9b4b 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java
@@ -16,16 +16,16 @@
package com.android.server.wifi;
-import static com.android.server.wifi.WifiController.CMD_AP_STOPPED;
-import static com.android.server.wifi.WifiController.CMD_EMERGENCY_CALL_STATE_CHANGED;
-import static com.android.server.wifi.WifiController.CMD_EMERGENCY_MODE_CHANGED;
-import static com.android.server.wifi.WifiController.CMD_RECOVERY_DISABLE_WIFI;
-import static com.android.server.wifi.WifiController.CMD_RECOVERY_RESTART_WIFI;
-import static com.android.server.wifi.WifiController.CMD_SCANNING_STOPPED;
-import static com.android.server.wifi.WifiController.CMD_SCAN_ALWAYS_MODE_CHANGED;
-import static com.android.server.wifi.WifiController.CMD_SET_AP;
-import static com.android.server.wifi.WifiController.CMD_STA_STOPPED;
-import static com.android.server.wifi.WifiController.CMD_WIFI_TOGGLED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_AP_STOPPED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_EMERGENCY_CALL_STATE_CHANGED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_EMERGENCY_MODE_CHANGED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_RECOVERY_DISABLE_WIFI;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_RECOVERY_RESTART_WIFI;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_SCANNING_STOPPED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_SCAN_ALWAYS_MODE_CHANGED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_SET_AP;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_STA_STOPPED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_WIFI_TOGGLED;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
@@ -98,7 +98,7 @@ public class WifiControllerTest {
@Mock ActiveModeWarden mActiveModeWarden;
@Mock WifiPermissionsUtil mWifiPermissionsUtil;
- WifiController mWifiController;
+ ActiveModeWarden.WifiController mWifiController;
private BroadcastReceiver mBroadcastReceiver;
@@ -119,7 +119,7 @@ public class WifiControllerTest {
.thenReturn(TEST_WIFI_RECOVERY_DELAY_MS);
when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true);
- mWifiController = new WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
+ mWifiController = new ActiveModeWarden.WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
mSettingsStore, mFacade, mActiveModeWarden, mWifiPermissionsUtil);
mWifiController.start();
mLooper.dispatchAll();
@@ -180,7 +180,7 @@ public class WifiControllerTest {
// reset to avoid the default behavior
reset(mActiveModeWarden);
- WifiController wifiController = new WifiController(mContext, mClientModeImpl,
+ ActiveModeWarden.WifiController wifiController = new ActiveModeWarden.WifiController(mContext, mClientModeImpl,
mLooper.getLooper(), mSettingsStore, mFacade, mActiveModeWarden,
mWifiPermissionsUtil);
@@ -202,7 +202,7 @@ public class WifiControllerTest {
when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(false);
when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(false);
- mWifiController = new WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
+ mWifiController = new ActiveModeWarden.WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
mSettingsStore, mFacade, mActiveModeWarden, mWifiPermissionsUtil);
reset(mActiveModeWarden);
@@ -230,7 +230,7 @@ public class WifiControllerTest {
reset(mContext, mActiveModeWarden);
when(mContext.getResources()).thenReturn(mResources);
- mWifiController = new WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
+ mWifiController = new ActiveModeWarden.WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
mSettingsStore, mFacade, mActiveModeWarden, mWifiPermissionsUtil);
mWifiController.start();
@@ -263,7 +263,7 @@ public class WifiControllerTest {
reset(mContext, mActiveModeWarden);
when(mContext.getResources()).thenReturn(mResources);
- mWifiController = new WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
+ mWifiController = new ActiveModeWarden.WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
mSettingsStore, mFacade, mActiveModeWarden, mWifiPermissionsUtil);
mWifiController.start();
mLooper.dispatchAll();
@@ -954,7 +954,7 @@ public class WifiControllerTest {
when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false);
when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(false);
- mWifiController = new WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
+ mWifiController = new ActiveModeWarden.WifiController(mContext, mClientModeImpl, mLooper.getLooper(),
mSettingsStore, mFacade, mActiveModeWarden, mWifiPermissionsUtil);
mWifiController.start();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 2f942e828..15cab2b8a 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -37,8 +37,8 @@ import static android.net.wifi.WifiManager.WIFI_FEATURE_INFRA_5G;
import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED;
import static com.android.server.wifi.LocalOnlyHotspotRequestInfo.HOTSPOT_NO_ERROR;
-import static com.android.server.wifi.WifiController.CMD_SET_AP;
-import static com.android.server.wifi.WifiController.CMD_WIFI_TOGGLED;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_SET_AP;
+import static com.android.server.wifi.ActiveModeWarden.WifiController.CMD_WIFI_TOGGLED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -219,7 +219,8 @@ public class WifiServiceImplTest {
@Mock WifiInjector mWifiInjector;
@Mock WifiCountryCode mWifiCountryCode;
@Mock Clock mClock;
- @Mock WifiController mWifiController;
+ @Mock
+ ActiveModeWarden.WifiController mWifiController;
@Mock WifiTrafficPoller mWifiTrafficPoller;
@Mock ClientModeImpl mClientModeImpl;
@Mock ActiveModeWarden mActiveModeWarden;