diff options
author | Stephen Chen <stewchen@google.com> | 2016-12-06 12:47:56 -0800 |
---|---|---|
committer | Stephen Chen <stewchen@google.com> | 2016-12-06 12:52:09 -0800 |
commit | 0b9616e0e126221238edf5843a01b0cd3ec4daee (patch) | |
tree | ac7579cbb23780f2e0ef6f86e64063f34e4aacfc /tests | |
parent | d4828aff7aece6bed3db16bfd74633d497b0a9cf (diff) |
Refactor WifiNetworkScoreCache in ExternalScoreEvaluator to WifiInjector.
This allows us to share the cache in WifiNotificationController
Bug: 33355924
Test: runtest --path
frameworks/opt/net/wifi/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
runtest --path
frameworks/opt/net/wifi/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java
Change-Id: I934b29fb5287180610355588ed7fa43018ccd4aa
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java | 18 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java | 3 |
2 files changed, 5 insertions, 16 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java index ada21461f..238930d1b 100644 --- a/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java @@ -22,10 +22,8 @@ import static com.android.server.wifi.WifiConfigurationTestUtil.SECURITY_PSK; import static org.junit.Assert.*; import static org.mockito.Mockito.*; -import android.app.test.MockAnswerUtil.AnswerWithArguments; import android.content.Context; import android.content.res.Resources; -import android.net.INetworkScoreCache; import android.net.NetworkScoreManager; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; @@ -51,8 +49,9 @@ public class ExternalScoreEvaluatorTest { @Before public void setUp() throws Exception { mResource = getResource(); - mScoreManager = getScoreManager(); + mScoreManager = mock(NetworkScoreManager.class); mContext = getContext(); + mScoreCache = new WifiNetworkScoreCache(mContext); mWifiConfigManager = getWifiConfigManager(); when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime()); @@ -62,7 +61,7 @@ public class ExternalScoreEvaluatorTest { R.integer.config_wifi_framework_wifi_score_low_rssi_threshold_5GHz); mExternalScoreEvaluator = new ExternalScoreEvaluator(mContext, mWifiConfigManager, - mClock, null); + mScoreCache, mClock, null); } /** Cleans up test. */ @@ -82,17 +81,6 @@ public class ExternalScoreEvaluatorTest { private int mThresholdQualifiedRssi5G; private static final String TAG = "External Score Evaluator Unit Test"; - NetworkScoreManager getScoreManager() { - NetworkScoreManager scoreManager = mock(NetworkScoreManager.class); - - doAnswer(new AnswerWithArguments() { - public void answer(int networkType, INetworkScoreCache scoreCache) { - mScoreCache = (WifiNetworkScoreCache) scoreCache; - }}).when(scoreManager).registerNetworkScoreCache(anyInt(), anyObject()); - - return scoreManager; - } - Context getContext() { Context context = mock(Context.class); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 2a57a6a78..cb50471d2 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -105,6 +105,7 @@ public class WifiConnectivityManagerTest { @Mock private Clock mClock; @Mock private WifiLastResortWatchdog mWifiLastResortWatchdog; @Mock private WifiMetrics mWifiMetrics; + @Mock private WifiNetworkScoreCache mScoreCache; private MockResources mResources; private static final int CANDIDATE_NETWORK_ID = 0; @@ -252,7 +253,7 @@ public class WifiConnectivityManagerTest { WifiConnectivityManager createConnectivityManager() { return new WifiConnectivityManager(mContext, mWifiStateMachine, mWifiScanner, - mWifiConfigManager, mWifiInfo, mWifiNS, mWifiLastResortWatchdog, + mWifiConfigManager, mWifiInfo, mWifiNS, mScoreCache, mWifiLastResortWatchdog, mWifiMetrics, mLooper.getLooper(), mClock, true); } |