use of com.google.android.apps.common.testing.testrunner.annotations.SdkSuppress in project double-espresso by JakeWharton.
the class KeyEventActionIntegrationTest method testClickOnBackFromFragment.
@SuppressWarnings("unchecked")
// uses native fragments.
@SdkSuppress(versions = { 7, 8, 10 }, bugId = -1)
@FlakyTest
public void testClickOnBackFromFragment() {
Intent fragmentStack = new Intent().setClassName(getInstrumentation().getTargetContext(), "com.google.android.apps.common.testing.ui.testapp.FragmentStack");
fragmentStack.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getInstrumentation().startActivitySync(fragmentStack);
onView(allOf(withParent(withId(R.id.simple_fragment)), isAssignableFrom(TextView.class))).check(matches(withText(containsString("#1"))));
try {
pressBack();
fail("Should have thrown NoActivityResumedException");
} catch (NoActivityResumedException expected) {
}
getInstrumentation().startActivitySync(fragmentStack);
onView(withId(R.id.new_fragment)).perform(click()).perform(click()).perform(click());
onView(allOf(withParent(withId(R.id.simple_fragment)), isAssignableFrom(TextView.class))).check(matches(withText(containsString("#4"))));
pressBack();
onView(allOf(withParent(withId(R.id.simple_fragment)), isAssignableFrom(TextView.class))).check(matches(withText(containsString("#3"))));
pressBack();
onView(allOf(withParent(withId(R.id.simple_fragment)), isAssignableFrom(TextView.class))).check(matches(withText(containsString("#2"))));
pressBack();
onView(allOf(withParent(withId(R.id.simple_fragment)), isAssignableFrom(TextView.class))).check(matches(withText(containsString("#1"))));
try {
pressBack();
fail("Should have thrown NoActivityResumedException");
} catch (NoActivityResumedException expected) {
}
}
Aggregations