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.WifiStressTest;
     24 
     25 import junit.framework.TestSuite;
     26 
     27 /**
     28  * Instrumentation Test Runner for all stress tests
     29  *
     30  * To run the stress tests:
     31  *
     32  * adb shell am instrument -e stressnum <stress times> \
     33  *     -w com.android.connectivitymanagertest/.ConnectivityManagerStressTestRunner
     34  */
     35 
     36 public class ConnectivityManagerStressTestRunner extends InstrumentationTestRunner {
     37     private int mSoftApIterations = 0;
     38     private int mScanIterations = 100;
     39     private int mReconnectIterations = 100;
     40     // sleep time before restart wifi, default is set to 2 minutes
     41     private long mSleepTime = 2 * 60 * 1000;
     42     private String mReconnectSsid = null;
     43     private String mReconnectPassword = null;
     44     private boolean mWifiOnlyFlag = false;
     45 
     46     @Override
     47     public TestSuite getAllTests() {
     48         TestSuite suite = new InstrumentationTestSuite(this);
     49         suite.addTestSuite(WifiStressTest.class);
     50         return suite;
     51     }
     52 
     53     @Override
     54     public ClassLoader getLoader() {
     55         return ConnectivityManagerTestRunner.class.getClassLoader();
     56     }
     57 
     58     @Override
     59     public void onCreate(Bundle icicle) {
     60         super.onCreate(icicle);
     61 
     62         String scanIterationStr = icicle.getString("scan_iterations");
     63         if (scanIterationStr != null) {
     64             int scanIteration = Integer.parseInt(scanIterationStr);
     65             if (scanIteration > 0) {
     66                 mScanIterations = scanIteration;
     67             }
     68         }
     69 
     70         String ssidStr= icicle.getString("reconnect_ssid");
     71         if (ssidStr != null) {
     72             mReconnectSsid = ssidStr;
     73         }
     74 
     75         String passwordStr = icicle.getString("reconnect_password");
     76         if (passwordStr != null) {
     77             mReconnectPassword = passwordStr;
     78         }
     79 
     80         String reconnectStr = icicle.getString("reconnect_iterations");
     81         if (reconnectStr != null) {
     82             int iteration = Integer.parseInt(reconnectStr);
     83             if (iteration > 0) {
     84                 mReconnectIterations = iteration;
     85             }
     86         }
     87 
     88         String sleepTimeStr = icicle.getString("sleep_time");
     89         if (sleepTimeStr != null) {
     90             int sleepTime = Integer.parseInt(sleepTimeStr);
     91             if (sleepTime > 0) {
     92                 mSleepTime = 1000 * sleepTime;
     93             }
     94         }
     95 
     96         String wifiOnlyFlag = icicle.getString("wifi-only");
     97         if (wifiOnlyFlag != null) {
     98             mWifiOnlyFlag = true;
     99         }
    100     }
    101 
    102     public int getSoftApInterations() {
    103         return mSoftApIterations;
    104     }
    105 
    106     public int getScanIterations() {
    107         return mScanIterations;
    108     }
    109 
    110     public int getReconnectIterations() {
    111         return mReconnectIterations;
    112     }
    113 
    114     public boolean isWifiOnly() {
    115         return mWifiOnlyFlag;
    116     }
    117 
    118     public long getSleepTime() {
    119         return mSleepTime;
    120     }
    121 
    122     public String getReconnectSsid() {
    123         return mReconnectSsid;
    124     }
    125 
    126     public String getReconnectPassword() {
    127         return mReconnectPassword;
    128     }
    129 }
    130