diff options
author | Michael Plass <mplass@google.com> | 2017-06-14 01:05:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-06-14 01:05:03 +0000 |
commit | f932bcf61f7dfc559d0287c438b8cedea8bd9092 (patch) | |
tree | a68f9a2d391bbf0d5b43520f2261ebdb4f33e7b2 /tests | |
parent | 613bc28a67c43005f61a617611c6d228a7d25ba5 (diff) | |
parent | e802d02eb96d3cbe774110c432f957976deb92b3 (diff) |
Merge "[WifiScoreReport] Simplifed scorer/quick handover" into oc-dr1-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java index 41f14dd75..1f5927d95 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java @@ -49,6 +49,7 @@ public class WifiScoreReportTest { WifiScoreReport mWifiScoreReport; ScanDetailCache mScanDetailCache; WifiInfo mWifiInfo; + int mAggr; // Aggressive handover @Mock Context mContext; @Mock NetworkAgent mNetworkAgent; @Mock Resources mResources; @@ -106,6 +107,7 @@ public class WifiScoreReportTest { config.hiddenSSID = false; mWifiInfo = new WifiInfo(); mWifiInfo.setFrequency(2412); + mAggr = 0; when(mWifiConfigManager.getSavedNetworks()).thenReturn(Arrays.asList(config)); when(mWifiConfigManager.getConfiguredNetwork(anyInt())).thenReturn(config); mWifiConfiguration = config; @@ -138,10 +140,9 @@ public class WifiScoreReportTest { */ @Test public void calculateAndReportScoreSucceeds() throws Exception { - int aggressiveHandover = 0; mWifiInfo.setRssi(-77); mWifiScoreReport.calculateAndReportScore(mWifiInfo, - mNetworkAgent, aggressiveHandover, mWifiMetrics); + mNetworkAgent, mAggr, mWifiMetrics); verify(mNetworkAgent).sendNetworkScore(anyInt()); verify(mWifiMetrics).incrementWifiScoreCount(anyInt()); } @@ -155,7 +156,7 @@ public class WifiScoreReportTest { public void networkAgentMayBeNull() throws Exception { mWifiInfo.setRssi(-33); mWifiScoreReport.enableVerboseLogging(true); - mWifiScoreReport.calculateAndReportScore(mWifiInfo, null, 0, mWifiMetrics); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, null, mAggr, mWifiMetrics); verify(mWifiMetrics).incrementWifiScoreCount(anyInt()); } @@ -174,7 +175,7 @@ public class WifiScoreReportTest { mWifiInfo.txSuccessRate = 5.1; // proportional to pps mWifiInfo.rxSuccessRate = 5.1; for (int i = 0; i < 10; i++) { - mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, 0, mWifiMetrics); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics); } int score = mWifiInfo.score; assertTrue(score > CELLULAR_THRESHOLD_SCORE); @@ -197,10 +198,49 @@ public class WifiScoreReportTest { mWifiInfo.txSuccessRate = 0.1; mWifiInfo.rxSuccessRate = 0.1; for (int i = 0; i < 10; i++) { - mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, 0, mWifiMetrics); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics); } int score = mWifiInfo.score; assertTrue(score < CELLULAR_THRESHOLD_SCORE); verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score); } + + /** + * Test reporting with aggressive handover + */ + @Test + public void calculateAndReportScoreSucceedsAggressively() throws Exception { + mAggr = 1; + mWifiInfo.setRssi(-77); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics); + verify(mNetworkAgent).sendNetworkScore(anyInt()); + verify(mWifiMetrics).incrementWifiScoreCount(anyInt()); + } + + /** + * Test low rssi with aggressive handover + */ + @Test + public void giveUpOnBadRssiAggressively() throws Exception { + mAggr = 1; + mWifiInfo.setRssi(-83); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics); + int score = mWifiInfo.score; + verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score); + assertTrue(score < CELLULAR_THRESHOLD_SCORE); + } + + /** + * Test high rssi with aggressive handover + */ + @Test + public void allowGoodRssiAggressively() throws Exception { + mAggr = 1; + mWifiInfo.setRssi(-65); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics); + int score = mWifiInfo.score; + verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score); + assertTrue(score > CELLULAR_THRESHOLD_SCORE); + } + } |