Home | History | Annotate | Download | only in connectivitymanagertest
      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     public boolean mWifiOnlyFlag = false;
     46 
     47     @Override
     48     public TestSuite getAllTests() {
     49         TestSuite suite = new InstrumentationTestSuite(this);
     50         suite.addTestSuite(WifiApStress.class);
     51         suite.addTestSuite(WifiStressTest.class);
     52         return suite;
     53     }
     54 
     55     @Override
     56     public ClassLoader getLoader() {
     57         return ConnectivityManagerTestRunner.class.getClassLoader();
     58     }
     59 
     60     @Override
     61     public void onCreate(Bundle icicle) {
     62         super.onCreate(icicle);
     63         String valueStr = (String) icicle.get("softap_iterations");
     64         if (valueStr != null) {
     65             int iteration = Integer.parseInt(valueStr);
     66             if (iteration > 0) {
     67                 mSoftapIterations = iteration;
     68             }
     69         }
     70 
     71         String scanIterationStr = (String) icicle.get("scan_iterations");
     72         if (scanIterationStr != null) {
     73             int scanIteration = Integer.parseInt(scanIterationStr);
     74             if (scanIteration > 0) {
     75                 mScanIterations = scanIteration;
     76             }
     77         }
     78 
     79         String ssidStr= (String) icicle.get("reconnect_ssid");
     80         if (ssidStr != null) {
     81             mReconnectSsid = ssidStr;
     82         }
     83 
     84         String passwordStr = (String) icicle.get("reconnect_password");
     85         if (passwordStr != null) {
     86             mReconnectPassword = passwordStr;
     87         }
     88 
     89         String reconnectStr = (String) icicle.get("reconnect_iterations");
     90         if (reconnectStr != null) {
     91             int iteration = Integer.parseInt(reconnectStr);
     92             if (iteration > 0) {
     93                 mReconnectIterations = iteration;
     94             }
     95         }
     96 
     97         String sleepTimeStr = (String) icicle.get("sleep_time");
     98         if (sleepTimeStr != null) {
     99             int sleepTime = Integer.parseInt(sleepTimeStr);
    100             if (sleepTime > 0) {
    101                 mSleepTime = 1000 * sleepTime;
    102             }
    103         }
    104 
    105         String wifiOnlyFlag = (String) icicle.get("wifi-only");
    106         if (wifiOnlyFlag != null) {
    107             mWifiOnlyFlag = true;
    108         }
    109     }
    110 }
    111