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     private int mSoftApIterations = 100;
     39     private int mScanIterations = 100;
     40     private int mReconnectIterations = 100;
     41     // sleep time before restart wifi, default is set to 2 minutes
     42     private long mSleepTime = 2 * 60 * 1000;
     43     private String mReconnectSsid = null;
     44     private String mReconnectPassword = null;
     45     private 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 = icicle.getString("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 = icicle.getString("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= icicle.getString("reconnect_ssid");
     80         if (ssidStr != null) {
     81             mReconnectSsid = ssidStr;
     82         }
     83 
     84         String passwordStr = icicle.getString("reconnect_password");
     85         if (passwordStr != null) {
     86             mReconnectPassword = passwordStr;
     87         }
     88 
     89         String reconnectStr = icicle.getString("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 = icicle.getString("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 = icicle.getString("wifi-only");
    106         if (wifiOnlyFlag != null) {
    107             mWifiOnlyFlag = true;
    108         }
    109     }
    110 
    111     public int getSoftApInterations() {
    112         return mSoftApIterations;
    113     }
    114 
    115     public int getScanIterations() {
    116         return mScanIterations;
    117     }
    118 
    119     public int getReconnectIterations() {
    120         return mReconnectIterations;
    121     }
    122 
    123     public boolean isWifiOnly() {
    124         return mWifiOnlyFlag;
    125     }
    126 
    127     public long getSleepTime() {
    128         return mSleepTime;
    129     }
    130 
    131     public String getReconnectSsid() {
    132         return mReconnectSsid;
    133     }
    134 
    135     public String getReconnectPassword() {
    136         return mReconnectPassword;
    137     }
    138 }
    139