diff options
author | xshu <xshu@google.com> | 2018-02-16 16:00:52 -0800 |
---|---|---|
committer | xshu <xshu@google.com> | 2018-02-27 18:53:25 -0800 |
commit | fa60acfff0a91af90b914c7f77cd35a850f38f9e (patch) | |
tree | c0a94d88330b401d8541d4e4274e37a552a196c1 /tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java | |
parent | 3834a0e07498786c6d66ad07be87fe6b79292b90 (diff) | |
download | android_frameworks_opt_net_wifi-fa60acfff0a91af90b914c7f77cd35a850f38f9e.tar.gz android_frameworks_opt_net_wifi-fa60acfff0a91af90b914c7f77cd35a850f38f9e.tar.bz2 android_frameworks_opt_net_wifi-fa60acfff0a91af90b914c7f77cd35a850f38f9e.zip |
Delay bugreport trigger for watchdog recovery
Trigger bugreport after wifi successfully connects after a watchdog
restart.
Introduced random sampling to watchdog reported bugreport.
Bug: 73218994
Test: compile, run ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: Ie078f8f267a4f7ab7bd2206ab631aa9abd2e4245
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java index 85795349a..876950865 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java @@ -23,6 +23,7 @@ import static org.mockito.MockitoAnnotations.*; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiSsid; +import android.os.test.TestLooper; import android.support.test.filters.SmallTest; import android.util.Pair; @@ -42,6 +43,8 @@ public class WifiLastResortWatchdogTest { WifiLastResortWatchdog mLastResortWatchdog; @Mock WifiMetrics mWifiMetrics; @Mock SelfRecovery mSelfRecovery; + @Mock WifiStateMachine mWifiStateMachine; + private String[] mSsids = {"\"test1\"", "\"test2\"", "\"test3\"", "\"test4\""}; private String[] mBssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4", "de:ad:ba:b1:e5:55", "c0:ff:ee:ee:e3:ee"}; @@ -51,11 +54,15 @@ public class WifiLastResortWatchdogTest { private int[] mLevels = {-60, -86, -50, -62}; private boolean[] mIsEphemeral = {false, false, false, false}; private boolean[] mHasEverConnected = {false, false, false, false}; + private TestLooper mLooper; @Before public void setUp() throws Exception { initMocks(this); - mLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mWifiMetrics); + mLooper = new TestLooper(); + mLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mWifiMetrics, + mWifiStateMachine, mLooper.getLooper()); + mLastResortWatchdog.setBugReportProbability(1); } private List<Pair<ScanDetail, WifiConfiguration>> createFilteredQnsCandidates(String[] ssids, @@ -1483,12 +1490,18 @@ public class WifiLastResortWatchdogTest { // Verify that WifiMetrics counted this as a Watchdog success verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses(); + // Verify takeBugReport is called + mLooper.dispatchAll(); + verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString()); // Simulate wifi disconnecting mLastResortWatchdog.connectedStateTransition(false); // Verify that WifiMetrics has still only counted one success verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses(); + // Verify takeBugReport not called again + mLooper.dispatchAll(); + verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString()); // Remove the fifth network from candidates candidates = createFilteredQnsCandidates(Arrays.copyOfRange(mSsids, 0, 4), |