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.functional.ConnectivityManagerMobileTest;
24import com.android.connectivitymanagertest.functional.WifiConnectionTest;
25
26import junit.framework.TestSuite;
27
28/**
29 * Instrumentation Test Runner for all connectivity manager tests.
30 *
31 * To run the connectivity manager tests:
32 *
33 * adb shell am instrument -e ssid <ssid> \
34 *     -w com.android.connectivitymanagertest/.ConnectivityManagerTestRunner
35 */
36
37public class ConnectivityManagerTestRunner extends InstrumentationTestRunner {
38    public boolean mWifiOnly = false;
39    public String mSsid = null;
40    public String mPassword = null;
41
42    @Override
43    public TestSuite getAllTests() {
44        TestSuite suite = new InstrumentationTestSuite(this);
45        suite.addTestSuite(ConnectivityManagerMobileTest.class);
46        suite.addTestSuite(WifiConnectionTest.class);
47        return suite;
48    }
49
50    @Override
51    public ClassLoader getLoader() {
52        return ConnectivityManagerTestRunner.class.getClassLoader();
53    }
54
55    @Override
56    public void onCreate(Bundle icicle) {
57        super.onCreate(icicle);
58        String ssid = icicle.getString("ssid");
59        if (ssid != null) {
60            mSsid = ssid;
61        }
62        String password = (String) icicle.get("password");
63        if (password != null) {
64            mPassword = password;
65        }
66        String wifiOnlyFlag = (String) icicle.get("wifi-only");
67        if (wifiOnlyFlag != null) {
68            mWifiOnly = true;
69        }
70    }
71
72    public String getWifiSsid() {
73        return mSsid;
74    }
75
76    public String getWifiPassword() {
77        return mPassword;
78    }
79
80    public boolean isWifiOnly() {
81        return mWifiOnly;
82    }
83}
84