ConnectivityManagerStressTestRunner.java revision b97435c94f4d35a70d63e5dcba5415b0110cf2c9
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 17package com.android.connectivitymanagertest; 18 19import android.os.Bundle; 20import android.test.InstrumentationTestRunner; 21import android.test.InstrumentationTestSuite; 22 23import com.android.connectivitymanagertest.stress.WifiApStress; 24import com.android.connectivitymanagertest.stress.WifiStressTest; 25 26import 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 37public class ConnectivityManagerStressTestRunner extends InstrumentationTestRunner { 38 public int mSoftapIterations = 100; 39 public int mScanIterations = 100; 40 public int mReconnectIterations = 100; 41 public int mSleepTime = 30 * 1000; // default sleep time is 30 seconds 42 public String mReconnectSsid = "securenetdhcp"; 43 public String mReconnectPassword = "androidwifi"; 44 45 @Override 46 public TestSuite getAllTests() { 47 TestSuite suite = new InstrumentationTestSuite(this); 48 if (!UtilHelper.isWifiOnly()) { 49 suite.addTestSuite(WifiApStress.class); 50 suite.addTestSuite(WifiStressTest.class); 51 } else { 52 // create a new test suite 53 suite.setName("WifiOnlyStressTests"); 54 String[] methodNames = {"testWifiScanning"}; 55 Class<WifiStressTest> testClass = WifiStressTest.class; 56 for (String method: methodNames) { 57 suite.addTest(TestSuite.createTest(testClass, method)); 58 } 59 } 60 return suite; 61 } 62 63 @Override 64 public ClassLoader getLoader() { 65 return ConnectivityManagerTestRunner.class.getClassLoader(); 66 } 67 68 @Override 69 public void onCreate(Bundle icicle) { 70 super.onCreate(icicle); 71 String valueStr = (String) icicle.get("softap_iterations"); 72 if (valueStr != null) { 73 int iteration = Integer.parseInt(valueStr); 74 if (iteration > 0) { 75 mSoftapIterations = iteration; 76 } 77 } 78 79 String scanIterationStr = (String) icicle.get("scan_iterations"); 80 if (scanIterationStr != null) { 81 int scanIteration = Integer.parseInt(scanIterationStr); 82 if (scanIteration > 0) { 83 mScanIterations = scanIteration; 84 } 85 } 86 87 String ssidStr= (String) icicle.get("reconnect_ssid"); 88 if (ssidStr != null) { 89 mReconnectSsid = ssidStr; 90 } 91 92 String passwordStr = (String) icicle.get("reconnect_password"); 93 if (passwordStr != null) { 94 mReconnectPassword = passwordStr; 95 } 96 97 String reconnectStr = (String) icicle.get("reconnect_iterations"); 98 if (reconnectStr != null) { 99 int iteration = Integer.parseInt(reconnectStr); 100 if (iteration > 0) { 101 mReconnectIterations = iteration; 102 } 103 } 104 105 String sleepTimeStr = (String) icicle.get("sleep_time"); 106 if (sleepTimeStr != null) { 107 int sleepTime = Integer.parseInt(sleepTimeStr); 108 if (sleepTime > 0) { 109 mSleepTime = 1000 * sleepTime; 110 } 111 } 112 } 113} 114