Revert "Demo of Sending Arguments to a Test"
This reverts commit a5d6c08226b2ffc09af39c38c7c0e2ddba27a399.
Seems to prevent tests from being run!
Change-Id: I8d5c227c3fd157ebe080554f146cd7a45e49f24c
diff --git a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
index dbb4f7f..5aa2c3b 100644
--- a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
+++ b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
@@ -59,7 +59,7 @@
*/
private static final String TAG = "InstrumentationCtsTestRunner";
- private static final String ARGUMENT_PHONE_NUMBER = "phoneNumber";
+ private static final String REPORT_VALUE_ID = "InstrumentationCtsTestRunner";
/**
* True if (and only if) we are running in single-test mode (as opposed to
@@ -88,9 +88,6 @@
if (arguments != null) {
String classArg = arguments.getString(ARGUMENT_TEST_CLASS);
mSingleTest = classArg != null && classArg.contains("#");
-
- System.setProperty("cts.phoneNumber",
- arguments.getString(ARGUMENT_PHONE_NUMBER));
}
// attempt to disable keyguard, if current test has permission to do so
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index 7e9af21..44af455 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -110,12 +110,8 @@
super.setUp();
mTelephonyManager =
(TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
- mPackageManager = getContext().getPackageManager();
+ mPackageManager = mContext.getPackageManager();
mDestAddr = mTelephonyManager.getLine1Number();
- if (mDestAddr == null || mDestAddr.isEmpty()) {
- mDestAddr = System.getProperty("cts.phoneNumber", "");
- }
-
mText = "This is a test message";
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
diff --git a/tools/host/src/com/android/cts/HostConfig.java b/tools/host/src/com/android/cts/HostConfig.java
index 2051abd..fbea3a5 100644
--- a/tools/host/src/com/android/cts/HostConfig.java
+++ b/tools/host/src/com/android/cts/HostConfig.java
@@ -15,11 +15,6 @@
*/
package com.android.cts;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
@@ -40,6 +35,11 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
/**
* Holds CTS host configuration information, such as:
* <ul>
@@ -105,25 +105,6 @@
}
}
- enum Strings {
- // Phone number that will be used in tests if not available from the SIM card
- phoneNumber ("");
-
- private String value;
-
- Strings(String value) {
- this.value = value;
- }
-
- String value() {
- return value;
- }
-
- void setValue(String value) {
- this.value = value;
- }
- }
-
private final static HostConfig sInstance = new HostConfig();
private HostConfig() {
@@ -188,8 +169,7 @@
return false;
}
- loadIntConfigValues(doc);
- loadStringConfigValues(doc);
+ getConfigValues(doc);
String caseRoot = repositoryRoot + File.separator + caseCfg;
String planRoot = repositoryRoot + File.separator + planCfg;
@@ -380,35 +360,24 @@
return cfgStr;
}
- /** Load the integer configuration values from the config. */
- private void loadIntConfigValues(final Document doc) {
+ /**
+ * Load configuration values from config file.
+ *
+ * @param doc The document from which to load the values.
+ */
+ private void getConfigValues(final Document doc) {
NodeList intValues = doc.getElementsByTagName("IntValue");
for (int i = 0; i < intValues.getLength(); i++) {
- Node node = intValues.item(i);
- String name = getStringAttributeValue(node, "name");
- String value = getStringAttributeValue(node, "value");
+ Node n = intValues.item(i);
+ String name = getStringAttributeValue(n, "name");
+ String value = getStringAttributeValue(n, "value");
try {
- Integer intValue = Integer.parseInt(value);
- Ints.valueOf(name).setValue(intValue);
+ Integer v = Integer.parseInt(value);
+ Ints.valueOf(name).setValue(v);
} catch (NumberFormatException e) {
Log.e("Configuration error. Illegal value for " + name, e);
} catch (IllegalArgumentException e) {
- Log.e("Unknown int configuration value " + name, e);
- }
- }
- }
-
- /** Load the String configuration values from the config. */
- private void loadStringConfigValues(final Document doc) {
- NodeList stringValues = doc.getElementsByTagName("StringValue");
- for (int i = 0; i < stringValues.getLength(); i++) {
- Node node = stringValues.item(i);
- String name = getStringAttributeValue(node, "name");
- String value = getStringAttributeValue(node, "value");
- try {
- Strings.valueOf(name).setValue(value);
- } catch (IllegalArgumentException e) {
- Log.e("Unknown string configuration value " + name, e);
+ Log.e("Unknown configuration value " + name, e);
}
}
}
diff --git a/tools/host/src/com/android/cts/TestDevice.java b/tools/host/src/com/android/cts/TestDevice.java
index b8a0dc2..672ed37 100644
--- a/tools/host/src/com/android/cts/TestDevice.java
+++ b/tools/host/src/com/android/cts/TestDevice.java
@@ -16,7 +16,6 @@
package com.android.cts;
-import com.android.cts.HostConfig.Strings;
import com.android.ddmlib.AdbCommandRejectedException;
import com.android.ddmlib.Client;
import com.android.ddmlib.ClientData;
@@ -892,6 +891,7 @@
* @param test The test to be run.
*/
public void runTest(Test test) throws DeviceDisconnectedException {
+
final String appNameSpace = test.getAppNameSpace();
String runner = test.getInstrumentationRunner();
if (runner == null) {
@@ -903,7 +903,7 @@
final String testName = test.getFullName().replaceAll("\\$", "\\\\\\$");
final String commandStr = "am instrument -w -r -e class " + testName
- + getTestArguments() + " " + appNameSpace + "/" + runner;
+ + " " + appNameSpace + "/" + runner;
Log.d(commandStr);
executeShellCommand(commandStr, new IndividualModeResultParser(test));
}
@@ -928,8 +928,7 @@
name = javaPkgName;
}
- String cmdHeader = "am instrument -w -r -e package " + name + " "
- + getTestArguments() + " ";
+ String cmdHeader = "am instrument -w -r -e package " + name + " ";
final String commandStr = cmdHeader + appNameSpace + "/" + runner;
Log.d(commandStr);
@@ -937,8 +936,31 @@
executeShellCommand(commandStr, mBatchModeResultParser);
}
- private String getTestArguments() {
- return "-e phoneNumber " + Strings.phoneNumber.value();
+ /**
+ * Run a in batch mode of a TestPackage.
+ *
+ * @param testPackage The testPackage to be run.
+ * @param javaClassName The java class name.
+ */
+ public void runTestCaseInBatchMode(TestPackage testPackage, final String javaClassName,
+ String profile) throws DeviceDisconnectedException {
+ if (javaClassName == null) {
+ return;
+ }
+
+ String appNameSpace = testPackage.getAppNameSpace();
+ String runner = testPackage.getInstrumentationRunner();
+ if (runner == null) {
+ runner = DEFAULT_TEST_RUNNER_NAME;
+ }
+
+ String cmdHeader = "am instrument -w -r -e class " + javaClassName
+ + " -e profile " + profile + " ";
+ final String commandStr = cmdHeader + appNameSpace + "/" + runner;
+ Log.d(commandStr);
+
+ mBatchModeResultParser = new BatchModeResultParser(testPackage);
+ executeShellCommand(commandStr, mBatchModeResultParser);
}
/**
diff --git a/tools/utils/host_config.xml b/tools/utils/host_config.xml
index c84c093..661b1a3 100644
--- a/tools/utils/host_config.xml
+++ b/tools/utils/host_config.xml
@@ -42,7 +42,4 @@
<!-- Time to wait [ms] after a package installation or removal. -->
<IntValue name="postInstallWaitMs" value="10000" />
- <!-- Phone number that will be used in tests if not available from the SIM card. -->
- <StringValue name="phoneNumber" value="" />
-
</HostConfiguration>