Prevent monkey tests from toggling airplane mode
Bug 7449076
Monkey was sometimes toggling airplane mode via quick settings. Use a
full screen theme and deactivate some events to avoid this side effect.
Change-Id: Ie10dcc9bd3a0323a7db9336097573e53463b96d0
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
index 36dae9d..3930ea4 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
@@ -14,6 +14,11 @@
static final String[] PKGS = {"com.android.cts.monkey", "com.android.cts.monkey2"};
static final String[] APKS = {"CtsMonkeyApp.apk", "CtsMonkeyApp2.apk"};
+ /**
+ * Base monkey command with flags to avoid side effects like airplane mode.
+ */
+ static final String MONKEY_CMD = "monkey --pct-majornav 0 --pct-syskeys 0 --pct-anyevent 0";
+
CtsBuildHelper mBuild;
ITestDevice mDevice;
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
index 3932653..ff04f6c 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
@@ -19,25 +19,25 @@
public class CategoryTest extends AbstractMonkeyTest {
public void testDefaultCategories() throws Exception {
- String out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0] + " 5000");
+ String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0] + " 5000");
assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
}
public void testSingleCategory() throws Exception {
- String out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0]
+ String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
+ " -c android.intent.category.LAUNCHER 5000");
assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
assertFalse(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
- out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0]
+ out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
+ " -c android.intent.category.MONKEY 5000");
assertFalse(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
}
public void testMultipleCategories() throws Exception {
- String out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0]
+ String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
+ " -c android.intent.category.LAUNCHER"
+ " -c android.intent.category.MONKEY 5000");
assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
index f38b332..f141d8f 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
@@ -26,7 +26,7 @@
private static final String HUMAN = "(^_^)";
public void testIsMonkey() throws Exception {
- mDevice.executeShellCommand("monkey -p " + PKGS[0] + " 500");
+ mDevice.executeShellCommand(MONKEY_CMD + " -p " + PKGS[0] + " 500");
assertIsUserAMonkey(true);
}
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
index 3859f19..2e675e8 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
@@ -29,17 +29,17 @@
Pattern.MULTILINE);
public void testSinglePackage() throws Exception {
- String out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0] + " 5000");
+ String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0] + " 5000");
assertTrue(out, ALLOW_MONKEY.matcher(out).find());
assertFalse(out, ALLOW_CHIMP.matcher(out).find());
- out = mDevice.executeShellCommand("monkey -v -p " + PKGS[1] + " 5000");
+ out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[1] + " 5000");
assertFalse(out, ALLOW_MONKEY.matcher(out).find());
assertTrue(out, ALLOW_CHIMP.matcher(out).find());
}
public void testMultiplePackages() throws Exception {
- String out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0]
+ String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
+ " -p " + PKGS[1] + " 5000");
assertTrue(out, ALLOW_MONKEY.matcher(out).find());
assertTrue(out, ALLOW_CHIMP.matcher(out).find());
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java
index 4f8f842..a0016e2 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java
@@ -21,12 +21,12 @@
public class SeedTest extends AbstractMonkeyTest {
public void testSeed() throws Exception {
- String cmd1 = "monkey -s 1337 -v -p " + PKGS[0] + " 500";
+ String cmd1 = MONKEY_CMD + " -s 1337 -v -p " + PKGS[0] + " 500";
String out1 = mDevice.executeShellCommand(cmd1);
String out2 = mDevice.executeShellCommand(cmd1);
assertOutputs(out1, out2);
- String cmd2 = "monkey -s 3007 -v -p " + PKGS[0] + " 125";
+ String cmd2 = MONKEY_CMD + " -s 3007 -v -p " + PKGS[0] + " 125";
String out3 = mDevice.executeShellCommand(cmd2);
String out4 = mDevice.executeShellCommand(cmd2);
assertOutputs(out3, out4);
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/VerbosityTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/VerbosityTest.java
index 2956191..6688089 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/VerbosityTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/VerbosityTest.java
@@ -19,21 +19,21 @@
public class VerbosityTest extends AbstractMonkeyTest {
public void testVerbosity() throws Exception {
- String v0 = mDevice.executeShellCommand("monkey -s 1337 -p " + PKGS[0] + " 500");
+ String v0 = mDevice.executeShellCommand(MONKEY_CMD + " -s 1337 -p " + PKGS[0] + " 500");
assertTrue(v0.contains("Events injected"));
assertFalse(v0.contains("Sending Touch"));
assertFalse(v0.contains("Sending Trackball"));
assertFalse(v0.contains("Switch"));
assertFalse(v0.contains("Sleeping"));
- String v1 = mDevice.executeShellCommand("monkey -v -p " + PKGS[0] + " 500");
+ String v1 = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0] + " 500");
assertTrue(v1.contains("Events injected"));
assertTrue(v1.contains("Sending Touch"));
assertTrue(v1.contains("Sending Trackball"));
assertTrue(v1.contains("Switch"));
assertFalse(v1.contains("Sleeping"));
- String v2 = mDevice.executeShellCommand("monkey -v -v -p " + PKGS[0] + " 500");
+ String v2 = mDevice.executeShellCommand(MONKEY_CMD + " -v -v -p " + PKGS[0] + " 500");
assertTrue(v2.contains("Events injected"));
assertTrue(v2.contains("Sending Touch"));
assertTrue(v2.contains("Sending Trackball"));
diff --git a/hostsidetests/monkey/test-apps/CtsMonkeyApp/AndroidManifest.xml b/hostsidetests/monkey/test-apps/CtsMonkeyApp/AndroidManifest.xml
index 55f3d6f..a3dfc83 100644
--- a/hostsidetests/monkey/test-apps/CtsMonkeyApp/AndroidManifest.xml
+++ b/hostsidetests/monkey/test-apps/CtsMonkeyApp/AndroidManifest.xml
@@ -16,7 +16,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.monkey">
- <application>
+ <application android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name=".MonkeyActivity">
<intent-filter>
diff --git a/hostsidetests/monkey/test-apps/CtsMonkeyApp2/AndroidManifest.xml b/hostsidetests/monkey/test-apps/CtsMonkeyApp2/AndroidManifest.xml
index 34bca75..d08e231 100644
--- a/hostsidetests/monkey/test-apps/CtsMonkeyApp2/AndroidManifest.xml
+++ b/hostsidetests/monkey/test-apps/CtsMonkeyApp2/AndroidManifest.xml
@@ -16,7 +16,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.monkey2">
- <application>
+ <application android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name=".ChimpActivity">
<intent-filter>