【问题标题】:Espresso Test freezes when Use Host GPU is enabled启用使用主机 GPU 时,Espresso 测试冻结
【发布时间】:2014-05-30 07:49:59
【问题描述】:

我有一系列测试幻灯片菜单的 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,但我仍然可以看到抽屉滑动打开和关闭。

【问题讨论】:

  • 这也发生在我身上,但仅在 Windows 机器上 - 在 OSX 上它与 GPU 加速一起工作正常
  • 你解决了吗?

标签: android android-emulator gpu android-testing android-espresso


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-26
    • 2015-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-15
    • 2019-08-07
    相关资源
    最近更新 更多