From 329bce2b20ee1bee376de8012fb79b553b26e5d3 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 26 Oct 2024 08:32:14 +0200 Subject: [PATCH] test: clarify on the starting state Best to explicitly delete old sleeps than just hoping we won't have any. --- .../hu/vmiklos/plees_tracker/MainActivityUITest.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/androidTest/java/hu/vmiklos/plees_tracker/MainActivityUITest.kt b/app/src/androidTest/java/hu/vmiklos/plees_tracker/MainActivityUITest.kt index abb13b3..163801f 100644 --- a/app/src/androidTest/java/hu/vmiklos/plees_tracker/MainActivityUITest.kt +++ b/app/src/androidTest/java/hu/vmiklos/plees_tracker/MainActivityUITest.kt @@ -27,16 +27,24 @@ class MainActivityUITest { var activityScenarioRule = ActivityScenarioRule(MainActivity::class.java) @Test - fun testCreate() { + fun testCreateAndRead() { + // Given no sleeps: val instrumentation = InstrumentationRegistry.getInstrumentation() val device = UiDevice.getInstance(instrumentation) val pkg = instrumentation.processName val timeout: Long = 5000 + device.pressMenu() + val deleteAllSleep = device.wait(Until.findObject(By.text("Delete All Sleep")), timeout) + deleteAllSleep.click() + val yesButton = device.wait(Until.findObject(By.text("YES")), timeout) + yesButton.click() + // When creating one: val startStop = device.wait(Until.findObject(By.res(pkg, "start_stop")), timeout) startStop.click() startStop.click() + // Then make sure we have one sleep: val sleeps = device.wait( Until.findObject(By.res(pkg, "fragment_stats_sleeps").text("1")), timeout