From d021afd5796aed4445f2f349c6a86a0af1e1b30d Mon Sep 17 00:00:00 2001 From: "Mr. 17" Date: Fri, 8 Dec 2023 05:00:38 +0530 Subject: [PATCH] Fix part of #2480: Fixes 2 Audio Tests (#5245) ## Explanation Fixes part of #2480 - Fixes `testAudioWifi_ratioExp_audioIcon_audioFragHasDefaultLangAndAutoPlays()` by checking default language at the end and testing audio icons in a better way. - Fixes `testAudioWifi_ratioExp_continueInteraction_audioButton_submitAns_feedbackAudioPlays()` by scrolling to the _**continue_interaction_button**_ before performing click on it , as it was positioned at the lower end of the recycler view. ## Essential Checklist - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing --------- Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> --- .../exploration/ExplorationActivityTest.kt | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt index 9e33f7d9948..18acf05d0c9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt @@ -1077,17 +1077,10 @@ class ExplorationActivityTest { explorationDataController.stopPlayingExploration(isCompletion = false) } - // TODO(#89): The ExplorationActivity takes time to finish. This test case is failing currently. @Test - @Ignore("The ExplorationActivity takes time to finish, needs to fixed in #89.") fun testAudioWifi_ratioExp_audioIcon_audioFragHasDefaultLangAndAutoPlays() { - getApplicationDependencies( - internalProfileId, - RATIOS_TOPIC_ID, - RATIOS_STORY_ID_0, - RATIOS_EXPLORATION_ID_0 - ) - networkConnectionUtil.setCurrentConnectionStatus(ProdConnectionStatus.LOCAL) + markAllSpotlightsSeen() + setUpAudio() launch( createExplorationActivityIntent( internalProfileId, @@ -1097,23 +1090,28 @@ class ExplorationActivityTest { shouldSavePartialProgress = false ) ).use { - waitForTheView(withText("What is a Ratio?")) - onView(withId(R.id.action_audio_player)).perform(click()) - onView( - allOf( - withId(R.id.play_pause_audio_icon), - withEffectiveVisibility(Visibility.VISIBLE) - ) + explorationDataController.startPlayingNewExploration( + internalProfileId, + RATIOS_TOPIC_ID, + RATIOS_STORY_ID_0, + RATIOS_EXPLORATION_ID_0 ) - onView(allOf(withId(R.id.audio_language_icon), withEffectiveVisibility(Visibility.VISIBLE))) + networkConnectionUtil.setCurrentConnectionStatus(ProdConnectionStatus.LOCAL) + testCoroutineDispatchers.runCurrent() + onView(withId(R.id.action_audio_player)).perform(click()) + + testCoroutineDispatchers.runCurrent() + onView(withId(R.id.audio_bar_container)).check(matches(isDisplayed())) + onView(withId(R.id.audio_fragment_voiceover_progressbar)).check(matches(isDisplayed())) + waitForTheView(withDrawable(R.drawable.ic_pause_circle_filled_white_24dp)) onView(withId(R.id.play_pause_audio_icon)).check( matches( - withDrawable( - R.drawable.ic_pause_circle_filled_white_24dp - ) + withDrawable(R.drawable.ic_pause_circle_filled_white_24dp) ) ) + + onView(withText("What is a Ratio?")).check(matches(isDisplayed())) } explorationDataController.stopPlayingExploration(isCompletion = false) } @@ -1179,17 +1177,11 @@ class ExplorationActivityTest { explorationDataController.stopPlayingExploration(isCompletion = false) } - // TODO(#89): The ExplorationActivity takes time to finish. This test case is failing currently. @Test - @Ignore("The ExplorationActivity takes time to finish, needs to fixed in #89.") + @RunOn(TestPlatform.ESPRESSO) fun testAudioWifi_ratioExp_continueInteraction_audioButton_submitAns_feedbackAudioPlays() { - getApplicationDependencies( - internalProfileId, - RATIOS_TOPIC_ID, - RATIOS_STORY_ID_0, - RATIOS_EXPLORATION_ID_0 - ) - networkConnectionUtil.setCurrentConnectionStatus(ProdConnectionStatus.LOCAL) + markAllSpotlightsSeen() + setUpAudio() launch( createExplorationActivityIntent( internalProfileId, @@ -1199,15 +1191,25 @@ class ExplorationActivityTest { shouldSavePartialProgress = false ) ).use { - waitForTheView(withText("What is a Ratio?")) - // Clicks continue until we reach the first interaction. - onView(withId(R.id.continue_interaction_button)).perform(click()) - onView(withId(R.id.continue_interaction_button)).perform(click()) - onView(withId(R.id.continue_interaction_button)).perform(click()) - onView(withId(R.id.continue_interaction_button)).perform(click()) - onView(withId(R.id.continue_interaction_button)).perform(click()) + explorationDataController.startPlayingNewExploration( + internalProfileId, + RATIOS_TOPIC_ID, + RATIOS_STORY_ID_0, + RATIOS_EXPLORATION_ID_0 + ) + networkConnectionUtil.setCurrentConnectionStatus(ProdConnectionStatus.LOCAL) + testCoroutineDispatchers.runCurrent() + + clickContinueButton() + clickContinueButton() + clickContinueButton() + clickContinueButton() + clickContinueButton() onView(withId(R.id.action_audio_player)).perform(click()) + testCoroutineDispatchers.runCurrent() + + scrollToViewType(StateItemViewModel.ViewType.TEXT_INPUT_INTERACTION) onView(withId(R.id.text_input_interaction_view)).perform( editTextInputAction.appendText("123"), closeSoftKeyboard()