Skip to content

Commit

Permalink
uitest: add update test
Browse files Browse the repository at this point in the history
And remove the last, unreliable espresso test.
  • Loading branch information
vmiklos committed Oct 29, 2024
1 parent 3c7dcc2 commit 9fcb4df
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 110 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:
distribution: 'temurin'
java-version: 17
- name: run tests
uses: reactivecircus/android-emulator-runner@v2.30.1
uses: reactivecircus/android-emulator-runner@v2.33.0
with:
api-level: 29
api-level: 34
target: aosp_atd
script: tools/ci-build.sh
env:
KEYSTORE: ${{ secrets.KEYSTORE }}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ class MainActivityUITest {
return device.wait(Until.findObject(By.res(pkg, resourceId)), timeout)
}

private fun findObjectByText(text: String): UiObject2 {
val device = getDevice()
return device.wait(Until.findObject(By.text(text)), timeout)
}

private fun findObjectByDesc(desc: String): UiObject2 {
val device = getDevice()
return device.wait(Until.findObject(By.desc(desc)), timeout)
}

@Test
fun testCreateAndRead() {
// Given no sleeps:
Expand All @@ -88,6 +98,27 @@ class MainActivityUITest {
// Then make sure we have no sleeps:
assertResText("fragment_stats_sleeps", "0")
}

@Test
fun testUpdate() {
resetDatabase()
createSleep()

findObjectByRes("sleep_swipeable").click()
findObjectByRes("sleep_start_time").click()
findObjectByText("AM").click()
findObjectByDesc("10").click()
findObjectByDesc("0").click()
findObjectByText("OK").click()
findObjectByRes("sleep_stop_time").click()
findObjectByText("PM").click()
findObjectByDesc("10").click()
findObjectByDesc("0").click()
findObjectByText("OK").click()

assertResText("sleep_start_time", "10:00")
assertResText("sleep_stop_time", "22:00")
}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

0 comments on commit 9fcb4df

Please sign in to comment.