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 0b3694f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 108 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
uses: reactivecircus/[email protected]
with:
api-level: 29
arch: x86
target: google_apis_playstore
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 0b3694f

Please sign in to comment.