android - 启用使用主机 GPU 时 Espresso 测试卡住

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

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

最佳答案

关于android - 启用使用主机 GPU 时 Espresso 测试卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23092508/

相关文章:

android - 在 cordova android 中检查 GPS 状态(开/关)

android - "Hello, WebView"教程在Android浏览器中打开请求的地址而不是在我的webview中

cuda - 在 opencl 中 CPU 作为主机,intel HD 4000 作为设备 1,离散 GPU 作为设备 2

java - 使用 HttpURLConnection 添加自定义 header

android - 第二次执行surfaceCreated方法时Camera为null

java - 为什么ArrayList中必须保留一个Hashmap作为2行ListView的数据源

opencv - GPU中的Opencv特征检测

android - 禁止在 VirtualBox 中使用 Android 启动模拟器

java - 在 ListView 中显示数据库

python - 如何在 Python 中对 H2O 启用 GPU 加速?