diff --git a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromAboutTest.java b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromAboutTest.java index 6bb6ef32b..23f6ed770 100644 --- a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromAboutTest.java +++ b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromAboutTest.java @@ -19,6 +19,7 @@ package bbct.android.common.navigation.test; import android.support.test.espresso.Espresso; +import android.support.test.espresso.NoMatchingViewException; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; @@ -51,19 +52,20 @@ public void setUp() throws Exception { .getSupportFragmentManager().beginTransaction(); } - @Test - public void testNavigateToAboutFragment() { - openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); - - String aboutTitle = getInstrumentation().getTargetContext().getString(R.string.about_title); - Espresso.pressBack(); - - String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.bbct_title, aboutTitle); - onView(withText(expectedTitle)).check(matches(isDisplayed())); + private void skipSurvey() { + try { + onView(withText(R.string.survey1)).check(matches(isDisplayed())); + onView(withText(R.string.later)) + .check(matches(isDisplayed())) + .perform(click()); + } catch (NoMatchingViewException e) { + //view not displayed logic + } } @Test public void testNavigateBack() { + skipSurvey(); String initialTitle = (String) activityActivityTestRule.getActivity().getTitle(); openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); diff --git a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardDetailsTest.java b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardDetailsTest.java index cb3fec531..cad5f036b 100644 --- a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardDetailsTest.java +++ b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardDetailsTest.java @@ -19,6 +19,7 @@ package bbct.android.common.navigation.test; import android.support.test.espresso.Espresso; +import android.support.test.espresso.NoMatchingViewException; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; @@ -50,8 +51,20 @@ public void setUp() throws Exception { .getSupportFragmentManager().beginTransaction(); } + private void skipSurvey() { + try { + onView(withText(R.string.survey1)).check(matches(isDisplayed())); + onView(withText(R.string.later)) + .check(matches(isDisplayed())) + .perform(click()); + } catch (NoMatchingViewException e) { + //view not displayed logic + } + } + @Test public void testDefaultNavigateUpWithNoData() { + skipSurvey(); String cardDetailsTitle = getInstrumentation().getTargetContext().getString(R.string.card_details_title); String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.bbct_title, cardDetailsTitle); Espresso.closeSoftKeyboard(); diff --git a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardListTest.java b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardListTest.java index e0bc9057e..cbed0836d 100644 --- a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardListTest.java +++ b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardListTest.java @@ -19,6 +19,7 @@ package bbct.android.common.navigation.test; import android.support.test.espresso.Espresso; +import android.support.test.espresso.NoMatchingViewException; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; @@ -33,6 +34,7 @@ import static android.support.test.InstrumentationRegistry.getInstrumentation; import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withText; @@ -49,8 +51,20 @@ public void setUp() throws Exception { .getSupportFragmentManager().beginTransaction(); } + private void skipSurvey() { + try { + onView(withText(R.string.survey1)).check(matches(isDisplayed())); + onView(withText(R.string.later)) + .check(matches(isDisplayed())) + .perform(click()); + } catch (NoMatchingViewException e) { + //view not displayed logic + } + } + @Test public void testBackPress() { + skipSurvey(); String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.app_name); Espresso.closeSoftKeyboard(); Espresso.pressBack(); diff --git a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballFilterCardsTest.java b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballFilterCardsTest.java index a80321614..97dbb014d 100644 --- a/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballFilterCardsTest.java +++ b/android/src/androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballFilterCardsTest.java @@ -19,6 +19,7 @@ package bbct.android.common.navigation.test; import android.support.test.espresso.Espresso; +import android.support.test.espresso.NoMatchingViewException; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; @@ -33,6 +34,7 @@ import static android.support.test.InstrumentationRegistry.getInstrumentation; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; import static android.support.test.espresso.matcher.ViewMatchers.withText; @@ -49,10 +51,22 @@ public void setUp() throws Exception { .getSupportFragmentManager().beginTransaction(); } + private void skipSurvey() { + try { + onView(withText(R.string.survey1)).check(matches(isDisplayed())); + onView(withText(R.string.later)) + .check(matches(isDisplayed())) + .perform(click()); + } catch (NoMatchingViewException e) { + //view not displayed logic + } + } + @Test public void testNavigateUp() { - + skipSurvey(); String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.app_name); + Espresso.closeSoftKeyboard(); Espresso.pressBack(); onView(allOf(withContentDescription(R.string.filter_cards_title), isDisplayed())).perform(click()); Espresso.pressBack();