diff options
author | Roshan Pius <rpius@google.com> | 2018-09-20 13:34:22 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2018-09-27 19:37:21 -0700 |
commit | ce02379ffd2a080ef58d381456bc250ba82e2507 (patch) | |
tree | 89979cb838cbdbc5d50cd71f3276f20c4fd72a05 /tests | |
parent | 01d1d200d69e83238f44aa5a0e43051125730ecf (diff) |
WifiConnectivityManager: Refactor instantiation in ClientModeImpl
Create instance of WifiConnectivityManager in the constructor of
ClientModeImpl to avoid the null checks throughout the class. This
CL does not fix the ugly cyclic dependencies between these classes. That
is more involved and will be taken up later. This CL makes the
refactoring of WifiNetworkFactory from ClientModeImpl easier (next CL up
the stack).
Bug: 116218227
Test: Unit tests
Test: Device boots up & auto-connects to saved wifi networks.
Change-Id: Ib7b321482bf3f2eff9707e82a64da02513071e8e
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java | 2 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 1dade80db..b317e2950 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -399,7 +399,7 @@ public class ClientModeImplTest { when(mWifiInjector.getWifiDiagnostics()).thenReturn(mWifiDiagnostics); when(mWifiInjector.getWifiConfigManager()).thenReturn(mWifiConfigManager); when(mWifiInjector.getWifiScanner()).thenReturn(mWifiScanner); - when(mWifiInjector.makeWifiConnectivityManager(any(WifiInfo.class), anyBoolean())) + when(mWifiInjector.makeWifiConnectivityManager(any())) .thenReturn(mWifiConnectivityManager); when(mWifiInjector.getPasspointManager()).thenReturn(mPasspointManager); when(mWifiInjector.getWifiStateTracker()).thenReturn(mWifiStateTracker); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 625ed7180..7d0922959 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -92,6 +92,7 @@ public class WifiConnectivityManagerTest { mWifiScanner = mockWifiScanner(); mWifiConnectivityHelper = mockWifiConnectivityHelper(); mWifiNS = mockWifiNetworkSelector(); + when(mWifiInjector.getWifiScanner()).thenReturn(mWifiScanner); mWifiConnectivityManager = createConnectivityManager(); verify(mWifiConfigManager).setOnSavedNetworkUpdateListener(anyObject()); mWifiConnectivityManager.setWifiEnabled(true); @@ -125,7 +126,7 @@ public class WifiConnectivityManagerTest { private WifiConfigManager mWifiConfigManager; private WifiInfo mWifiInfo; private LocalLog mLocalLog; - @Mock private FrameworkFacade mFrameworkFacade; + @Mock private WifiInjector mWifiInjector; @Mock private NetworkScoreManager mNetworkScoreManager; @Mock private Clock mClock; @Mock private WifiLastResortWatchdog mWifiLastResortWatchdog; @@ -313,11 +314,11 @@ public class WifiConnectivityManagerTest { WifiConnectivityManager createConnectivityManager() { return new WifiConnectivityManager(mContext, new ScoringParams(mContext), - mClientModeImpl, mWifiScanner, + mClientModeImpl, mWifiInjector, mWifiConfigManager, mWifiInfo, mWifiNS, mWifiConnectivityHelper, mWifiLastResortWatchdog, mOpenNetworkNotifier, mCarrierNetworkNotifier, mCarrierNetworkConfig, mWifiMetrics, mLooper.getLooper(), mClock, mLocalLog, true, - mFrameworkFacade, null, null, null); + null, null, null); } /** |