Android monkeyrunner test calls onClick handler twice
I am experiencing funny behavior of monkey. When app shows AlertDialog with two buttons, my onClick handler sometimes called twice. This does not happen when I press the button manually, only when using monkey.
Here is my activity code:
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "onResume");
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setPositiveButton("yes", this)
.setNegativeButton("no", this);
AlertDialog alert = builder.create();
alert.show();
}
@Override
public void onClick(DialogInterface pDialog, int pWhich) {
Log.d(TAG, "onClick " + pWhich);
pDialog.dismiss();
}
This is how I call monkey:
adb shell monkey -p com.mycompany.helloapp -v 500
And here is logcat output (irrelevant lines are skipped):
09-26 12:27:04.867 D/ClickTest(27989): onResume
09-26 12:27:07.557 D/ClickTest(27989): onClick -1
09-26 12:27:07.557 D/ClickTest(27989): onClick -1
Am I doing anything wrong or this is some sort of bug in android UI event handler the开发者_运维知识库t reproduces under high event load?
-Lev
精彩评论