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 #3607: ExplorationPlayer End to End tests #3608

Merged
merged 72 commits into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
b720222
Introducing UiAutomator
FareesHussain Jul 15, 2021
f90cbfc
Using 23 api level
FareesHussain Jul 15, 2021
930abe0
some local tweaks
FareesHussain Jul 16, 2021
bb6f5bb
Updated implementation based on adb commands
FareesHussain Jul 20, 2021
46a1b56
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
FareesHussain Jul 20, 2021
44f4003
Nit fixes
FareesHussain Jul 20, 2021
72620a2
Nit fixes
FareesHussain Jul 20, 2021
7a384c3
Merge branch 'setup-uiautomator' of https://github.com/FareesHussain/…
FareesHussain Jul 22, 2021
8a641d7
Requested changes
FareesHussain Jul 22, 2021
c58b6f6
fix class name
FareesHussain Jul 22, 2021
09c419e
update dependencies
FareesHussain Jul 22, 2021
004e3a1
Nit fixes
FareesHussain Jul 24, 2021
7124642
Initial e2e tests
FareesHussain Jul 29, 2021
7a1221d
Requested changes
FareesHussain Jul 30, 2021
0aec4a5
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
FareesHussain Jul 30, 2021
6e09966
updated maven_install
FareesHussain Jul 30, 2021
8ca2bb9
Merge branch 'setup-uiautomator' of https://github.com/FareesHussain/…
FareesHussain Jul 30, 2021
4486882
Nit fix
FareesHussain Jul 30, 2021
f64d32c
Add CODEOWNERS
FareesHussain Jul 30, 2021
dc66ba2
Added KDoc
FareesHussain Jul 30, 2021
c233b71
NIT
FareesHussain Jul 30, 2021
2044979
Added comments
FareesHussain Jul 30, 2021
7ac1ac5
Added oppia_instrumentation_test.bzl
FareesHussain Jul 31, 2021
3bb5348
added exempted_file_path
FareesHussain Jul 31, 2021
1c818dd
Merge branch 'setup-uiautomator' of https://github.com/FareesHussain/…
FareesHussain Jul 31, 2021
2e0440e
e2e tests for both explorations
FareesHussain Jul 31, 2021
e5a6128
Helper utility shifted to testing module
FareesHussain Aug 4, 2021
425ebfa
NIT
FareesHussain Aug 4, 2021
067537f
NIT
FareesHussain Aug 4, 2021
b9233c6
deleted the previous utility
FareesHussain Aug 4, 2021
37b10e2
ignoring instrumentation in ComputeAffectedTests.kt
FareesHussain Aug 5, 2021
3c1e79f
NIT
FareesHussain Aug 5, 2021
44363c1
NIT
FareesHussain Aug 5, 2021
e95d29f
NIT
FareesHussain Aug 6, 2021
c608f7c
changed startsWith("instrumentation/")
FareesHussain Aug 6, 2021
66f6b51
filtered bazel targets
FareesHussain Aug 6, 2021
6514ba9
NIT
FareesHussain Aug 6, 2021
e81706b
NIT
FareesHussain Aug 6, 2021
a4266e4
filtering the instrumentation from the total affected targets
FareesHussain Aug 6, 2021
6f2836c
NIT
FareesHussain Aug 6, 2021
870d0a2
Merge branch 'setup-uiautomator' of https://github.com/FareesHussain/…
FareesHussain Aug 9, 2021
3660243
changed directory to javatests
FareesHussain Aug 10, 2021
d4aa4d4
NIT
FareesHussain Aug 10, 2021
41ea23f
NIT
FareesHussain Aug 10, 2021
b15451b
fixed scripts
FareesHussain Aug 11, 2021
73c650e
NIT
FareesHussain Aug 11, 2021
0d50914
updated the ComputedAffectedTests
FareesHussain Aug 13, 2021
e2db957
ignoring player directory
FareesHussain Aug 13, 2021
f8f3ca9
Merge branch 'setup-uiautomator' of https://github.com/FareesHussain/…
FareesHussain Aug 14, 2021
16b51e5
Updated with new changes
FareesHussain Aug 15, 2021
02af57a
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
FareesHussain Aug 16, 2021
e39903f
updated tests
FareesHussain Aug 17, 2021
838c713
updated tests
FareesHussain Aug 17, 2021
08ffe75
fix OppiaTestApplication
FareesHussain Aug 17, 2021
e2ba215
added todo
FareesHussain Aug 17, 2021
989342e
fixed clearAppData to delete all the .cache file of the app
FareesHussain Aug 17, 2021
5610651
NIT
FareesHussain Aug 17, 2021
3f9e2c7
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
FareesHussain Aug 18, 2021
75c60cd
removed clearAppData
FareesHussain Aug 18, 2021
a37bcbb
updated ComputeAffectedTestsTest
FareesHussain Aug 18, 2021
33c4189
updated ComputeAffectedTestsTest
FareesHussain Aug 18, 2021
d40cd4b
reverted ComputeAffectedTestsTest.kt
FareesHussain Aug 19, 2021
55bc4d9
requested changes
FareesHussain Aug 19, 2021
58caec1
Using !!.
FareesHussain Aug 19, 2021
8d16408
NIT
FareesHussain Aug 19, 2021
c7bd1dd
fixed tests
FareesHussain Aug 19, 2021
f01a655
reverted chapter_completed_tick content desc
FareesHussain Aug 19, 2021
4811a07
Updated content description for ImageRegionSelectionInteraction
FareesHussain Aug 19, 2021
b9e9fbe
testing ImageRegionSelectionInteractionView
FareesHussain Aug 19, 2021
196f8db
updated test
FareesHussain Aug 20, 2021
bf1e0eb
remoced ignore
FareesHussain Aug 20, 2021
63ed680
Removed content description and Added checkNotNull
FareesHussain Aug 20, 2021
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 @@ -49,16 +49,32 @@ object EndToEndTestHelper {
wait(Until.hasObject(By.text(text)), TRANSITION_TIMEOUT_SECONDS)
}

