Skip to content

Commit

Permalink
Make end-to-end tests LOI task resilient. (#2589)
Browse files Browse the repository at this point in the history
  • Loading branch information
sufyanAbbasi authored Aug 2, 2024
1 parent fd197fc commit 82e8378
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.google.android.ground.e2etest.TestConfig.GROUND_PACKAGE
import com.google.android.ground.e2etest.TestConfig.LONG_TIMEOUT
import com.google.android.ground.e2etest.TestConfig.SHORT_TIMEOUT
import com.google.android.ground.e2etest.TestConfig.TEST_SURVEY_IDENTIFIER
import com.google.android.ground.e2etest.TestConfig.TEST_SURVEY_LOI_TASK_INDEX
import com.google.android.ground.e2etest.TestConfig.TEST_SURVEY_TASKS_ADHOC
import com.google.android.ground.model.task.Task
import java.io.IOException
Expand All @@ -61,7 +62,7 @@ class SurveyRunnerTest : AutomatorRunner {
fillOutTaskData(isAdHoc = true, TEST_SURVEY_TASKS_ADHOC)
clickSubmissionConfirmationDone()
startPredefinedLoiTask()
fillOutTaskData(isAdHoc = false, TEST_SURVEY_TASKS_ADHOC.drop(1))
fillOutTaskData(isAdHoc = false, TEST_SURVEY_TASKS_ADHOC)
clickSubmissionConfirmationDone()
}

Expand Down Expand Up @@ -154,6 +155,9 @@ class SurveyRunnerTest : AutomatorRunner {
private fun fillOutTaskData(isAdHoc: Boolean, taskList: List<Task.Type>) {
taskList.forEachIndexed { i, it ->
device.waitForIdle()
if (!isAdHoc && i == TEST_SURVEY_LOI_TASK_INDEX) {
return@forEachIndexed
}
when (it) {
Task.Type.DROP_PIN -> completeDropPinTask()
Task.Type.DRAW_AREA -> completeDrawArea()
Expand All @@ -168,7 +172,7 @@ class SurveyRunnerTest : AutomatorRunner {
}
if (i < taskList.size - 1) {
clickNext()
if (isAdHoc && i == 0) {
if (isAdHoc && i == TEST_SURVEY_LOI_TASK_INDEX) {
setLoiName()
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object TestConfig {
const val GROUND_PACKAGE = "com.google.android.ground"
val TEST_SURVEY_TASKS_ADHOC =
listOf(
Task.Type.CAPTURE_LOCATION,
Task.Type.DROP_PIN,
Task.Type.TEXT,
Task.Type.MULTIPLE_CHOICE,
Expand All @@ -33,5 +34,6 @@ object TestConfig {
Task.Type.PHOTO,
Task.Type.CAPTURE_LOCATION,
)
val TEST_SURVEY_LOI_TASK_INDEX = 1
const val TEST_SURVEY_IDENTIFIER = "test"
}

0 comments on commit 82e8378

Please sign in to comment.