Skip to content

Commit

Permalink
Fix part of #2480: Fixes 2 Audio Tests (#5245)
Browse files Browse the repository at this point in the history
<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->

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
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [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
<!-- Delete these section if this PR does not include UI-related
changes. -->
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 <[email protected]>
  • Loading branch information
theMr17 and adhiamboperes authored Dec 7, 2023
1 parent d85fe6e commit d021afd
Showing 1 changed file with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExplorationActivity>(
createExplorationActivityIntent(
internalProfileId,
Expand All @@ -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)
}
Expand Down Expand Up @@ -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<ExplorationActivity>(
createExplorationActivityIntent(
internalProfileId,
Expand All @@ -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()
Expand Down

0 comments on commit d021afd

Please sign in to comment.