Search in sources :

Example 1 with SdkSuppress

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) {
    }
}
Also used : NoActivityResumedException(com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException) Intent(android.content.Intent) TextView(android.widget.TextView) FlakyTest(android.test.FlakyTest) SdkSuppress(com.google.android.apps.common.testing.testrunner.annotations.SdkSuppress)

Aggregations

Intent (android.content.Intent)1 FlakyTest (android.test.FlakyTest)1 TextView (android.widget.TextView)1 SdkSuppress (com.google.android.apps.common.testing.testrunner.annotations.SdkSuppress)1 NoActivityResumedException (com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException)1