ConnectivityManagerTestRunner.java revision b97435c94f4d35a70d63e5dcba5415b0110cf2c9
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 String TEST_SSID = null; 39 40 @Override 41 public TestSuite getAllTests() { 42 TestSuite suite = new InstrumentationTestSuite(this); 43 if (!UtilHelper.isWifiOnly()) { 44 suite.addTestSuite(ConnectivityManagerMobileTest.class); 45 } else { 46 // create a new test suite 47 suite.setName("ConnectivityManagerWifiOnlyFunctionalTests"); 48 String[] methodNames = {"testConnectToWifi", "testConnectToWifWithKnownAP", 49 "testDisconnectWifi", "testDataConnectionOverAMWithWifi", 50 "testDataConnectionWithWifiToAMToWifi", "testWifiStateChange"}; 51 Class<ConnectivityManagerMobileTest> testClass = ConnectivityManagerMobileTest.class; 52 for (String method: methodNames) { 53 suite.addTest(TestSuite.createTest(testClass, method)); 54 } 55 } 56 suite.addTestSuite(WifiConnectionTest.class); 57 return suite; 58 } 59 60 @Override 61 public ClassLoader getLoader() { 62 return ConnectivityManagerTestRunner.class.getClassLoader(); 63 } 64 65 @Override 66 public void onCreate(Bundle icicle) { 67 super.onCreate(icicle); 68 String testSSID = (String) icicle.get("ssid"); 69 if (testSSID != null) { 70 TEST_SSID = testSSID; 71 } 72 } 73} 74