Added the periodic bugreport option for the Auotmated profile test.

Added the press and hold keyword in the scripted monkey.
Bug#3426961

Change-Id: I18f84520ef37c9b5cb300f62df3540d0d774c62b
This commit is contained in:
Yu Shan Emily Lau
2011-02-07 20:36:26 -08:00
parent 15e889b5e0
commit ebbef932a7
2 changed files with 60 additions and 2 deletions

View File

@@ -136,6 +136,17 @@ public class Monkey {
*/ */
private boolean mRequestAppCrashBugreport = false; private boolean mRequestAppCrashBugreport = false;
/**Request the bugreport based on the mBugreportFrequency. */
private boolean mGetPeriodicBugreport = true;
/**
* Request the bugreport based on the mBugreportFrequency.
*/
private boolean mRequestPeriodicBugreport = false;
/** Bugreport frequency. */
private long mBugreportFrequency = 10;
/** Failure process name */ /** Failure process name */
private String mReportProcessName; private String mReportProcessName;
@@ -337,9 +348,8 @@ public class Monkey {
synchronized (Monkey.this) { synchronized (Monkey.this) {
mAbort = true; mAbort = true;
} }
return (mKillProcessAfterError) ? -1 : 0;
} }
return 0; return (mKillProcessAfterError) ? -1 : 1;
} }
} }
@@ -618,6 +628,10 @@ public class Monkey {
reportDumpsysMemInfo(); reportDumpsysMemInfo();
mRequestDumpsysMemInfo = false; mRequestDumpsysMemInfo = false;
} }
if (mRequestPeriodicBugreport){
getBugreport("Bugreport_");
mRequestPeriodicBugreport = false;
}
} }
if (mGenerateHprof) { if (mGenerateHprof) {
@@ -762,6 +776,9 @@ public class Monkey {
mScriptLog = true; mScriptLog = true;
} else if (opt.equals("--bugreport")) { } else if (opt.equals("--bugreport")) {
mRequestBugreport = true; mRequestBugreport = true;
} else if (opt.equals("--periodic-bugreport")){
mGetPeriodicBugreport = true;
mBugreportFrequency = nextOptionLong("Number of iterations");
} else if (opt.equals("-h")) { } else if (opt.equals("-h")) {
showUsage(); showUsage();
return false; return false;
@@ -993,6 +1010,10 @@ public class Monkey {
getBugreport("app_crash" + mReportProcessName + "_"); getBugreport("app_crash" + mReportProcessName + "_");
mRequestAppCrashBugreport = false; mRequestAppCrashBugreport = false;
} }
if (mRequestPeriodicBugreport){
getBugreport("Bugreport_");
mRequestPeriodicBugreport = false;
}
if (mRequestDumpsysMemInfo) { if (mRequestDumpsysMemInfo) {
mRequestDumpsysMemInfo = false; mRequestDumpsysMemInfo = false;
shouldReportDumpsysMemInfo = true; shouldReportDumpsysMemInfo = true;
@@ -1082,6 +1103,12 @@ public class Monkey {
if (!mCountEvents) { if (!mCountEvents) {
cycleCounter++; cycleCounter++;
writeScriptLog(cycleCounter); writeScriptLog(cycleCounter);
//Capture the bugreport after n iteration
if (mGetPeriodicBugreport) {
if ((cycleCounter % mBugreportFrequency) == 0) {
mRequestPeriodicBugreport = true;
}
}
} else { } else {
// Event Source has signaled that we have no more events to process // Event Source has signaled that we have no more events to process
break; break;
@@ -1259,6 +1286,7 @@ public class Monkey {
usage.append(" [--randomize-script]\n"); usage.append(" [--randomize-script]\n");
usage.append(" [--script-log]\n"); usage.append(" [--script-log]\n");
usage.append(" [--bugreport]\n"); usage.append(" [--bugreport]\n");
usage.append(" [--periodic-bugreport]\n");
usage.append(" COUNT\n"); usage.append(" COUNT\n");
System.err.println(usage.toString()); System.err.println(usage.toString());
} }

View File

@@ -113,6 +113,8 @@ public class MonkeySourceScript implements MonkeyEventSource {
private static final String EVENT_KEYWORD_INPUT_STRING = "DispatchString"; private static final String EVENT_KEYWORD_INPUT_STRING = "DispatchString";
private static final String EVENT_KEYWORD_PRESSANDHOLD = "PressAndHold";
// a line at the end of the header // a line at the end of the header
private static final String STARTING_DATA_LINE = "start data >>"; private static final String STARTING_DATA_LINE = "start data >>";
@@ -308,6 +310,34 @@ public class MonkeySourceScript implements MonkeyEventSource {
.addPointer(0, x, y, 1, 5); .addPointer(0, x, y, 1, 5);
mQ.addLast(e1); mQ.addLast(e1);
mQ.addLast(e2); mQ.addLast(e2);
} catch (NumberFormatException e) {
System.err.println("// " + e.toString());
}
return;
}
//Handle the press and hold
if ((s.indexOf(EVENT_KEYWORD_PRESSANDHOLD) >= 0) && args.length == 3) {
try {
float x = Float.parseFloat(args[0]);
float y = Float.parseFloat(args[1]);
long pressDuration = Long.parseLong(args[2]);
// Set the default parameters
long downTime = SystemClock.uptimeMillis();
MonkeyMotionEvent e1 = new MonkeyTouchEvent(MotionEvent.ACTION_DOWN)
.setDownTime(downTime)
.setEventTime(downTime)
.addPointer(0, x, y, 1, 5);
MonkeyWaitEvent e2 = new MonkeyWaitEvent(pressDuration);
MonkeyMotionEvent e3 = new MonkeyTouchEvent(MotionEvent.ACTION_UP)
.setDownTime(downTime + pressDuration)
.setEventTime(downTime + pressDuration)
.addPointer(0, x, y, 1, 5);
mQ.addLast(e1);
mQ.addLast(e2);
mQ.addLast(e2);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
System.err.println("// " + e.toString()); System.err.println("// " + e.toString());