diff options
author | David Su <dysu@google.com> | 2019-05-30 17:06:35 -0700 |
---|---|---|
committer | David Su <dysu@google.com> | 2019-05-30 17:06:35 -0700 |
commit | 443ee3b76a41c323ec0278dde9f18d2d9029d1e1 (patch) | |
tree | 674358caaa21d4586c8a23a9665ba60f62662fdd | |
parent | 080083b69d931a22bba4d26c85c05cab22e8d71a (diff) |
Optimize Link Probing unit test to prevent timeout
Pull out Mockito's verify() out of for loops to
improve unit test performance and prevent timing
out.
Bug: 134097394
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I5fbf104579e6ba63a73b48e2625064442141ed70
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java index 6884c03c0..32eb78d8c 100644 --- a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java @@ -376,17 +376,17 @@ public class LinkProbeManagerTest { mTimeMs += LinkProbeManager.DELAY_BETWEEN_PROBES_MS + 1000; when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs); mLinkProbeManager.updateConnectionStats(mWifiInfo, TEST_IFACE_NAME); - verify(mWifiNative, times(i)) - .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); } + verify(mWifiNative, times((int) LinkProbeManager.MAX_PROBE_COUNT_IN_PERIOD)) + .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); // verify no more quota for (int i = 0; i < 10; i++) { mTimeMs += LinkProbeManager.DELAY_BETWEEN_PROBES_MS + 1000; when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs); mLinkProbeManager.updateConnectionStats(mWifiInfo, TEST_IFACE_NAME); - verify(mWifiNative, times((int) LinkProbeManager.MAX_PROBE_COUNT_IN_PERIOD)) - .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); } + verify(mWifiNative, times((int) LinkProbeManager.MAX_PROBE_COUNT_IN_PERIOD)) + .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); // start new period mTimeMs += LinkProbeManager.PERIOD_MILLIS + 1000; @@ -397,16 +397,16 @@ public class LinkProbeManagerTest { mTimeMs += LinkProbeManager.DELAY_BETWEEN_PROBES_MS + 1000; when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs); mLinkProbeManager.updateConnectionStats(mWifiInfo, TEST_IFACE_NAME); - verify(mWifiNative, times((int) (LinkProbeManager.MAX_PROBE_COUNT_IN_PERIOD + i))) - .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); } + verify(mWifiNative, times((int) (2 * LinkProbeManager.MAX_PROBE_COUNT_IN_PERIOD))) + .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); // verify no more quota again for (int i = 0; i < 10; i++) { mTimeMs += LinkProbeManager.DELAY_BETWEEN_PROBES_MS + 1000; when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs); mLinkProbeManager.updateConnectionStats(mWifiInfo, TEST_IFACE_NAME); - verify(mWifiNative, times((int) (2 * LinkProbeManager.MAX_PROBE_COUNT_IN_PERIOD))) - .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); } + verify(mWifiNative, times((int) (2 * LinkProbeManager.MAX_PROBE_COUNT_IN_PERIOD))) + .probeLink(eq(TEST_IFACE_NAME), any(), any(), anyInt()); } } |