summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java24
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java4
2 files changed, 12 insertions, 16 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index 1c33a2dda..2a57a6a78 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -50,6 +50,8 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -66,7 +68,7 @@ public class WifiConnectivityManagerTest {
*/
@Before
public void setUp() throws Exception {
- mWifiInjector = mockWifiInjector();
+ MockitoAnnotations.initMocks(this);
mResource = mockResource();
mAlarmManager = new TestAlarmManager();
mContext = mockContext();
@@ -100,10 +102,9 @@ public class WifiConnectivityManagerTest {
private ScanData mScanData;
private WifiConfigManager mWifiConfigManager;
private WifiInfo mWifiInfo;
- private Clock mClock = mock(Clock.class);
- private WifiLastResortWatchdog mWifiLastResortWatchdog;
- private WifiMetrics mWifiMetrics;
- private WifiInjector mWifiInjector;
+ @Mock private Clock mClock;
+ @Mock private WifiLastResortWatchdog mWifiLastResortWatchdog;
+ @Mock private WifiMetrics mWifiMetrics;
private MockResources mResources;
private static final int CANDIDATE_NETWORK_ID = 0;
@@ -249,19 +250,10 @@ public class WifiConnectivityManagerTest {
return wifiConfigManager;
}
- WifiInjector mockWifiInjector() {
- WifiInjector wifiInjector = mock(WifiInjector.class);
- mWifiLastResortWatchdog = mock(WifiLastResortWatchdog.class);
- mWifiMetrics = mock(WifiMetrics.class);
- when(wifiInjector.getWifiLastResortWatchdog()).thenReturn(mWifiLastResortWatchdog);
- when(wifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics);
- when(wifiInjector.getClock()).thenReturn(mClock);
- return wifiInjector;
- }
-
WifiConnectivityManager createConnectivityManager() {
return new WifiConnectivityManager(mContext, mWifiStateMachine, mWifiScanner,
- mWifiConfigManager, mWifiInfo, mWifiNS, mWifiInjector, mLooper.getLooper(), true);
+ mWifiConfigManager, mWifiInfo, mWifiNS, mWifiLastResortWatchdog,
+ mWifiMetrics, mLooper.getLooper(), mClock, true);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 36f8b7c41..c27010b9a 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -38,6 +38,7 @@ import android.net.wifi.IWificond;
import android.net.wifi.ScanResult;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiScanner;
import android.net.wifi.WifiSsid;
@@ -310,6 +311,7 @@ public class WifiStateMachineTest {
@Mock IBinder mClientInterfaceBinder;
@Mock WifiConfigManager mWifiConfigManager;
@Mock WifiSupplicantControl mWifiSupplicantControl;
+ @Mock WifiConnectivityManager mWifiConnectivityManager;
public WifiStateMachineTest() throws Exception {
}
@@ -341,6 +343,8 @@ public class WifiStateMachineTest {
when(mWifiInjector.getWifiSupplicantControl()).thenReturn(mWifiSupplicantControl);
when(mWifiInjector.getWifiScanner()).thenReturn(mWifiScanner);
when(mWifiInjector.getWifiNetworkSelector()).thenReturn(mock(WifiNetworkSelector.class));
+ when(mWifiInjector.makeWifiConnectivityManager(any(WifiInfo.class), anyBoolean()))
+ .thenReturn(mWifiConnectivityManager);
when(mWifiNative.getInterfaceName()).thenReturn("mockWlan");
when(mWifiSupplicantControl.getFrameworkNetworkId(anyInt())).thenReturn(0);