/** Waits for the view with given content description to appear. */
fun UiDevice.waitForDesc(text: String) {
wait(Until.hasObject(By.desc(text)), TRANSITION_TIMEOUT_SECONDS)
}

/** Return the UiObject with the given text. */
fun UiDevice.findObjectByText(text: String): UiObject2? {
fun UiDevice.findObjectByText(text: String): UiObject2 {
waitForText(text)
return findObject(By.text(text))
return checkNotNull(findObject(By.text(text)))
}

/** Returns the UiObject for the given resourceId. */
fun UiDevice.findObjectByRes(resourceId: String): UiObject2? {
fun UiDevice.findObjectByRes(resourceId: String): UiObject2 {
waitForRes(resourceId)
return findObject(By.res("$OPPIA_PACKAGE:id/$resourceId"))
return checkNotNull(findObject(By.res("$OPPIA_PACKAGE:id/$resourceId")))
}

/** Returns the UiObject for the given resourceId. */
fun UiObject2.findObjectByRes(resourceId: String): UiObject2 {
return checkNotNull(findObject(By.res("$OPPIA_PACKAGE:id/$resourceId")))
}

/** Returns the UiObject for the given content description. */
fun UiDevice.findObjectByDesc(text: String): UiObject2 {
waitForDesc(text)
return checkNotNull(findObject(By.desc(text)))
}

/** Performs a scroll until the view with the give text is visible. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.findObjectByDesc
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.findObjectByRes
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.findObjectByText
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.scrollRecyclerViewTextIntoView
Expand All @@ -23,22 +25,162 @@ class ExplorationPlayerTest {
}

@Test
fun testExploration_prototypeExploration_toolbarTitle_isDisplayedSuccessfully() {
fun testPlayExploration_prototypeExploration_playedFullyThrough_finishesSuccessfully() {
navigateToPrototypeExploration()
assertThat(device.findObjectByRes("exploration_toolbar_title")).isNotNull()

// Play through all interactions.
playContinueInteraction()
playFractionInputInteraction()
playMultipleChoiceIntearction1()
playMultipleChoiceIntearction2()
playItemSelectionInteraction()
playNumericInputInteraction()
playRatioInputInteraction()
playTextInputInteraction()
playDragAndDropInteraction()
playDragDropMergeInteraction()
playEndExplorationInteraction()

// Assert Topic Completed.
scrollRecyclerViewTextIntoView("Chapter 1: Prototype Exploration")
val chapterCompletedTick = device.findObjectByText(
"Chapter 1: Prototype Exploration"
).parent.findObjectByRes("chapter_completed_tick")
assertThat(chapterCompletedTick).isNotNull()
}

// TODO(#3697): Update e2e tests when backend support is introduced.
@Test
@Ignore("Need backend connection support to test the ImageRegionSelectionInteraction")
fun testPlayExploration_imageRegionInteractionExp_playedFullyThrough_finishesSuccessfully() {
navigateToImageRegionSelectionInteraction()

// Image Region Selection Interaction.
val imageSelectionView = device.findObjectByRes("interaction_container_frame_layout")
device.waitForRes("image_click_interaction_image_view")
// TODO(#3712): Use content description to fetch the image region.
imageSelectionView.children.get(2).click()
device.findObjectByText("SUBMIT").click()
device.findObjectByText("CONTINUE").click()

// End Exploration.
playEndExplorationInteraction()

// Assert Topic Completed.
scrollRecyclerViewTextIntoView("Chapter 2: Image Region Selection Exploration")
val chapterCompletedTick = device.findObjectByText(
"Chapter 2: Image Region Selection Exploration"
).parent.findObjectByRes("chapter_completed_tick")
assertThat(chapterCompletedTick).isNotNull()
}

/** Navigates and opens the Prototype Exploration using the admin profile. */
private fun navigateToPrototypeExploration() {
device.findObjectByRes("skip_text_view")?.click()
device.findObjectByRes("get_started_button")?.click()
device.findObjectByRes("skip_text_view").click()
device.findObjectByRes("get_started_button").click()
device.waitForRes("profile_select_text")
device.findObjectByText("Admin").click()
scrollRecyclerViewTextIntoView("First Test Topic")
device.findObjectByText("First Test Topic").click()
device.findObjectByText("LESSONS").click()
device.findObjectByText("First Story").click()
scrollRecyclerViewTextIntoView("Chapter 1: Prototype Exploration")
device.findObjectByText("Chapter 1: Prototype Exploration").click()
}

private fun completePrototypeExploration() {
playContinueInteraction()
playFractionInputInteraction()
playMultipleChoiceIntearction1()
playMultipleChoiceIntearction2()
playItemSelectionInteraction()
playNumericInputInteraction()
playRatioInputInteraction()
playTextInputInteraction()
playDragAndDropInteraction()
playDragDropMergeInteraction()
playEndExplorationInteraction()
}

private fun playContinueInteraction() {
device.findObjectByText("CONTINUE").click()
}

private fun playFractionInputInteraction() {
device.findObjectByRes("fraction_input_interaction_view").text = "1/2"
device.findObjectByText("SUBMIT").click()
playContinueInteraction()
}

private fun playMultipleChoiceIntearction1() {
device.findObjectByText("Eagle").click()
playContinueInteraction()
}

private fun playMultipleChoiceIntearction2() {
device.findObjectByText("Green").click()
playContinueInteraction()
}

private fun playItemSelectionInteraction() {
device.findObjectByText("Red").click()
device.findObjectByText("Green").click()
device.findObjectByText("Blue").click()
device.findObjectByText("SUBMIT").click()
playContinueInteraction()
}

private fun playNumericInputInteraction() {
device.findObjectByRes("numeric_input_interaction_view").text = "121"
device.findObjectByText("SUBMIT").click()
playContinueInteraction()
}

private fun playRatioInputInteraction() {
device.findObjectByRes("ratio_input_interaction_view").text = "4:5"
device.findObjectByText("SUBMIT").click()
playContinueInteraction()
}

private fun playTextInputInteraction() {
device.findObjectByRes("text_input_interaction_view").text = "Finnish"
device.findObjectByText("SUBMIT").click()
playContinueInteraction()
}

private fun playDragAndDropInteraction() {
device.findObjectByDesc("Move item down to 2").click()
device.findObjectByDesc("Move item down to 3").click()
device.findObjectByDesc("Move item down to 4").click()
device.findObjectByText("SUBMIT").click()
playContinueInteraction()
}

private fun playDragDropMergeInteraction() {
device.findObjectByDesc("Link to item 2").click()
device.findObjectByDesc("Move item down to 3").click()
device.findObjectByText("SUBMIT").click()
playContinueInteraction()
}

private fun playEndExplorationInteraction() {
device.findObjectByText("RETURN TO TOPIC").click()
}

/** Navigates and opens the Image Region Selection Exploration using the admin profile. */
private fun navigateToImageRegionSelectionInteraction() {
device.findObjectByRes("skip_text_view").click()
device.findObjectByRes("get_started_button").click()
device.waitForRes("profile_select_text")
device.findObjectByText("Admin")?.click()
device.findObjectByText("Admin").click()
scrollRecyclerViewTextIntoView("First Test Topic")
device.findObjectByText("First Test Topic")?.click()
device.findObjectByText("LESSONS")?.click()
device.findObjectByText("First Story")?.click()
device.findObjectByText("First Test Topic").click()
device.findObjectByText("LESSONS").click()
device.findObjectByText("First Story").click()
scrollRecyclerViewTextIntoView("Chapter 1: Prototype Exploration")
device.findObjectByText("Chapter 1: Prototype Exploration")?.click()
device.findObjectByText("Chapter 1: Prototype Exploration").click()
completePrototypeExploration()
scrollRecyclerViewTextIntoView("Chapter 2: Image Region Selection Exploration")
device.findObjectByText("Chapter 2: Image Region Selection Exploration").click()
}
}