Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 9 additions & 5 deletions .github/actions/submit-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
google-maps-key:
description: 'A Google Maps API key'

api-level:
description: 'Android API level to run the emulator with'
default: '30'

runs:
using: composite
steps:
Expand Down Expand Up @@ -76,7 +80,7 @@ runs:
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
api-level: ${{ inputs.api-level }}
target: google_apis
arch: x86_64
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
Expand All @@ -91,7 +95,7 @@ runs:
if: always()
uses: actions/upload-artifact@v6
with:
name: test-reports
name: test-reports-api${{ inputs.api-level }}
path: '**/build/reports/androidTests'
retention-days: 7
if-no-files-found: warn
Expand All @@ -100,7 +104,7 @@ runs:
if: always()
uses: actions/upload-artifact@v6
with:
name: test-screenshots
name: test-screenshots-api${{ inputs.api-level }}
path: '**/build/outputs/connected_android_test_additional_output'
retention-days: 7
if-no-files-found: ignore
Expand All @@ -118,7 +122,7 @@ runs:
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: firebase-emulator-log
name: firebase-emulator-log-api${{ inputs.api-level }}
path: /tmp/firebase-emulator.log
retention-days: 7
if-no-files-found: warn
Expand All @@ -127,7 +131,7 @@ runs:
if: always() && inputs.upload-artifacts == 'true'
uses: actions/upload-artifact@v6
with:
name: firebase-emulator-data
name: firebase-emulator-data-api${{ inputs.api-level }}
path: ${{ github.workspace }}/test-android-result
retention-days: 7
if-no-files-found: warn
33 changes: 31 additions & 2 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,26 @@ permissions:
contents: read

jobs:
run-instrumentation-tests:
request-approval:
runs-on: ubuntu-latest
timeout-minutes: 30
environment: e2e-approval
steps:
- run: echo "Approval granted"

instrumentation-matrix:
name: API ${{ matrix.api-level }}
needs: request-approval
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- api-level: 30
required: true
- api-level: 24
required: false
continue-on-error: ${{ !matrix.required }}
env:
FIREBASE_CLI_EXPERIMENTS: webframeworks

Expand All @@ -47,3 +63,16 @@ jobs:
android-repository: google/ground-android
upload-artifacts: true
google-maps-key: ${{ secrets.MAPS_API_KEY }}
api-level: ${{ matrix.api-level }}

run-instrumentation-tests:
needs: instrumentation-matrix
if: always()
runs-on: ubuntu-latest
steps:
- name: Check matrix results
run: |
if [ "${{ needs.instrumentation-matrix.result }}" != "success" ]; then
echo "Required instrumentation tests failed"
exit 1
fi
1 change: 1 addition & 0 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ kotlin {
namespace = "org.groundplatform.core.ui"
compileSdk = libs.versions.androidCompileSdk.get().toInt()
minSdk = libs.versions.androidMinSdk.get().toInt()
androidResources.enable = true
}

val xcfName = "GroundUiKit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
import java.util.regex.Pattern
import org.groundplatform.android.R
import org.groundplatform.android.e2etest.TestConfig.DEFAULT_TIMEOUT
import org.groundplatform.android.e2etest.TestConfig.TEST_PHOTO_FILE
Expand Down Expand Up @@ -180,4 +181,15 @@ class AndroidTestDriver(
composeRule.onTarget(TestDriver.Target.Text(componentText)).assertIsNotDisplayed()
}
}

override fun enableLocationServices() {
val button =
device.wait(
Until.findObject(
By.text(Pattern.compile(".*${Regex.escape("ok")}.*", Pattern.CASE_INSENSITIVE))
),
DEFAULT_TIMEOUT,
)
button?.click()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ interface TestDriver {

fun assertVisible(componentText: String, isVisible: Boolean = false)

fun enableLocationServices()

sealed class Target {
data class TestTag(val tag: String) : Target()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import org.groundplatform.android.ui.components.LOCATION_NOT_LOCKED_TEST_TAG

@OptIn(ExperimentalTestApi::class)
class HomeScreenRobot(override val testDriver: TestDriver) : Robot<HomeScreenRobot>() {
fun enableLocationServices() {
testDriver.enableLocationServices()
}

fun moveMap() = testDriver.dragMapBy(500, 500)

fun recenter() = testDriver.click(TestDriver.Target.TestTag(LOCATION_NOT_LOCKED_TEST_TAG))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class CompleteAllTaskTypesTest {
with(SurveySelectorRobot(testDriver)) { selectSurvey(TestConfig.SURVEY_NAME) }
// Add new LOI and test all task types except DRAW_AREA
with(HomeScreenRobot(testDriver)) {
enableLocationServices()
moveMap()
recenter()
addLoi()
Expand Down
Loading