diff options
author | Liam Mark <lmark@codeaurora.org> | 2013-07-10 11:36:12 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2014-11-04 08:23:57 -0700 |
commit | fe855b29b57be8f938c9e1fc37dbc10d7cf7f1bb (patch) | |
tree | fadc402e53e23d2287d28c3dee32082d3e8f88d7 | |
parent | 95cc81c8e340d90c35c43cfd82478d18052cde35 (diff) | |
download | android_development-fe855b29b57be8f938c9e1fc37dbc10d7cf7f1bb.tar.gz android_development-fe855b29b57be8f938c9e1fc37dbc10d7cf7f1bb.tar.bz2 android_development-fe855b29b57be8f938c9e1fc37dbc10d7cf7f1bb.zip |
Monkey: Add option to limit run based on launches
Add new command line option to set a maximum number
of activity launches after which Monkey will stop.
Change-Id: I702f3bd1081f3cf1a3383dd90c11da4578856418
-rw-r--r-- | cmds/monkey/src/com/android/commands/monkey/Monkey.java | 18 |
1 files changed, 18 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 afedb5c3f..1adfb4d74 100644 --- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java +++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java @@ -209,6 +209,9 @@ public class Monkey { /** The random number generator **/ Random mRandom = null; + /** Quit after the maximum number of activity launches is reached **/ + long mMaxActivityLaunches = -1; + /** Dropped-event statistics **/ long mDroppedKeyEvents = 0; @@ -847,6 +850,8 @@ public class Monkey { "(in milliseconds)"); } else if (opt.equals("--randomize-script")) { mRandomizeScript = true; + } else if (opt.equals("--max-activity-launches")) { + mMaxActivityLaunches = nextOptionLong("max activity launches"); } else if (opt.equals("--script-log")) { mScriptLog = true; } else if (opt.equals("--bugreport")) { @@ -1073,6 +1078,7 @@ public class Monkey { private int runMonkeyCycles() { int eventCounter = 0; int cycleCounter = 0; + int numActivityLaunches = 0; boolean shouldReportAnrTraces = false; boolean shouldReportDumpsysMemInfo = false; @@ -1169,6 +1175,18 @@ public class Monkey { MonkeyEvent ev = mEventSource.getNextEvent(); if (ev != null) { + if ((mMaxActivityLaunches > -1) && (ev instanceof MonkeyActivityEvent)) { + if (numActivityLaunches >= mMaxActivityLaunches) { + if (mVerbose > 0) { + System.out.println("Exit Monkey," + + " reached max number of activity launches:" + + numActivityLaunches); + return eventCounter; + } + } + numActivityLaunches++; + } + int injectCode = ev.injectEvent(mWm, mAm, mVerbose); if ((mAppSwitchDelay > 0) && (ev instanceof MonkeyActivityEvent)) { |