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;
22import com.android.connectivitymanagertest.stress.WifiApStress;
23import com.android.connectivitymanagertest.stress.WifiStressTest;
24
25import 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
36public class ConnectivityManagerStressTestRunner extends InstrumentationTestRunner {
37    public int mSoftapIterations = 100;
38    public int mScanIterations = 100;
39    public int mReconnectIterations = 100;
40    public int mSleepTime = 30 * 1000;  // default sleep time is 30 seconds
41    public String mReconnectSsid = "securenetdhcp";
42    public String mReconnectPassword = "androidwifi";
43
44    @Override
45    public TestSuite getAllTests() {
46        TestSuite suite = new InstrumentationTestSuite(this);
47        suite.addTestSuite(WifiApStress.class);
48        suite.addTestSuite(WifiStressTest.class);
49        return suite;
50    }
51
52    @Override
53    public ClassLoader getLoader() {
54        return ConnectivityManagerTestRunner.class.getClassLoader();
55    }
56
57    @Override
58    public void onCreate(Bundle icicle) {
59        super.onCreate(icicle);
60        String valueStr = (String) icicle.get("softap_iterations");
61        if (valueStr != null) {
62            int iteration = Integer.parseInt(valueStr);
63            if (iteration > 0) {
64                mSoftapIterations = iteration;
65            }
66        }
67
68        String scanIterationStr = (String) icicle.get("scan_iterations");
69        if (scanIterationStr != null) {
70            int scanIteration = Integer.parseInt(scanIterationStr);
71            if (scanIteration > 0) {
72                mScanIterations = scanIteration;
73            }
74        }
75
76        String ssidStr= (String) icicle.get("reconnect_ssid");
77        if (ssidStr != null) {
78            mReconnectSsid = ssidStr;
79        }
80
81        String passwordStr = (String) icicle.get("reconnect_password");
82        if (passwordStr != null) {
83            mReconnectPassword = passwordStr;
84        }
85
86        String reconnectStr = (String) icicle.get("reconnect_iterations");
87        if (reconnectStr != null) {
88            int iteration = Integer.parseInt(reconnectStr);
89            if (iteration > 0) {
90                mReconnectIterations = iteration;
91            }
92        }
93
94        String sleepTimeStr = (String) icicle.get("sleep_time");
95        if (sleepTimeStr != null) {
96            int sleepTime = Integer.parseInt(sleepTimeStr);
97            if (sleepTime > 0) {
98                mSleepTime = 1000 * sleepTime;
99            }
100        }
101    }
102}
103