diff options
author | Xia Wang <xiaw@google.com> | 2012-10-31 16:53:26 -0700 |
---|---|---|
committer | Xia Wang <xiaw@google.com> | 2012-10-31 17:03:23 -0700 |
commit | b2a2096903342a9eaba0b8f64f0f549e5277b662 (patch) | |
tree | 97d786954cd23b18cd55add965abe172a9c40912 /core/tests/ConnectivityManagerTest | |
parent | 86e1b96666af3693ec1bf220272fbc90d73d3cde (diff) | |
download | frameworks_base-b2a2096903342a9eaba0b8f64f0f549e5277b662.zip frameworks_base-b2a2096903342a9eaba0b8f64f0f549e5277b662.tar.gz frameworks_base-b2a2096903342a9eaba0b8f64f0f549e5277b662.tar.bz2 |
Fix WiFi stress test
- Disable lock screen after screen is turned on.
Without disabling lock screen, device will screen off automatically after around 10 seconds
- Add a longer timer for ping test when the data traffic is stalled.
For a short ping test, it is hard to tell whether it is a transient issue or a real issue.
bug# 7426823
Change-Id: If1a560e11dcdff519562bb2a22651d1fd523b5a2
Diffstat (limited to 'core/tests/ConnectivityManagerTest')
3 files changed, 31 insertions, 23 deletions
diff --git a/core/tests/ConnectivityManagerTest/AndroidManifest.xml b/core/tests/ConnectivityManagerTest/AndroidManifest.xml index 1bbc7df..5db7ffc 100644 --- a/core/tests/ConnectivityManagerTest/AndroidManifest.xml +++ b/core/tests/ConnectivityManagerTest/AndroidManifest.xml @@ -74,4 +74,5 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> + <uses-permission android:name="android.permission.INJECT_EVENTS" /> </manifest> diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java index 561e33e..245f537 100644 --- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java +++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java @@ -65,6 +65,8 @@ public class ConnectivityManagerTestActivity extends Activity { public static final long LONG_TIMEOUT = 50 * 1000; // 2 minutes timer between wifi stop and start public static final long WIFI_STOP_START_INTERVAL = 2 * 60 * 1000; + // Set ping test timer to be 3 minutes + public static final long PING_TIMER = 3 * 60 *1000; public static final int SUCCESS = 0; // for Wifi tethering state change public static final int FAILURE = 1; public static final int INIT = -1; @@ -517,37 +519,36 @@ public class ConnectivityManagerTestActivity extends Activity { * @return true if the ping test is successful, false otherwise. */ public boolean pingTest(String[] pingServerList) { - boolean result = false; String[] hostList = {"www.google.com", "www.yahoo.com", "www.bing.com", "www.facebook.com", "www.ask.com"}; if (pingServerList != null) { hostList = pingServerList; } - try { - // assume the chance that all servers are down is very small - for (int i = 0; i < hostList.length; i++ ) { - String host = hostList[i]; - log("Start ping test, ping " + host); - Process p = Runtime.getRuntime().exec("ping -c 10 -w 100 " + host); - int status = p.waitFor(); - if (status == 0) { - // if any of the ping test is successful, return true - result = true; - break; - } else { - result = false; - log("ping " + host + " failed."); + + long startTime = System.currentTimeMillis(); + while ((System.currentTimeMillis() - startTime) < PING_TIMER) { + try { + // assume the chance that all servers are down is very small + for (int i = 0; i < hostList.length; i++ ) { + String host = hostList[i]; + log("Start ping test, ping " + host); + Process p = Runtime.getRuntime().exec("ping -c 10 -w 100 " + host); + int status = p.waitFor(); + if (status == 0) { + // if any of the ping test is successful, return true + return true; + } } + } catch (UnknownHostException e) { + log("Ping test Fail: Unknown Host"); + } catch (IOException e) { + log("Ping test Fail: IOException"); + } catch (InterruptedException e) { + log("Ping test Fail: InterruptedException"); } - } catch (UnknownHostException e) { - log("Ping test Fail: Unknown Host"); - } catch (IOException e) { - log("Ping test Fail: IOException"); - } catch (InterruptedException e) { - log("Ping test Fail: InterruptedException"); } - log("return"); - return result; + // ping test timeout + return false; } /** diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java index 79d928c..7bfb594 100644 --- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java +++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java @@ -28,6 +28,7 @@ import android.net.wifi.WifiManager; import android.os.Environment; import android.os.PowerManager; import android.provider.Settings; +import android.view.KeyEvent; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; @@ -289,6 +290,11 @@ public class WifiStressTest // Turn screen on again mAct.turnScreenOn(); + // Wait for 2 seconds for the lock screen + sleep(2 * 1000, "wait 2 seconds for lock screen"); + // Disable lock screen by inject menu key event + mRunner.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU); + // Measure the time for Wi-Fi to get connected long startTime = System.currentTimeMillis(); assertTrue("Wait for Wi-Fi enable timeout after wake up", |