1 /* 2 * Copyright (C) 2010, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.connectivitymanagertest; 18 19 import android.os.Bundle; 20 import android.test.InstrumentationTestRunner; 21 import android.test.InstrumentationTestSuite; 22 23 import com.android.connectivitymanagertest.stress.WifiApStress; 24 import com.android.connectivitymanagertest.stress.WifiStressTest; 25 26 import junit.framework.TestSuite; 27 28 /** 29 * Instrumentation Test Runner for all stress tests 30 * 31 * To run the stress tests: 32 * 33 * adb shell am instrument -e stressnum <stress times> \ 34 * -w com.android.connectivitymanagertest/.ConnectivityManagerStressTestRunner 35 */ 36 37 public class ConnectivityManagerStressTestRunner extends InstrumentationTestRunner { 38 public int mSoftapIterations = 100; 39 public int mScanIterations = 100; 40 public int mReconnectIterations = 100; 41 // sleep time before restart wifi, default is set to 2 minutes 42 public int mSleepTime = 2 * 60 * 1000; 43 public String mReconnectSsid = "securenetdhcp"; 44 public String mReconnectPassword = "androidwifi"; 45 46 @Override 47 public TestSuite getAllTests() { 48 TestSuite suite = new InstrumentationTestSuite(this); 49 if (!UtilHelper.isWifiOnly()) { 50 suite.addTestSuite(WifiApStress.class); 51 suite.addTestSuite(WifiStressTest.class); 52 } else { 53 // only the wifi stress tests 54 suite.addTestSuite(WifiStressTest.class); 55 } 56 return suite; 57 } 58 59 @Override 60 public ClassLoader getLoader() { 61 return ConnectivityManagerTestRunner.class.getClassLoader(); 62 } 63 64 @Override 65 public void onCreate(Bundle icicle) { 66 super.onCreate(icicle); 67 if (!UtilHelper.isWifiOnly()) { 68 String valueStr = (String) icicle.get("softap_iterations"); 69 if (valueStr != null) { 70 int iteration = Integer.parseInt(valueStr); 71 if (iteration > 0) { 72 mSoftapIterations = iteration; 73 } 74 } 75 } 76 77 String scanIterationStr = (String) icicle.get("scan_iterations"); 78 if (scanIterationStr != null) { 79 int scanIteration = Integer.parseInt(scanIterationStr); 80 if (scanIteration > 0) { 81 mScanIterations = scanIteration; 82 } 83 } 84 85 String ssidStr= (String) icicle.get("reconnect_ssid"); 86 if (ssidStr != null) { 87 mReconnectSsid = ssidStr; 88 } 89 90 String passwordStr = (String) icicle.get("reconnect_password"); 91 if (passwordStr != null) { 92 mReconnectPassword = passwordStr; 93 } 94 95 String reconnectStr = (String) icicle.get("reconnect_iterations"); 96 if (reconnectStr != null) { 97 int iteration = Integer.parseInt(reconnectStr); 98 if (iteration > 0) { 99 mReconnectIterations = iteration; 100 } 101 } 102 103 String sleepTimeStr = (String) icicle.get("sleep_time"); 104 if (sleepTimeStr != null) { 105 int sleepTime = Integer.parseInt(sleepTimeStr); 106 if (sleepTime > 0) { 107 mSleepTime = 1000 * sleepTime; 108 } 109 } 110 } 111 } 112