gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 02:57:09 24 4
gpt4 key购买 nike

我有一系列测试幻灯片菜单的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com