summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Dandiga <vijayd@codeaurora.org>2013-02-21 18:37:18 +0530
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:23:55 -0700
commit95cc81c8e340d90c35c43cfd82478d18052cde35 (patch)
treeff51d2855ddcee45806133f9f9256bb6c87292be
parentb212eb32a64d435a8b37e002376039c8ea7104e9 (diff)
downloadandroid_development-95cc81c8e340d90c35c43cfd82478d18052cde35.tar.gz
android_development-95cc81c8e340d90c35c43cfd82478d18052cde35.tar.bz2
android_development-95cc81c8e340d90c35c43cfd82478d18052cde35.zip
Monkey: New option to add delay after activity switch event.
Add new command line option to set delay after each activity switch event. Change-Id: I425ebf31772961d375200f69e4ff5fe67e2d3c24
-rw-r--r--cmds/monkey/src/com/android/commands/monkey/Monkey.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
index 4953242af..afedb5c3f 100644
--- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java
+++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
@@ -226,6 +226,9 @@ public class Monkey {
/** Device idle time. This is for the scripted monkey. **/
long mDeviceSleepTime = 30000;
+ /** The delay after App switch event. **/
+ long mAppSwitchDelay = 0;
+
boolean mRandomizeScript = false;
boolean mScriptLog = false;
@@ -851,6 +854,8 @@ public class Monkey {
} else if (opt.equals("--periodic-bugreport")){
mGetPeriodicBugreport = true;
mBugreportFrequency = nextOptionLong("Number of iterations");
+ } else if (opt.equals("--delay-appswitch")) {
+ mAppSwitchDelay = nextOptionLong("Delay(in ms) after app switch event");
} else if (opt.equals("-h")) {
showUsage();
return false;
@@ -1165,6 +1170,19 @@ public class Monkey {
MonkeyEvent ev = mEventSource.getNextEvent();
if (ev != null) {
int injectCode = ev.injectEvent(mWm, mAm, mVerbose);
+
+ if ((mAppSwitchDelay > 0) && (ev instanceof MonkeyActivityEvent)) {
+ if (mVerbose > 0) {
+ System.out.println("After App switch about to sleep "
+ + mAppSwitchDelay + " ms");
+ }
+ try {
+ Thread.sleep(mAppSwitchDelay);
+ } catch (InterruptedException e1) {
+ System.out.println("** Monkey interrupted in sleep after App switch.");
+ }
+ }
+
if (injectCode == MonkeyEvent.INJECT_FAIL) {
System.out.println(" // Injection Failed");
if (ev instanceof MonkeyKeyEvent) {
@@ -1382,6 +1400,7 @@ public class Monkey {
usage.append(" [--script-log]\n");
usage.append(" [--bugreport]\n");
usage.append(" [--periodic-bugreport]\n");
+ usage.append(" [--delay-appswitch MILLISEC]\n");
usage.append(" COUNT\n");
System.err.println(usage.toString());
}