Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #2417: Fix ignored test in HomeActivityTest #2416

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.containsString
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.R
Expand Down Expand Up @@ -145,12 +144,12 @@ class HomeActivityTest {
}

@Test
@Ignore(
"This test case is incorrect as it depends on internalProfileId " +
"which is not guaranteed to be 0 for admin."
)
fun testHomeActivity_recyclerViewIndex0_withProfileId0_displayProfileName_profileNameDisplayedSuccessfully() { // ktlint-disable max-line-length
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
fun testHomeActivity_withAdminProfile_profileNameDisplayedSuccessfully() {
launch<HomeActivity>(createHomeActivityIntent(0)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(0)
)
onView(
atPositionOnView(
R.id.home_recycler_view,
Expand All @@ -162,28 +161,27 @@ class HomeActivityTest {
}

@Test
fun testHomeActivity_recyclerViewIndex0_displayGreetingMessageBasedOnTime_goodMorningMessageDisplayedSuccessful() { // ktlint-disable max-line-length
getApplicationDependencies()
oppiaClock.setCurrentTimeMs(MORNING_TIMESTAMP)
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
fun testHomeActivity_withAdminProfile_configChange_profileNameDisplayedSuccessfully() {
launch<HomeActivity>(createHomeActivityIntent(0)).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(0)
)
onView(
atPositionOnView(
R.id.home_recycler_view,
0,
R.id.welcome_text_view
R.id.profile_name_textview
)
).check(matches(withText("Good morning,")))
).check(matches(withText("Admin!")))
}
}

@Test
fun testHomeActivity_recyclerViewIndex0_displayGreetingMessageBasedOnTime_goodAfternoonMessageDisplayedSuccessful() { // ktlint-disable max-line-length
fun testHomeActivity_recyclerViewIndex0_displayGreetingMessageBasedOnTime_goodMorningMessageDisplayedSuccessful() { // ktlint-disable max-line-length
getApplicationDependencies()
oppiaClock.setCurrentTimeMs(AFTERNOON_TIMESTAMP)
oppiaClock.setCurrentTimeMs(MORNING_TIMESTAMP)
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
Expand All @@ -195,14 +193,14 @@ class HomeActivityTest {
0,
R.id.welcome_text_view
)
).check(matches(withText("Good afternoon,")))
).check(matches(withText("Good morning,")))
}
}

@Test
fun testHomeActivity_recyclerViewIndex0_displayGreetingMessageBasedOnTime_goodEveningMessageDisplayedSuccessful() { // ktlint-disable max-line-length
fun testHomeActivity_recyclerViewIndex0_displayGreetingMessageBasedOnTime_goodAfternoonMessageDisplayedSuccessful() { // ktlint-disable max-line-length
getApplicationDependencies()
oppiaClock.setCurrentTimeMs(EVENING_TIMESTAMP)
oppiaClock.setCurrentTimeMs(AFTERNOON_TIMESTAMP)
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.home_recycler_view)).perform(
Expand All @@ -214,25 +212,26 @@ class HomeActivityTest {
0,
R.id.welcome_text_view
)
).check(matches(withText("Good evening,")))
).check(matches(withText("Good afternoon,")))
}
}

@Test
fun testHomeActivity_recyclerViewIndex0_configurationChange_displaysWelcomeMessageCorrectly() {
launch<HomeActivity>(createHomeActivityIntent(0)).use {
fun testHomeActivity_recyclerViewIndex0_displayGreetingMessageBasedOnTime_goodEveningMessageDisplayedSuccessful() { // ktlint-disable max-line-length
getApplicationDependencies()
oppiaClock.setCurrentTimeMs(EVENING_TIMESTAMP)
launch<HomeActivity>(createHomeActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.home_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(0)
)
onView(
atPositionOnView(
R.id.home_recycler_view,
0,
R.id.profile_name_textview
R.id.welcome_text_view
)
).check(matches(withText("Admin!")))
).check(matches(withText("Good evening,")))
}
}

Expand Down