aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Torres Milano <dtmilano@gmail.com>2012-06-05 15:43:47 -0400
committerandroid code review <noreply-gerritcodereview@google.com>2012-08-03 17:53:20 -0700
commit565d857070f4c5c0ed7cbfa6aa70dbdd8d0f0399 (patch)
treec7c81d6716acb08e7433bc8fb2a26bafab6a3daf
parent35328a2e52070f64911b2930ca292b114094747f (diff)
downloadsdk-565d857070f4c5c0ed7cbfa6aa70dbdd8d0f0399.zip
sdk-565d857070f4c5c0ed7cbfa6aa70dbdd8d0f0399.tar.gz
sdk-565d857070f4c5c0ed7cbfa6aa70dbdd8d0f0399.tar.bz2
Fix instrument ignoring extra arguments
Extra arguments passed to instrument are silently ignored. This could lead to some confusion when instrument is invoked with extra arguments that are expected to alter the instrumentation being run. A common use case for this is when 'instrument' is invoked from monkeyrunner to run all the tests in one class: device.instrument(pkg, { 'class':'com.example.test.MyTests' }) without this patch, the previous method will run all the tests in pkg. Change-Id: I908d49422fe2755a1bcf562c2d040651b9691a6a
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java b/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
index d4513d1..7c4b62a 100644
--- a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
+++ b/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
@@ -481,7 +481,17 @@ public class AdbChimpDevice implements IChimpDevice {
@Override
public Map<String, Object> instrument(String packageName, Map<String, Object> args) {
- List<String> shellCmd = Lists.newArrayList("am", "instrument", "-w", "-r", packageName);
+ List<String> shellCmd = Lists.newArrayList("am", "instrument", "-w", "-r");
+ for (Entry<String, Object> entry: args.entrySet()) {
+ final String key = entry.getKey();
+ final Object value = entry.getValue();
+ if (key != null && value != null) {
+ shellCmd.add("-e");
+ shellCmd.add(key);
+ shellCmd.add(value.toString());
+ }
+ }
+ shellCmd.add(packageName);
String result = shell(shellCmd.toArray(ZERO_LENGTH_STRING_ARRAY));
return convertInstrumentResult(result);
}