Skip to content

Commit

Permalink
Added/Verified Espresso Tests - bumped Mockitor to 3.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rd4dev committed Sep 30, 2024
1 parent 7d1ab3a commit 41f1195
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ dependencies {
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4',
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4',
'org.mockito:mockito-core:2.7.22',
'org.mockito:mockito-core:3.11.1',
'com.github.oppia:android-spotlight:cc23499d37dc8533a2876e45b5063e981a4583f4'
)
compileOnly(
Expand All @@ -222,7 +222,7 @@ dependencies {
'org.robolectric:robolectric:4.5',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4',
"org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version",
'org.mockito:mockito-core:2.7.22',
'org.mockito:mockito-core:3.11.1',
project(":testing"),
)
androidTestImplementation(
Expand All @@ -238,7 +238,7 @@ dependencies {
'androidx.work:work-testing:2.4.0',
'com.google.truth.extensions:truth-liteproto-extension:1.1.3',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4',
'org.mockito:mockito-android:2.7.22',
'org.mockito:mockito-android:3.11.1',
'org.robolectric:annotations:4.5',
)
// Adding the testing module directly causes duplicates of the below groups so we need to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,80 @@ class StateFragmentTest {
}
}

@Test
@RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric.
fun testStateFragment_loadDragDropExp_wrongAnswer_retainsLatestState() {
setUpTestWithLanguageSwitchingFeatureOff()
launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use {
startPlayingExploration()
playThroughPrototypeState1()
playThroughPrototypeState2()
playThroughPrototypeState3()
playThroughPrototypeState4()
playThroughPrototypeState5()
playThroughPrototypeState6()
playThroughPrototypeState7()
playThroughPrototypeState8()

// Drag and drop interaction without grouping.
// Ninth state: Drag Drop Sort. Wrong answer: Move 1st item to 2nd position.
dragAndDropItem(fromPosition = 0, toPosition = 1)
clickSubmitAnswerButton()

scrollToViewType(DRAG_DROP_SORT_INTERACTION)
onView(
atPositionOnView(
recyclerViewId = R.id.drag_drop_interaction_recycler_view,
position = 0,
targetViewId = R.id.drag_drop_content_text_view
)
).check(matches(withText("3/5")))
onView(
atPositionOnView(
recyclerViewId = R.id.drag_drop_interaction_recycler_view,
position = 1,
targetViewId = R.id.drag_drop_content_text_view
)
).check(matches(withText("0.35")))
}
}

@Test
@RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric.
fun testStateFragment_loadDragDropExp_wrongAnswer_unArrangedRetainState_causeSubmitTimeError() {
setUpTestWithLanguageSwitchingFeatureOff()
launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use {
startPlayingExploration()
playThroughPrototypeState1()
playThroughPrototypeState2()
playThroughPrototypeState3()
playThroughPrototypeState4()
playThroughPrototypeState5()
playThroughPrototypeState6()
playThroughPrototypeState7()
playThroughPrototypeState8()

// Drag and drop interaction without grouping.
// Ninth state: Drag Drop Sort. Wrong answer: Move 1st item to 2nd position.
dragAndDropItem(fromPosition = 0, toPosition = 1)
clickSubmitAnswerButton()

scrollToViewType(DRAG_DROP_SORT_INTERACTION)
onView(
atPositionOnView(
recyclerViewId = R.id.drag_drop_interaction_recycler_view,
position = 0,
targetViewId = R.id.drag_drop_content_text_view
)
).check(matches(withText("3/5")))
clickSubmitAnswerButton()

onView(withId(R.id.drag_drop_interaction_error)).check(
matches(withText(R.string.drag_and_drop_interaction_empty_input))
)
}
}

@Test
fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_wrongAnswer_retainsLatestStateCount() {
setUpTestWithLanguageSwitchingFeatureOff()
Expand Down Expand Up @@ -1398,14 +1472,44 @@ class StateFragmentTest {
}

@Test
fun testStateFragment_loadDragDropExp_mergeItems_unArrangedRetainState_causeSubmitTimeError() {
@RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric.
fun testStateFragment_loadDragDropExp_mergeItems_dragItem_wrongAnswer_retainsLatestState() {
setUpTestWithLanguageSwitchingFeatureOff()
launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use {
startPlayingExploration()

mergeDragAndDropItems(position = 0)
dragAndDropItem(fromPosition = 0, toPosition = 2)
clickSubmitAnswerButton()

scrollToViewType(DRAG_DROP_SORT_INTERACTION)
onView(
atPositionOnView(
recyclerViewId = R.id.drag_drop_interaction_recycler_view,
position = 2,
targetViewId = R.id.drag_drop_content_text_view
)
).check(matches(withText("a camera at the store")))
}
}

@Test
fun testStateFragment_loadDragDropExp_mergeItems_unArrangedRetainState_causeSubmitTimeError() {
setUpTestWithLanguageSwitchingFeatureOff()
launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use {
startPlayingExploration()

mergeDragAndDropItems(position = 0)
clickSubmitAnswerButton()

scrollToViewType(DRAG_DROP_SORT_INTERACTION)
onView(
atPositionOnView(
recyclerViewId = R.id.drag_drop_item_recyclerview,
position = 0,
targetViewId = R.id.drag_drop_content_text_view
)
).check(matches(withText("a camera at the store")))
clickSubmitAnswerButton()

onView(withId(R.id.drag_drop_interaction_error)).check(
Expand Down

0 comments on commit 41f1195

Please sign in to comment.