diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt index 8458664151b..8784bf351fd 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt @@ -77,6 +77,15 @@ class MarkChaptersCompletedFragmentPresenter @Inject constructor( ) } } + } else if (binding.isAllChecked == true) { + binding.isAllChecked = false + viewModel.getItemList().forEach { viewModel -> + if (viewModel is ChapterSummaryViewModel) { + if (!viewModel.checkIfChapterIsCompleted()) { + chapterUnselected(viewModel.chapterIndex, viewModel.nextStoryIndex) + } + } + } } } diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt index cd98130c088..f6c98598418 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt @@ -63,8 +63,11 @@ class MarkStoriesCompletedFragmentPresenter @Inject constructor( } binding.markStoriesCompletedAllCheckBoxContainer.setOnClickListener { - if (binding.isAllChecked == null || binding.isAllChecked == false) + if (binding.isAllChecked == null || binding.isAllChecked == false) { binding.isAllChecked = true + } else if (binding.isAllChecked == true) { + binding.isAllChecked = false + } } binding.markStoriesCompletedAllCheckBox.setOnCheckedChangeListener { _, isChecked -> @@ -73,6 +76,10 @@ class MarkStoriesCompletedFragmentPresenter @Inject constructor( if (!viewModel.isCompleted) storySelected(viewModel.storySummary.storyId) } + } else { + viewModel.getStorySummaryMap().values.forEach { viewModel -> + if (!viewModel.isCompleted) storyUnselected(viewModel.storySummary.storyId) + } } bindingAdapter.notifyDataSetChanged() } diff --git a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt index 4c57fb63da8..6d80cb32dd3 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt @@ -63,8 +63,7 @@ class MarkTopicsCompletedFragmentPresenter @Inject constructor( } binding.markTopicsCompletedAllCheckBoxContainer.setOnClickListener { - if (binding.isAllChecked == null || binding.isAllChecked == false) - binding.isAllChecked = true + binding.isAllChecked = !(binding.isAllChecked ?: false) } binding.markTopicsCompletedAllCheckBox.setOnCheckedChangeListener { _, isChecked -> @@ -72,6 +71,10 @@ class MarkTopicsCompletedFragmentPresenter @Inject constructor( viewModel.getTopicList().forEach { viewModel -> if (!viewModel.isCompleted) topicSelected(viewModel.topic.topicId) } + } else { + viewModel.getTopicList().forEach { viewModel -> + if (!viewModel.isCompleted) topicUnselected(viewModel.topic.topicId) + } } bindingAdapter.notifyDataSetChanged() } diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt index 0fa6c4ad037..1f7c33104c9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt @@ -13,6 +13,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition import androidx.test.espresso.matcher.ViewMatchers.isChecked import androidx.test.espresso.matcher.ViewMatchers.isEnabled +import androidx.test.espresso.matcher.ViewMatchers.isNotChecked import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -160,31 +161,26 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 0, stringToMatch = "First Story", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 4) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 4, stringToMatch = "Other Interesting Story", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 6) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 6, stringToMatch = "Matthew Goes to the Bakery", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 9) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 9, stringToMatch = "Ratios: Part 1", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 12) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 12, stringToMatch = "Ratios: Part 2", @@ -200,31 +196,26 @@ class MarkChaptersCompletedFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 0) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 0, stringToMatch = "First Story", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 4) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 4, stringToMatch = "Other Interesting Story", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 6) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 6, stringToMatch = "Matthew Goes to the Bakery", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 9) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 9, stringToMatch = "Ratios: Part 1", targetViewId = R.id.mark_chapters_completed_story_name_text_view ) - scrollToPosition(position = 12) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 12, stringToMatch = "Ratios: Part 2", @@ -239,61 +230,51 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 1, stringToMatch = "Prototype Exploration", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 2) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 2, stringToMatch = "Image Region Selection Exploration", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 3) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 3, stringToMatch = "Math Expressions", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 5) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 5, stringToMatch = "Fifth Exploration", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 7) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 7, stringToMatch = "What is a Fraction?", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 8) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 8, stringToMatch = "The Meaning of Equal Parts", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 10) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 10, stringToMatch = "What is a Ratio?", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 11) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 11, stringToMatch = "Order is important", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 13) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 13, stringToMatch = "Equivalent Ratios", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 14) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 14, stringToMatch = "Writing Ratios in Simplest Form", @@ -309,61 +290,51 @@ class MarkChaptersCompletedFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 1) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 1, stringToMatch = "Prototype Exploration", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 2) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 2, stringToMatch = "Image Region Selection Exploration", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 3) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 3, stringToMatch = "Math Expressions", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 5) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 5, stringToMatch = "Fifth Exploration", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 7) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 7, stringToMatch = "What is a Fraction?", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 8) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 8, stringToMatch = "The Meaning of Equal Parts", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 10) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 10, stringToMatch = "What is a Ratio?", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 11) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 11, stringToMatch = "Order is important", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 13) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 13, stringToMatch = "Equivalent Ratios", targetViewId = R.id.mark_chapters_completed_chapter_check_box ) - scrollToPosition(position = 14) verifyItemTextOnRecyclerViewItemAtPosition( itemPosition = 14, stringToMatch = "Writing Ratios in Simplest Form", @@ -402,29 +373,44 @@ class MarkChaptersCompletedFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.mark_chapters_completed_all_check_box_container)).perform(click()) - scrollToPosition(position = 1) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 3) - scrollToPosition(position = 5) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 5) - scrollToPosition(position = 7) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 7) - scrollToPosition(position = 8) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 8) - scrollToPosition(position = 10) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 10) - scrollToPosition(position = 11) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 11) - scrollToPosition(position = 13) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 13) - scrollToPosition(position = 14) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 14) } } + @Test + fun testMarkChaptersCompletedFragment_deselectAllChapters_deselectsAllChapters() { + launch( + createMarkChaptersCompletedTestActivityIntent(internalProfileId) + ).use { + testCoroutineDispatchers.runCurrent() + // Click one to select all chapters. + onView(withId(R.id.mark_chapters_completed_all_check_box_container)).perform(click()) + // Click a second time to unselect all chapters. + onView(withId(R.id.mark_chapters_completed_all_check_box_container)).perform(click()) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 1) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 2) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 3) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 5) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 7) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 8) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 10) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 11) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 13) + verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition = 14) + testCoroutineDispatchers.runCurrent() + onView(withId(R.id.mark_chapters_completed_all_check_box)).check(matches(not(isChecked()))) + } + } + @Test fun testMarkChaptersCompletedFragment_selectAll_configChange_selectsAllChapters() { launch( @@ -433,25 +419,15 @@ class MarkChaptersCompletedFragmentTest { testCoroutineDispatchers.runCurrent() onView(withId(R.id.mark_chapters_completed_all_check_box_container)).perform(click()) onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 1) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 3) - scrollToPosition(position = 5) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 5) - scrollToPosition(position = 7) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 7) - scrollToPosition(position = 8) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 8) - scrollToPosition(position = 10) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 10) - scrollToPosition(position = 11) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 11) - scrollToPosition(position = 13) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 13) - scrollToPosition(position = 14) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 14) } } @@ -462,10 +438,8 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 2) } @@ -477,14 +451,10 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 1) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition = 2) } } @@ -546,13 +516,9 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) onView( atPositionOnView( recyclerViewId = R.id.mark_chapters_completed_recycler_view, @@ -569,14 +535,10 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 2) onView( atPositionOnView( recyclerViewId = R.id.mark_chapters_completed_recycler_view, @@ -593,25 +555,15 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 3) - scrollToPosition(position = 5) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 5) - scrollToPosition(position = 7) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 7) - scrollToPosition(position = 8) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 8) - scrollToPosition(position = 10) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 10) - scrollToPosition(position = 11) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 11) - scrollToPosition(position = 13) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 13) - scrollToPosition(position = 14) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 14) onView(withId(R.id.mark_chapters_completed_all_check_box)).check(matches(isChecked())) } @@ -623,25 +575,15 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 3) - scrollToPosition(position = 5) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 5) - scrollToPosition(position = 7) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 7) - scrollToPosition(position = 8) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 8) - scrollToPosition(position = 10) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 10) - scrollToPosition(position = 11) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 11) - scrollToPosition(position = 13) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 13) - scrollToPosition(position = 14) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 14) onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.mark_chapters_completed_all_check_box)).check(matches(isChecked())) @@ -654,27 +596,16 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 3) - scrollToPosition(position = 5) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 5) - scrollToPosition(position = 7) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 7) - scrollToPosition(position = 8) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 8) - scrollToPosition(position = 10) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 10) - scrollToPosition(position = 11) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 11) - scrollToPosition(position = 13) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 13) - scrollToPosition(position = 14) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 14) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) onView(withId(R.id.mark_chapters_completed_all_check_box)).check(matches(not(isChecked()))) } @@ -686,27 +617,16 @@ class MarkChaptersCompletedFragmentTest { createMarkChaptersCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 1) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 3) - scrollToPosition(position = 5) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 5) - scrollToPosition(position = 7) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 7) - scrollToPosition(position = 8) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 8) - scrollToPosition(position = 10) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 10) - scrollToPosition(position = 11) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 11) - scrollToPosition(position = 13) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 13) - scrollToPosition(position = 14) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 14) - scrollToPosition(position = 2) performItemCheckOnRecyclerViewItemAtPosition(itemPosition = 2) onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.mark_chapters_completed_all_check_box)).check(matches(not(isChecked()))) @@ -842,6 +762,7 @@ class MarkChaptersCompletedFragmentTest { stringToMatch: String, targetViewId: Int ) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_chapters_completed_recycler_view, @@ -852,6 +773,7 @@ class MarkChaptersCompletedFragmentTest { } private fun performItemCheckOnRecyclerViewItemAtPosition(itemPosition: Int) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_chapters_completed_recycler_view, @@ -862,6 +784,7 @@ class MarkChaptersCompletedFragmentTest { } private fun verifyItemCheckedOnRecyclerViewItemAtPosition(itemPosition: Int) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_chapters_completed_recycler_view, @@ -871,6 +794,17 @@ class MarkChaptersCompletedFragmentTest { ).check(matches(isChecked())) } + private fun verifyItemUncheckedOnRecyclerViewItemAtPosition(itemPosition: Int) { + scrollToPosition(position = itemPosition) + onView( + atPositionOnView( + recyclerViewId = R.id.mark_chapters_completed_recycler_view, + position = itemPosition, + targetViewId = R.id.mark_chapters_completed_chapter_check_box + ) + ).check(matches(isNotChecked())) + } + private fun markFractionsFirstChapterCompleted() { storyProgressTestHelper.markCompletedFractionsStory0Exp0( profileId, diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt index 1930bf670fa..5920dd4b644 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt @@ -13,6 +13,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition import androidx.test.espresso.matcher.ViewMatchers.isChecked import androidx.test.espresso.matcher.ViewMatchers.isEnabled +import androidx.test.espresso.matcher.ViewMatchers.isNotChecked import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -160,27 +161,22 @@ class MarkStoriesCompletedFragmentTest { createMarkStoriesCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 0, stringToMatch = "First Story" ) - scrollToPosition(position = 1) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 1, stringToMatch = "Other Interesting Story" ) - scrollToPosition(position = 2) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 2, stringToMatch = "Matthew Goes to the Bakery" ) - scrollToPosition(position = 3) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 3, stringToMatch = "Ratios: Part 1" ) - scrollToPosition(position = 4) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 4, stringToMatch = "Ratios: Part 2" @@ -195,27 +191,22 @@ class MarkStoriesCompletedFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 0) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 0, stringToMatch = "First Story" ) - scrollToPosition(position = 1) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 1, stringToMatch = "Other Interesting Story" ) - scrollToPosition(position = 2) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 2, stringToMatch = "Matthew Goes to the Bakery" ) - scrollToPosition(position = 3) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 3, stringToMatch = "Ratios: Part 1" ) - scrollToPosition(position = 4) verifyStoryNameOnStorySummaryListItemAtPosition( itemPosition = 4, stringToMatch = "Ratios: Part 2" @@ -253,19 +244,33 @@ class MarkStoriesCompletedFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.mark_stories_completed_all_check_box_container)).perform(click()) - scrollToPosition(position = 0) verifyItemCheckedOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) verifyItemCheckedOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) verifyItemCheckedOnStorySummaryListItem(itemPosition = 4) } } + @Test + fun testMarkStoriesCompletedFragment_deselectAllStories_deselectsAllStories() { + launch( + createMarkStoriesCompletedTestActivityIntent(internalProfileId) + ).use { + testCoroutineDispatchers.runCurrent() + // Click one to select all stories. + onView(withId(R.id.mark_stories_completed_all_check_box_container)).perform(click()) + // Click a second time to unselect all stories. + onView(withId(R.id.mark_stories_completed_all_check_box_container)).perform(click()) + verifyItemUncheckedOnStorySummaryListItem(itemPosition = 0) + verifyItemUncheckedOnStorySummaryListItem(itemPosition = 1) + verifyItemUncheckedOnStorySummaryListItem(itemPosition = 2) + verifyItemUncheckedOnStorySummaryListItem(itemPosition = 3) + verifyItemUncheckedOnStorySummaryListItem(itemPosition = 4) + onView(withId(R.id.mark_stories_completed_all_check_box)).check(matches(not(isChecked()))) + } + } + @Test fun testMarkStoriesCompletedFragment_selectAll_configChange_selectsAllStories() { launch( @@ -274,15 +279,10 @@ class MarkStoriesCompletedFragmentTest { testCoroutineDispatchers.runCurrent() onView(withId(R.id.mark_stories_completed_all_check_box_container)).perform(click()) onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 0) verifyItemCheckedOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) verifyItemCheckedOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) verifyItemCheckedOnStorySummaryListItem(itemPosition = 4) } } @@ -293,25 +293,15 @@ class MarkStoriesCompletedFragmentTest { createMarkStoriesCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) performItemCheckOnStorySummaryListItem(itemPosition = 4) - scrollToPosition(position = 0) verifyItemCheckedOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) verifyItemCheckedOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) verifyItemCheckedOnStorySummaryListItem(itemPosition = 4) } } @@ -322,26 +312,16 @@ class MarkStoriesCompletedFragmentTest { createMarkStoriesCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) performItemCheckOnStorySummaryListItem(itemPosition = 4) onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 0) verifyItemCheckedOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) verifyItemCheckedOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) verifyItemCheckedOnStorySummaryListItem(itemPosition = 4) } } @@ -352,15 +332,10 @@ class MarkStoriesCompletedFragmentTest { createMarkStoriesCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) performItemCheckOnStorySummaryListItem(itemPosition = 4) onView(withId(R.id.mark_stories_completed_all_check_box)).check(matches(isChecked())) } @@ -372,15 +347,10 @@ class MarkStoriesCompletedFragmentTest { createMarkStoriesCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) performItemCheckOnStorySummaryListItem(itemPosition = 4) onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.mark_stories_completed_all_check_box)).check(matches(isChecked())) @@ -393,17 +363,11 @@ class MarkStoriesCompletedFragmentTest { createMarkStoriesCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) performItemCheckOnStorySummaryListItem(itemPosition = 4) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) onView(withId(R.id.mark_stories_completed_all_check_box)).check(matches(not(isChecked()))) } @@ -415,17 +379,11 @@ class MarkStoriesCompletedFragmentTest { createMarkStoriesCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnStorySummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnStorySummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnStorySummaryListItem(itemPosition = 3) - scrollToPosition(position = 4) performItemCheckOnStorySummaryListItem(itemPosition = 4) - scrollToPosition(position = 2) performItemCheckOnStorySummaryListItem(itemPosition = 2) onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.mark_stories_completed_all_check_box)).check(matches(not(isChecked()))) @@ -519,6 +477,7 @@ class MarkStoriesCompletedFragmentTest { itemPosition: Int, stringToMatch: String ) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_stories_completed_recycler_view, @@ -529,6 +488,7 @@ class MarkStoriesCompletedFragmentTest { } private fun verifyItemCheckedOnStorySummaryListItem(itemPosition: Int) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_stories_completed_recycler_view, @@ -538,7 +498,19 @@ class MarkStoriesCompletedFragmentTest { ).check(matches(isChecked())) } + private fun verifyItemUncheckedOnStorySummaryListItem(itemPosition: Int) { + scrollToPosition(position = itemPosition) + onView( + atPositionOnView( + recyclerViewId = R.id.mark_stories_completed_recycler_view, + position = itemPosition, + targetViewId = R.id.mark_stories_completed_story_check_box + ) + ).check(matches(isNotChecked())) + } + private fun performItemCheckOnStorySummaryListItem(itemPosition: Int) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_stories_completed_recycler_view, diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt index 19958dadc77..6f59f6f57b3 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt @@ -13,6 +13,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition import androidx.test.espresso.matcher.ViewMatchers.isChecked import androidx.test.espresso.matcher.ViewMatchers.isEnabled +import androidx.test.espresso.matcher.ViewMatchers.isNotChecked import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -160,22 +161,18 @@ class MarkTopicsCompletedFragmentTest { createMarkTopicsCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 0, stringToMatch = "First Test Topic" ) - scrollToPosition(position = 1) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 1, stringToMatch = "Second Test Topic" ) - scrollToPosition(position = 2) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 2, stringToMatch = "Fractions" ) - scrollToPosition(position = 3) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 3, stringToMatch = "Ratios and Proportional Reasoning" @@ -190,22 +187,18 @@ class MarkTopicsCompletedFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 0) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 0, stringToMatch = "First Test Topic" ) - scrollToPosition(position = 1) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 1, stringToMatch = "Second Test Topic" ) - scrollToPosition(position = 2) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 2, stringToMatch = "Fractions" ) - scrollToPosition(position = 3) verifyTopicNameOnTopicSummaryListItemAtPosition( itemPosition = 3, stringToMatch = "Ratios and Proportional Reasoning" @@ -243,13 +236,9 @@ class MarkTopicsCompletedFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.mark_topics_completed_all_check_box_container)).perform(click()) - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) } } @@ -262,13 +251,9 @@ class MarkTopicsCompletedFragmentTest { testCoroutineDispatchers.runCurrent() onView(withId(R.id.mark_topics_completed_all_check_box_container)).perform(click()) onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) } } @@ -279,21 +264,13 @@ class MarkTopicsCompletedFragmentTest { createMarkTopicsCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) - scrollToPosition(position = 0) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 3) } } @@ -304,22 +281,14 @@ class MarkTopicsCompletedFragmentTest { createMarkTopicsCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) onView(isRoot()).perform(orientationLandscape()) - scrollToPosition(position = 0) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) verifyItemCheckedOnTopicSummaryListItem(itemPosition = 3) } } @@ -330,31 +299,41 @@ class MarkTopicsCompletedFragmentTest { createMarkTopicsCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) onView(withId(R.id.mark_topics_completed_all_check_box)).check(matches(isChecked())) } } + @Test + fun testMarkTopicsCompletedFragment_deselectAllTopics_deselectsAllTopics() { + launch( + createMarkTopicsCompletedTestActivityIntent(internalProfileId) + ).use { + testCoroutineDispatchers.runCurrent() + // Click one to select all topics. + onView(withId(R.id.mark_topics_completed_all_check_box_container)).perform(click()) + // Click a second time to unselect all topics. + onView(withId(R.id.mark_topics_completed_all_check_box_container)).perform(click()) + verifyItemUncheckedOnTopicSummaryListItem(itemPosition = 0) + verifyItemUncheckedOnTopicSummaryListItem(itemPosition = 1) + verifyItemUncheckedOnTopicSummaryListItem(itemPosition = 2) + verifyItemUncheckedOnTopicSummaryListItem(itemPosition = 3) + onView(withId(R.id.mark_topics_completed_all_check_box)).check(matches(not(isChecked()))) + } + } + @Test fun testMarkTopicsCompletedFragment_selectAllTopics_configChange_allCheckBoxIsChecked() { launch( createMarkTopicsCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.mark_topics_completed_all_check_box)).check(matches(isChecked())) @@ -367,15 +346,10 @@ class MarkTopicsCompletedFragmentTest { createMarkTopicsCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) onView(withId(R.id.mark_topics_completed_all_check_box)).check(matches(not(isChecked()))) } @@ -387,15 +361,10 @@ class MarkTopicsCompletedFragmentTest { createMarkTopicsCompletedTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) performItemCheckOnTopicSummaryListItem(itemPosition = 0) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) - scrollToPosition(position = 2) performItemCheckOnTopicSummaryListItem(itemPosition = 2) - scrollToPosition(position = 3) performItemCheckOnTopicSummaryListItem(itemPosition = 3) - scrollToPosition(position = 1) performItemCheckOnTopicSummaryListItem(itemPosition = 1) onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.mark_topics_completed_all_check_box)).check(matches(not(isChecked()))) @@ -489,6 +458,7 @@ class MarkTopicsCompletedFragmentTest { itemPosition: Int, stringToMatch: String ) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_topics_completed_recycler_view, @@ -499,6 +469,7 @@ class MarkTopicsCompletedFragmentTest { } private fun verifyItemCheckedOnTopicSummaryListItem(itemPosition: Int) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_topics_completed_recycler_view, @@ -508,7 +479,19 @@ class MarkTopicsCompletedFragmentTest { ).check(matches(isChecked())) } + private fun verifyItemUncheckedOnTopicSummaryListItem(itemPosition: Int) { + scrollToPosition(position = itemPosition) + onView( + atPositionOnView( + recyclerViewId = R.id.mark_topics_completed_recycler_view, + position = itemPosition, + targetViewId = R.id.mark_topics_completed_topic_check_box + ) + ).check(matches(isNotChecked())) + } + private fun performItemCheckOnTopicSummaryListItem(itemPosition: Int) { + scrollToPosition(position = itemPosition) onView( atPositionOnView( recyclerViewId = R.id.mark_topics_completed_recycler_view,