开发者

Android monkeyrunner test calls onClick handler twice

开发者 https://www.devze.com 2023-04-07 20:25 出处:网络
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 usin

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号