Created
March 4, 2021 05:35
-
-
Save anandwana001/fa497cb8981606313c9dc3a8a26fcdb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
****** Espresso Passing ****** | |
@get:Rule | |
val activityTestRule: ActivityTestRule<ExplorationActivity> = ActivityTestRule( | |
ExplorationActivity::class.java, /* initialTouchMode= */ true, /* launchActivity= */ false | |
) | |
@Test | |
fun testAudioWithWifi_openRatioExploration_continueToInteraction_clickAudioButton_submitAnswer_checkFeedbackAudioPlays() { | |
getApplicationDependencies(RATIOS_EXPLORATION_ID_0) | |
networkConnectionUtil.setCurrentConnectionStatus(NetworkConnectionUtil.ConnectionStatus.LOCAL) | |
activityTestRule.launchActivity( | |
createExplorationActivityIntent( | |
internalProfileId, RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, RATIOS_EXPLORATION_ID_0 | |
) | |
) | |
testCoroutineDispatchers.unregisterIdlingResource() | |
waitForTheView(withText("What is a Ratio?")) | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
onView(withId(R.id.action_audio_player)).perform(click()) | |
onView(withId(R.id.text_input_interaction_view)).perform( | |
editTextInputAction.appendText("123"), | |
closeSoftKeyboard() | |
) | |
onView(withId(R.id.submit_answer_button)).perform(click()) | |
waitForTheView(withDrawable(R.drawable.ic_pause_circle_filled_white_24dp)) | |
onView(withId(R.id.play_pause_audio_icon)) | |
.check(matches(withContentDescription(context.getString(R.string.audio_pause_description)))) | |
testCoroutineDispatchers.registerIdlingResource() | |
explorationDataController.stopPlayingExploration() | |
} | |
private fun scrollToViewType(viewType: StateItemViewModel.ViewType) { | |
onView(withId(R.id.state_recycler_view)).perform( | |
scrollToHolder(StateViewHolderTypeMatcher(viewType)) | |
) | |
onView(withId(R.id.continue_button)).perform(click()) | |
} | |
private class StateViewHolderTypeMatcher( | |
private val viewType: StateItemViewModel.ViewType | |
) : BaseMatcher<RecyclerView.ViewHolder>() { | |
override fun describeTo(description: Description?) { | |
description?.appendText("item view type of $viewType") | |
} | |
override fun matches(item: Any?): Boolean { | |
return (item as? RecyclerView.ViewHolder)?.itemViewType == viewType.ordinal | |
} | |
} | |
****** Robolectric Failing //executing till last line where we are checking pause icon, but I think need more delay ****** | |
@Test | |
fun forRobolectric() { | |
setupAudio() | |
launch<ExplorationActivity>( | |
createExplorationActivityIntent( | |
internalProfileId, RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, RATIOS_EXPLORATION_ID_0 | |
) | |
).use { | |
explorationDataController.startPlayingExploration(RATIOS_EXPLORATION_ID_0) | |
networkConnectionUtil.setCurrentConnectionStatus(NetworkConnectionUtil.ConnectionStatus.CELLULAR) | |
testCoroutineDispatchers.runCurrent() | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
testCoroutineDispatchers.runCurrent() | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
testCoroutineDispatchers.runCurrent() | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
testCoroutineDispatchers.runCurrent() | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
testCoroutineDispatchers.runCurrent() | |
scrollToViewType(StateItemViewModel.ViewType.CONTINUE_INTERACTION) | |
testCoroutineDispatchers.runCurrent() | |
onView(withId(R.id.action_audio_player)).perform(click()) | |
testCoroutineDispatchers.runCurrent() | |
onView(withId(R.id.text_input_interaction_view)).perform( | |
editTextInputAction.appendText("123"), | |
closeSoftKeyboard() | |
) | |
testCoroutineDispatchers.runCurrent() | |
onView(withId(R.id.submit_answer_button)).perform(click()) | |
testCoroutineDispatchers.runCurrent() | |
onView(withId(R.id.play_pause_audio_icon)) | |
.check(matches(withContentDescription(context.getString(R.string.audio_pause_description)))) | |
explorationDataController.stopPlayingExploration() | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment