启用“使用主机GPU”后,浓缩咖啡测试冻结



我进行了一系列Espresso测试,测试幻灯片菜单。当"使用主机GPU"处于启用状态时,大多数测试都会失败,但当它处于禁用状态时则不会失败。尽管我禁用了动画,但我想我可能在某个地方错过了一个设置,因为我仍然可以看到窗户滑开。我正在测试Android 4.4.2并使用HAXM。为什么这个测试失败了?

这里有一个测试的例子(它们都有相同的结构):

@SuppressWarnings("unchecked")
public void testClickOnItemDisplaysMyFragment() {
    openDrawer(DRAWER);
    onView(withId(DRAWER)).check(matches(isOpen()));
    onView(allOf(withId(DRAWER_ITEM), withText(MY_ITEM))).perform(click());
    onView(withId(DRAWER)).check(matches(isClosed()));
    Fragment fragment = fragmentManager.findFragmentById(FRAGMENT_LAYOUT);
    assertThat(fragment, is(notNullValue()));
    assertThat(fragment, is(instanceOf(MyFragment.class)));
    onView(withId(fragment.getId())).check(matches(isDisplayed()));
}

如果我在未选中"使用主机GPU"的情况下启动模拟器,测试会顺利通过。如果启用了"使用主机GPU",则第一个测试通过,然后其余测试失败:

com.google.android.apps.common.testing.ui.espresso.IdlingResourceTimeoutException: Wait for [IdlingDrawerListener] to become idle timed out
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:579)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:69)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:40)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:159)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.check(ViewInteraction.java:133)
at com.example.MainActivityTest.testClickOnItemDisplaysMyFragment(MainActivityTest.java:152)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:167)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)

我已经尝试禁用模拟器中的动画,如下所述:https://code.google.com/p/android-test-kit/wiki/Espresso#Getting_Started,但我仍然可以看到抽屉滑动打开和关闭。

这是一个已知的错误:https://code.google.com/p/android-test-kit/issues/detail?id=64

相关内容

  • 没有找到相关文章

最新更新