1

当我打电话给 Robotium 时:

solo.clickOnMenuItem("Sync");

有时我会得到著名的错误跟踪:

09-19 22:27:23.647: ERROR/WindowManager(20662): android.view.WindowLeaked: Activity test.com.activities.ListActivity 泄露了窗口 com.android.internal.policy.impl.PhoneWindow$DecorView@461d4660最初添加在这里 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: 错误/WindowManager(20662): 在 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: 错误/WindowManager(20662): 在测试中。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: 错误/WindowManager(20662): 在 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: 错误/WindowManager(20662): 在 android.view.View$PerformClick.run(View.java:8818) 09-19 22:27:23.647: 错误/WindowManager(20662) : 在 android.os.Handler.handleCallback(Handler.java:587) 09-19 22:27:23.647: 错误/WindowManager(20662): 在 android.os.Handler.dispatchMessage(Handler.java:92) 09-19 22:27:23.647:错误/WindowManager(20662):在android.os.Looper.loop(Looper.java:143)09-19 22:27:23.647:错误/WindowManager(20662):在 android.app.ActivityThread.main(ActivityThread.java:4701) 09-19 22:27:23.647:错误/WindowManager(20662):在 java.lang.reflect.Method.invokeNative(Native方法) 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) : 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-19 22:27:23.647: 错误/WindowManager(20662): 在 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) :致命例外:主要 09-19 22:27:24.209:错误/AndroidRuntime(20662):java.lang.IllegalArgumentException:视图未附加到窗口管理器 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): 在 android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 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:错误/AndroidRuntime(20662):在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): 在 android.os.AsyncTask.access$300(AsyncTask.java:127) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java :429) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 android.os.Handler.dispatchMessage(Handler.java:99) 09-19 22:27:24.209: 错误/AndroidRuntime(20662):在 android.os.Looper.loop(Looper.java:143) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 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):在 java.lang.reflect.Method.invoke(Method.java:521)09-19 22:27:24.209:错误/AndroidRuntime(20662):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller。运行(ZygoteInit.java:860)09-19 22:27:24.209:错误/AndroidRuntime(20662):在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)09-19 22:27: 24.209:错误/AndroidRuntime(20662):在 dalvik.system.NativeStart.main(本机方法)521) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-19 22:27:24.209: 错误/ AndroidRuntime(20662): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 dalvik.system.NativeStart.main(Native方法)521) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-19 22:27:24.209: 错误/ AndroidRuntime(20662): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 09-19 22:27:24.209: 错误/AndroidRuntime(20662): 在 dalvik.system.NativeStart.main(Native方法)

但是,如果我像这样本地调用(菜单项是第三个):

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

无论我运行多少次测试,我都没有收到任何错误。为什么我会出现这种行为?

4

0 回答 0