开发者

Problem with Robotium.clickOnMenuItem()

开发者 https://www.devze.com 2023-04-05 20:14 出处:网络
When I make this call to Robotium: solo.clickOnMenuItem(\"Sync\"); sometimes I get the famous error trace:

When I make this call to Robotium:

solo.clickOnMenuItem("Sync");

sometimes I get the famous error trace:

09-19 22:27:23.647: ERROR/WindowManager(20662): android.view.WindowLeaked: Activity test.com.activities.ListActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@461d4660 that was originally added here 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.view.ViewRoot.(ViewRoot.java:253) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.view.Window$LocalWindowManager.addView(Window.java:424) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.app.Dialog.show(Dialog.java:241) 09-19 22:27:23.647: ERROR/WindowManager(20662): at test.com.activities.ListActivity$Sincronizacao.onPreExecute(ListActivity.java:272) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.os.AsyncTask.execute(AsyncTask.java:391) 09-19 22:27:23.开发者_如何学编程647: ERROR/WindowManager(20662): at test.com.activities.ListActivity.onOptionsItemSelected(ListActivity.java:224) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.app.Activity.onOptionsItemSelected(Activity.java:2313) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.app.Activity.onMenuItemSelected(Activity.java:2201) 09-19 22:27:23.647: ERROR/WindowManager(20662): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:740) 09-19 22:27:23.647: ERROR/WindowManager(20662): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143) 09-19 22:27:23.647: ERROR/WindowManager(20662): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855) 09-19 22:27:23.647: ERROR/WindowManager(20662): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:538) 09-19 22:27:23.647: ERROR/WindowManager(20662): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:142) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.view.View$PerformClick.run(View.java:8818) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.os.Handler.handleCallback(Handler.java:587) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.os.Handler.dispatchMessage(Handler.java:92) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.os.Looper.loop(Looper.java:143) 09-19 22:27:23.647: ERROR/WindowManager(20662): at android.app.ActivityThread.main(ActivityThread.java:4701) 09-19 22:27:23.647: ERROR/WindowManager(20662): at java.lang.reflect.Method.invokeNative(Native Method) 09-19 22:27:23.647: ERROR/WindowManager(20662): at java.lang.reflect.Method.invoke(Method.java:521) 09-19 22:27:23.647: ERROR/WindowManager(20662): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-19 22:27:23.647: ERROR/WindowManager(20662): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 09-19 22:27:23.647: ERROR/WindowManager(20662): at dalvik.system.NativeStart.main(Native Method) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): FATAL EXCEPTION: main 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): java.lang.IllegalArgumentException: View not attached to window manager 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.view.Window$LocalWindowManager.removeView(Window.java:432) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.app.Dialog.dismissDialog(Dialog.java:278) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.app.Dialog.access$000(Dialog.java:71) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.app.Dialog$1.run(Dialog.java:111) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.app.Dialog.dismiss(Dialog.java:268) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.app.Dialog.cancel(Dialog.java:951) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at test.com.activities.ListActivity$Sincronizacao.onPostExecute(ListActivity.java:331) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.os.AsyncTask.finish(AsyncTask.java:417) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.os.AsyncTask.access$300(AsyncTask.java:127) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.os.Handler.dispatchMessage(Handler.java:99) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.os.Looper.loop(Looper.java:143) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at android.app.ActivityThread.main(ActivityThread.java:4701) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at java.lang.reflect.Method.invokeNative(Native Method) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at java.lang.reflect.Method.invoke(Method.java:521) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 09-19 22:27:24.209: ERROR/AndroidRuntime(20662): at dalvik.system.NativeStart.main(Native Method)

But if I make the call natively like this (the menuitem is the third one):

mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_RIGHT);
mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_RIGHT);
mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_ENTER);

I don't get any errors no matter how many times I run the test. Why I'm getting that behaviour?

0

精彩评论

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