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:
@@ -136,6 +136,17 @@ public class Monkey {
|
||||
*/
|
||||
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 */
|
||||
private String mReportProcessName;
|
||||
|
||||
@@ -337,9 +348,8 @@ public class Monkey {
|
||||
synchronized (Monkey.this) {
|
||||
mAbort = true;
|
||||
}
|
||||
return (mKillProcessAfterError) ? -1 : 0;
|
||||
}
|
||||
return 0;
|
||||
return (mKillProcessAfterError) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,6 +628,10 @@ public class Monkey {
|
||||
reportDumpsysMemInfo();
|
||||
mRequestDumpsysMemInfo = false;
|
||||
}
|
||||
if (mRequestPeriodicBugreport){
|
||||
getBugreport("Bugreport_");
|
||||
mRequestPeriodicBugreport = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mGenerateHprof) {
|
||||
@@ -762,6 +776,9 @@ public class Monkey {
|
||||
mScriptLog = true;
|
||||
} else if (opt.equals("--bugreport")) {
|
||||
mRequestBugreport = true;
|
||||
} else if (opt.equals("--periodic-bugreport")){
|
||||
mGetPeriodicBugreport = true;
|
||||
mBugreportFrequency = nextOptionLong("Number of iterations");
|
||||
} else if (opt.equals("-h")) {
|
||||
showUsage();
|
||||
return false;
|
||||
@@ -993,6 +1010,10 @@ public class Monkey {
|
||||
getBugreport("app_crash" + mReportProcessName + "_");
|
||||
mRequestAppCrashBugreport = false;
|
||||
}
|
||||
if (mRequestPeriodicBugreport){
|
||||
getBugreport("Bugreport_");
|
||||
mRequestPeriodicBugreport = false;
|
||||
}
|
||||
if (mRequestDumpsysMemInfo) {
|
||||
mRequestDumpsysMemInfo = false;
|
||||
shouldReportDumpsysMemInfo = true;
|
||||
@@ -1082,6 +1103,12 @@ public class Monkey {
|
||||
if (!mCountEvents) {
|
||||
cycleCounter++;
|
||||
writeScriptLog(cycleCounter);
|
||||
//Capture the bugreport after n iteration
|
||||
if (mGetPeriodicBugreport) {
|
||||
if ((cycleCounter % mBugreportFrequency) == 0) {
|
||||
mRequestPeriodicBugreport = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Event Source has signaled that we have no more events to process
|
||||
break;
|
||||
@@ -1259,6 +1286,7 @@ public class Monkey {
|
||||
usage.append(" [--randomize-script]\n");
|
||||
usage.append(" [--script-log]\n");
|
||||
usage.append(" [--bugreport]\n");
|
||||
usage.append(" [--periodic-bugreport]\n");
|
||||
usage.append(" COUNT\n");
|
||||
System.err.println(usage.toString());
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
||||
|
||||
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
|
||||
private static final String STARTING_DATA_LINE = "start data >>";
|
||||
|
||||
@@ -308,6 +310,34 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
||||
.addPointer(0, x, y, 1, 5);
|
||||
mQ.addLast(e1);
|
||||
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) {
|
||||
System.err.println("// " + e.toString());
|
||||
|
||||
Reference in New Issue
Block a user