-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jojo Narte
authored and
Jojo Narte
committed
May 16, 2018
1 parent
5632385
commit 3a06166
Showing
6 changed files
with
284 additions
and
5 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
.../androidTest/java/bbct/android/common/navigation/test/NavigateBackPressFromAboutTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* This file is part of BBCT for Android. | ||
* | ||
* Copyright 2018 codeguru <[email protected]> | ||
* | ||
* BBCT for Android is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* BBCT for Android is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package bbct.android.common.navigation.test; | ||
|
||
import android.support.test.espresso.Espresso; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import bbct.android.common.R; | ||
import bbct.android.lite.provider.LiteActivity; | ||
|
||
import static android.support.test.InstrumentationRegistry.getInstrumentation; | ||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; | ||
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; | ||
import static org.hamcrest.Matchers.allOf; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class NavigateBackPressFromAboutTest { | ||
@Rule | ||
public ActivityTestRule<LiteActivity> activityActivityTestRule = new ActivityTestRule<LiteActivity>(LiteActivity.class); | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
activityActivityTestRule.getActivity() | ||
.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())); | ||
} | ||
|
||
@Test | ||
public void testNavigateBack() { | ||
String initialTitle = (String) activityActivityTestRule.getActivity().getTitle(); | ||
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); | ||
|
||
String aboutTitle = getInstrumentation().getTargetContext().getString(R.string.about_title); | ||
|
||
onView(allOf(withText(aboutTitle), isDisplayed())).perform(click()); | ||
String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.bbct_title, aboutTitle); | ||
onView(withText(expectedTitle)).check(matches(isDisplayed())); | ||
|
||
Espresso.closeSoftKeyboard(); | ||
Espresso.pressBack(); | ||
onView(withText(initialTitle)).check(matches(isDisplayed())); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...ava/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardDetailsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This file is part of BBCT for Android. | ||
* | ||
* Copyright 2018 codeguru <[email protected]> | ||
* | ||
* BBCT for Android is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* BBCT for Android is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package bbct.android.common.navigation.test; | ||
|
||
import android.support.test.espresso.Espresso; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import bbct.android.common.R; | ||
import bbct.android.lite.provider.LiteActivity; | ||
|
||
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; | ||
import static org.hamcrest.Matchers.allOf; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class NavigateBackPressFromBaseballCardDetailsTest { | ||
@Rule | ||
public ActivityTestRule<LiteActivity> activityActivityTestRule = new ActivityTestRule<LiteActivity>(LiteActivity.class); | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
activityActivityTestRule.getActivity() | ||
.getSupportFragmentManager().beginTransaction(); | ||
} | ||
|
||
@Test | ||
public void testDefaultNavigateUpWithNoData() { | ||
String cardDetailsTitle = getInstrumentation().getTargetContext().getString(R.string.card_details_title); | ||
String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.bbct_title, cardDetailsTitle); | ||
Espresso.closeSoftKeyboard(); | ||
onView(withText(expectedTitle)).check(matches(isDisplayed())); | ||
Espresso.pressBack(); | ||
onView(withText(R.string.app_name)).check(matches(isDisplayed())); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...t/java/bbct/android/common/navigation/test/NavigateBackPressFromBaseballCardListTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* This file is part of BBCT for Android. | ||
* | ||
* Copyright 2018 codeguru <[email protected]> | ||
* | ||
* BBCT for Android is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* BBCT for Android is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package bbct.android.common.navigation.test; | ||
|
||
import android.support.test.espresso.Espresso; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
|
||
import bbct.android.common.R; | ||
import bbct.android.lite.provider.LiteActivity; | ||
|
||
import static android.support.test.InstrumentationRegistry.getInstrumentation; | ||
import static android.support.test.espresso.Espresso.onView; | ||
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; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class NavigateBackPressFromBaseballCardListTest { | ||
@Rule | ||
public ActivityTestRule<LiteActivity> activityActivityTestRule = new ActivityTestRule<LiteActivity>(LiteActivity.class); | ||
|
||
|
||
@Before | ||
public void setUp() throws Exception { | ||
activityActivityTestRule.getActivity() | ||
.getSupportFragmentManager().beginTransaction(); | ||
} | ||
|
||
@Test | ||
public void testBackPress() { | ||
String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.app_name); | ||
Espresso.closeSoftKeyboard(); | ||
Espresso.pressBack(); | ||
onView(withText(expectedTitle)).check(matches(isDisplayed())); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...ava/bbct/android/common/navigation/test/NavigateBackPressFromBaseballFilterCardsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This file is part of BBCT for Android. | ||
* | ||
* Copyright 2018 codeguru <[email protected]> | ||
* | ||
* BBCT for Android is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* BBCT for Android is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package bbct.android.common.navigation.test; | ||
|
||
import android.support.test.espresso.Espresso; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import bbct.android.common.R; | ||
import bbct.android.lite.provider.LiteActivity; | ||
|
||
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.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.Matchers.allOf; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class NavigateBackPressFromBaseballFilterCardsTest { | ||
@Rule | ||
public ActivityTestRule<LiteActivity> activityActivityTestRule = new ActivityTestRule<LiteActivity>(LiteActivity.class); | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
activityActivityTestRule.getActivity() | ||
.getSupportFragmentManager().beginTransaction(); | ||
} | ||
|
||
@Test | ||
public void testNavigateUp() { | ||
|
||
String expectedTitle = getInstrumentation().getTargetContext().getString(R.string.app_name); | ||
Espresso.pressBack(); | ||
onView(allOf(withContentDescription(R.string.filter_cards_title), isDisplayed())).perform(click()); | ||
Espresso.pressBack(); | ||
onView(allOf(withText(expectedTitle), isDisplayed())); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters