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 #2132: Chapter List Page Issues #2232

Merged
merged 18 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
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 @@ -28,6 +28,7 @@ class StoryChapterSummaryViewModel(
val name: String = chapterSummary.name
val summary: String = chapterSummary.summary
val chapterThumbnail: LessonThumbnail = chapterSummary.chapterThumbnail
val missingPrerequisiteChapter: ChapterSummary = chapterSummary.missingPrerequisiteChapter

fun onExplorationClicked() {
explorationDataController.stopPlayingExploration()
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/layout-land/story_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:maxLines="3"
android:text="@{htmlContent}"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : @string/chapter_prerequisite_title_label(viewModel.index, viewModel.missingPrerequisiteChapter.name)}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/layout-sw600dp/story_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:maxLines="4"
android:text="@{htmlContent}"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : @string/chapter_prerequisite_title_label(viewModel.index, viewModel.missingPrerequisiteChapter.name)}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/layout/story_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:maxLines="4"
android:text="@{htmlContent}"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : @string/chapter_prerequisite_title_label(viewModel.index, viewModel.missingPrerequisiteChapter.name)}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@

<dimen name="story_chapter_card_playable_state_elevation">4dp</dimen>
<dimen name="ongoing_topic_card_elevation">4dp</dimen>
<dimen name="story_chapter_card_not_playable_state_elevation">0dp</dimen>
<dimen name="story_chapter_card_not_playable_state_elevation">2dp</dimen>
<dimen name="profile_chooser_padding_bottom_profile_already_added">224dp</dimen>

<dimen name="continue_item_exploration_split_view_margin_top">72dp</dimen>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<string name="topic_play_chapter_index">%s.</string>
<string name="chapter_name">Chapter %s: %s</string>
<string name="chapter_completed">Chapter %s: %s is completed.</string>
<string name="chapter_prerequisite_title_label">Complete Chapter %s: %s to unlock this chapter.</string>
<string name="text_input_default_content_description">Enter text.</string>
<string name="fractions_default_hint_text">Enter a fraction in the form x/x, or a mixed number in the form x x/x.</string>
<string name="fractions_default_hint_text_no_integer">Enter a fraction in the form x/x.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.domain.topic.StoryProgressTestHelper
import org.oppia.android.domain.topic.TEST_STORY_ID_1
import org.oppia.android.domain.topic.TEST_TOPIC_ID_1
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
Expand Down Expand Up @@ -117,10 +119,6 @@ class StoryFragmentTest {
profileTestHelper.initializeProfiles()
FirebaseApp.initializeApp(context)
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build()
storyProgressTestHelper.markPartialStoryProgressForFractions(
profileId,
timestampOlderThanAWeek = false
)
testCoroutineDispatchers.runCurrent()
}

Expand All @@ -130,26 +128,17 @@ class StoryFragmentTest {
Intents.release()
}

private fun createStoryActivityIntent(): Intent {
return StoryActivity.createStoryActivityIntent(
ApplicationProvider.getApplicationContext(),
internalProfileId,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0
)
}

@Test
fun testStoryFragment_clickOnToolbarNavigationButton_closeActivity() {
activityTestRule.launchActivity(createStoryActivityIntent())
activityTestRule.launchActivity(createFractionsStoryActivityIntent())
testCoroutineDispatchers.runCurrent()
onView(withContentDescription(R.string.go_to_previous_page)).perform(click())
assertThat(activityTestRule.activity.isFinishing).isTrue()
}

@Test
fun testStoryFragment_toolbarTitle_isDisplayedSuccessfully() {
launch<StoryActivity>(createStoryActivityIntent()).use {
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.story_toolbar_title))
.check(matches(withText("Matthew Goes to the Bakery")))
Expand All @@ -158,7 +147,8 @@ class StoryFragmentTest {

@Test
fun testStoryFragment_correctStoryCountLoadedInHeader() {
launch<StoryActivity>(createStoryActivityIntent()).use {
setStoryPartialProgressForFractions()
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
val headerString: String =
getResources().getQuantityString(R.plurals.story_total_chapters, 2, 1, 2)
Expand All @@ -183,23 +173,29 @@ class StoryFragmentTest {

@Test
fun testStoryFragment_correctNumberOfStoriesLoadedInRecyclerView() {
launch<StoryActivity>(createStoryActivityIntent()).use {
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.story_chapter_list)).check(hasItemCount(3))
}
}

@Test
fun testStoryFragment_changeConfiguration_textViewIsShownCorrectly() {
launch<StoryActivity>(createStoryActivityIntent()).use {
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(atPositionOnView(R.id.story_chapter_list, 1, R.id.chapter_title)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_title
)
).check(
matches(
withText("Chapter 1: What is a Fraction?")
)
Expand All @@ -209,14 +205,20 @@ class StoryFragmentTest {

@Test
fun testStoryFragment_chapterSummaryIsShownCorrectly() {
launch<StoryActivity>(createStoryActivityIntent()).use {
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(atPositionOnView(R.id.story_chapter_list, 1, R.id.chapter_summary)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText("This is outline/summary for What is a Fraction?")
)
Expand All @@ -226,25 +228,133 @@ class StoryFragmentTest {

@Test
fun testStoryFragment_changeConfiguration_chapterSummaryIsShownCorrectly() {
launch<StoryActivity>(createStoryActivityIntent()).use {
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(atPositionOnView(R.id.story_chapter_list, 1, R.id.chapter_summary)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText("This is outline/summary for What is a Fraction?")
)
)
}
}

@Test
fun testStoryFragment_chapterLongSummaryIsShownCorrectly() {
launch<StoryActivity>(createTestStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText(
"This is outline/summary for Second Exploration. It is very long but " +
"it has to be fully visible. You wil be learning about oppia app in Second Story. " +
"Learn about oppia app via testing in second exploration."
)
)
)
}
}

@Test
fun testStoryFragment_changeConfiguration_chapterLongSummaryIsShownCorrectly() {
launch<StoryActivity>(createTestStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText(
"This is outline/summary for Second Exploration. It is very long but " +
"it has to be fully visible. You wil be learning about oppia app in Second Story. " +
"Learn about oppia app via testing in second exploration."
)
)
)
}
}

@Test
fun testStoryFragment_chapterMissingPrerequisiteIsShownCorrectly() {
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
2
)
)
onView(
atPositionOnView(
R.id.story_chapter_list,
2,
R.id.chapter_summary
)
).check(
matches(
withText("Complete Chapter 1: What is a Fraction? to unlock this chapter.")
)
)
}
}

@Test
fun testStoryFragment_changeConfiguration_chapterMissingPrerequisiteIsShownCorrectly() {
anandwana001 marked this conversation as resolved.
Show resolved Hide resolved
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
2
)
)
onView(
atPositionOnView(
R.id.story_chapter_list,
2,
R.id.chapter_summary
)
).check(
matches(
withText("Complete Chapter 1: What is a Fraction? to unlock this chapter.")
)
)
}
}

@Test
fun testStoryFragment_changeConfiguration_explorationStartCorrectly() {
launch<StoryActivity>(createStoryActivityIntent()).use {
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(allOf(withId(R.id.story_chapter_list))).perform(
Expand All @@ -262,7 +372,8 @@ class StoryFragmentTest {

@Test
fun testStoryFragment_changeConfiguration_correctStoryCountInHeader() {
launch<StoryActivity>(createStoryActivityIntent()).use {
setStoryPartialProgressForFractions()
launch<StoryActivity>(createFractionsStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
val headerString: String =
Expand Down Expand Up @@ -291,6 +402,31 @@ class StoryFragmentTest {
}
}

private fun createFractionsStoryActivityIntent(): Intent {
return StoryActivity.createStoryActivityIntent(
ApplicationProvider.getApplicationContext(),
internalProfileId,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0
)
}

private fun createTestStoryActivityIntent(): Intent {
return StoryActivity.createStoryActivityIntent(
ApplicationProvider.getApplicationContext(),
internalProfileId,
TEST_TOPIC_ID_1,
TEST_STORY_ID_1
)
}

private fun setStoryPartialProgressForFractions() {
storyProgressTestHelper.markPartialStoryProgressForFractions(
profileId,
timestampOlderThanAWeek = false
)
}

private fun setUpTestApplicationComponent() {
ApplicationProvider.getApplicationContext<TestApplication>().inject(this)
}
Expand Down
2 changes: 1 addition & 1 deletion domain/src/main/assets/test_story_id_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"objective": "Learn about oppia app via testing in second exploration.",
"id": "test_exp_id_1"
},
"outline": "",
"outline": "This is outline/summary for Second Exploration. It is very long but it has to be fully visible. You wil be learning about oppia app in Second Story. Learn about oppia app via testing in second exploration.",
"title": "Second Exploration",
"acquired_skill_ids": []
},
Expand Down
Loading