summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2018-04-26 17:34:56 -0700
committerMichael Plass <mplass@google.com>2018-05-09 15:17:28 +0000
commit1ba5b5858ffc04acbd317dc1f6789f1777d375e6 (patch)
tree4f1c3366d016e092abc50b5adfa845badeb87a51 /tests
parent76defeec19f5f0155a657bedc7590edd8c455d1d (diff)
Remove mWifiLinkLayerStatsSupported counter
While here, remove some unneeded private final vars. Added new unit test to exercise RSSI polling, and one to test switching counter sources. Bug: 78592561 Test: Unit tests Change-Id: I1b944d567528f4f52817c5d4157b0ff526c1a444
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java40
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java29
2 files changed, 69 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java
index 0189aed07..638b637c6 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java
@@ -17,6 +17,7 @@
package com.android.server.wifi;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@@ -121,4 +122,43 @@ public class WifiLinkLayerStatsTest {
mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs);
assertEquals(0.33, mWifiInfo.txSuccessRate, 0.01);
}
+
+ /**
+ * Check for bad interactions with the alternative updatePacketRates method
+ */
+ @Test
+ public void afterSourceSwitchTheRatesShouldGetReset() throws Exception {
+ // Do some updates using link layer stats
+ bumpCounters(mWifiLinkLayerStats, 999, 999, 999, 999);
+ mWifiLinkLayerStats.timeStampInMs = 999999999;
+ mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs);
+ assertEquals(0.0, mWifiInfo.txSuccessRate, 0.0001);
+ assertEquals(0.0, mWifiInfo.rxSuccessRate, 0.0001);
+ bumpCounters(mWifiLinkLayerStats, 1_000_000_000, 777000, 66600, 1_000_100_000);
+ mWifiLinkLayerStats.timeStampInMs += 10_000;
+ mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs);
+ assertTrue("" + mWifiInfo + " " + mWifiLinkLayerStats, mWifiInfo.txSuccessRate > 0.95e+8);
+ assertTrue("" + mWifiInfo + " " + mWifiLinkLayerStats, mWifiInfo.rxSuccessRate > 0.95e+8);
+ // Now update with traffic counters
+ mWifiLinkLayerStats.timeStampInMs += 10_000;
+ mWifiInfo.updatePacketRates(2_000_000_000L, 2_000_000_000L,
+ mWifiLinkLayerStats.timeStampInMs);
+ // Despite the increase, the rates should be zero after the change in source
+ assertEquals(0.0, mWifiInfo.txSuccessRate, 0.0001);
+ assertEquals(0.0, mWifiInfo.rxSuccessRate, 0.0001);
+ assertEquals(0, mWifiInfo.txBad);
+ assertEquals(0, mWifiInfo.txRetries);
+ // Make sure that updates from this source work, too
+ mWifiLinkLayerStats.timeStampInMs += 10_000;
+ mWifiInfo.updatePacketRates(3_000_000_000L, 3_000_000_000L,
+ mWifiLinkLayerStats.timeStampInMs);
+ assertTrue(mWifiInfo.txSuccessRate > 0.95e+8);
+ assertTrue(mWifiInfo.rxSuccessRate > 0.95e+8);
+ // Switch back to using link layer stats
+ mWifiLinkLayerStats.timeStampInMs += 10_000;
+ bumpCounters(mWifiLinkLayerStats, 1_000_000_000, 777000, 66600, 1_000_100_000);
+ mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs);
+ assertEquals(0.0, mWifiInfo.txSuccessRate, 0.0001);
+ assertEquals(0.0, mWifiInfo.rxSuccessRate, 0.0001);
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 86692c8ce..79966d7f1 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -2119,6 +2119,35 @@ public class WifiStateMachineTest {
}
/**
+ * Verify that RSSI and link layer stats polling works in connected mode
+ */
+ @Test
+ public void verifyConnectedModeRssiPolling() throws Exception {
+ final long startMillis = 1_500_000_000_100L;
+ WifiLinkLayerStats llStats = new WifiLinkLayerStats();
+ llStats.txmpdu_be = 1000;
+ llStats.rxmpdu_bk = 2000;
+ WifiNative.SignalPollResult signalPollResult = new WifiNative.SignalPollResult();
+ signalPollResult.currentRssi = -42;
+ signalPollResult.txBitrate = 65;
+ signalPollResult.associationFrequency = sFreq;
+ when(mWifiNative.getWifiLinkLayerStats(any())).thenReturn(llStats);
+ when(mWifiNative.signalPoll(any())).thenReturn(signalPollResult);
+ when(mClock.getWallClockMillis()).thenReturn(startMillis + 0);
+ mWsm.enableRssiPolling(true);
+ connect();
+ mLooper.dispatchAll();
+ when(mClock.getWallClockMillis()).thenReturn(startMillis + 3333);
+ mLooper.dispatchAll();
+ WifiInfo wifiInfo = mWsm.getWifiInfo();
+ assertEquals(llStats.txmpdu_be, wifiInfo.txSuccess);
+ assertEquals(llStats.rxmpdu_bk, wifiInfo.rxSuccess);
+ assertEquals(signalPollResult.currentRssi, wifiInfo.getRssi());
+ assertEquals(signalPollResult.txBitrate, wifiInfo.getLinkSpeed());
+ assertEquals(sFreq, wifiInfo.getFrequency());
+ }
+
+ /**
* Verify that calls to start and stop filtering multicast packets are passed on to the IpClient
* instance.
*/