Skip to content

Commit

Permalink
Apply test changes from oppia#2253
Browse files Browse the repository at this point in the history
  • Loading branch information
jcqli committed Dec 15, 2020
1 parent 7dd9fb0 commit b9b226b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex1_displaysRecentlyPlayedStoriesText() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(1)
)
Expand All @@ -260,6 +261,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex1_displaysViewAllText() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(1)
)
Expand All @@ -274,6 +276,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex1_clickViewAll_opensRecentlyPlayedActivity() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(1)
)
Expand Down Expand Up @@ -372,6 +375,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex3_topicSummary_topicNameIsCorrect() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(3)
)
Expand All @@ -386,6 +390,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex3_topicSummary_lessonCountIsCorrect() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(3)
)
Expand All @@ -405,6 +410,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex4_topicSummary_topicNameIsCorrect() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(4)
)
Expand All @@ -419,6 +425,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex4_topicSummary_lessonCountIsCorrect() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(4)
)
Expand All @@ -438,6 +445,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex4_topicSummary_configurationChange_lessonCountIsCorrect() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(4)
Expand All @@ -458,6 +466,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_recyclerViewIndex3_clickTopicSummary_opensTopicActivity() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(3)
)
Expand All @@ -470,6 +479,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_onBackPressed_showsExitToProfileChooserDialog() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
pressBack()
onView(withText(R.string.home_activity_back_dialog_message))
.inRoot(isDialog())
Expand All @@ -480,6 +490,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_onBackPressed_orientationChange_showsExitToProfileChooserDialog() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
pressBack()
onView(isRoot()).perform(orientationLandscape())
onView(withText(R.string.home_activity_back_dialog_message))
Expand All @@ -491,6 +502,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_onBackPressed_clickExit_checkOpensProfileActivity() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
pressBack()
onView(withText(R.string.home_activity_back_dialog_exit))
.inRoot(isDialog())
Expand All @@ -502,6 +514,7 @@ class HomeActivityTest {
@Test
fun testHomeActivity_checkSpanForItem0_spanSizeIsTwoOrThree() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
if (context.resources.getBoolean(R.bool.isTablet)) {
onView(withId(R.id.home_recycler_view)).check(hasGridItemCount(3, 0))
} else {
Expand All @@ -513,13 +526,15 @@ class HomeActivityTest {
@Test
fun testHomeActivity_checkSpanForItem4_spanSizeIsOne() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).check(hasGridItemCount(1, 4))
}
}

@Test
fun testHomeActivity_configurationChange_checkSpanForItem4_spanSizeIsOne() {
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.home_recycler_view)).check(hasGridItemCount(1, 4))
}
Expand Down

0 comments on commit b9b226b

Please sign in to comment.