スライド メニューをテストする一連の Espresso テストがあります。Use Host 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()));
}
Use Host GPU をチェックせずにエミュレーターを起動すると、テストは問題なくパスします。Use Host 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で説明されているように、エミュレーターでアニメーションを無効にしようとしましたが、引き出しがスライドして開閉するのを見ることができます。