Skip to content

Commit

Permalink
Proof that pre-setup works in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat Talesra committed Feb 26, 2021
1 parent 9d77057 commit d9fd298
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withParent
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Component
import org.hamcrest.Matchers.allOf
Expand All @@ -29,6 +30,7 @@ import org.hamcrest.Matchers.instanceOf
import org.hamcrest.Matchers.not
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.R
Expand Down Expand Up @@ -117,6 +119,10 @@ class RecentlyPlayedFragmentTest {

private lateinit var profileId: ProfileId

@get:Rule
val activityScenarioRule: ActivityScenarioRule<RecentlyPlayedActivity> =
ActivityScenarioRule(createRecentlyPlayedActivityIntent(internalProfileId))

@Before
fun setUp() {
Intents.init()
Expand All @@ -139,7 +145,7 @@ class RecentlyPlayedFragmentTest {

private fun createRecentlyPlayedActivityIntent(profileId: Int): Intent {
return RecentlyPlayedActivity.createRecentlyPlayedActivityIntent(
context,
ApplicationProvider.getApplicationContext(),
profileId
)
}
Expand Down Expand Up @@ -185,23 +191,17 @@ class RecentlyPlayedFragmentTest {
profileId,
timestampOlderThanOneWeek = true
)
ActivityScenario.launch<RecentlyPlayedActivity>(
createRecentlyPlayedActivityIntent(
internalProfileId
)
).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.ongoing_story_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(
0
)
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.ongoing_story_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(
0
)
onView(
atPositionOnView(R.id.ongoing_story_recycler_view, 0, R.id.divider_view)
).check(
matches(not(isDisplayed()))
)
}
)
onView(
atPositionOnView(R.id.ongoing_story_recycler_view, 0, R.id.divider_view)
).check(
matches(not(isDisplayed()))
)
}

@Test
Expand Down

0 comments on commit d9fd298

Please sign in to comment.