Skip to content

Commit

Permalink
Try to fling twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Futsch1 committed Jan 3, 2025
1 parent 1935e8c commit ce4f2b6
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/src/androidTest/java/com/futsch1/medtimer/SettingsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ class SettingsTest : BaseTestHelper() {
AndroidTestHelper.createIntervalReminder("1", 120)
pressBack()

// Now dismiss notification
// We navigate to analysis first to not accidentally grab another UI object with text "Test med"
navigateTo(MainMenu.ANALYSIS)
device.openNotification()
val notification = device.wait(Until.findObject(By.textContains("Test med")), 2000)
Assert.assertNotNull(notification)
if (!notification.fling(Direction.RIGHT)) notification.fling(Direction.RIGHT)
device.pressBack()
dismissNotification(device)

// Check overview and next reminders
navigateTo(MainMenu.OVERVIEW)
Expand All @@ -85,14 +78,7 @@ class SettingsTest : BaseTestHelper() {
onView(withText(R.string.clear_events)).perform(click())
onView(withId(android.R.id.button1)).perform(click())

// Now dismiss notification
// We navigate to analysis first to not accidentally grab another UI object with text "Test med"
navigateTo(MainMenu.ANALYSIS)
device.openNotification()
val newNotification = device.wait(Until.findObject(By.textContains("Test med")), 2000)
Assert.assertNotNull(newNotification)
if (!newNotification.fling(Direction.RIGHT)) newNotification.fling(Direction.RIGHT)
device.pressBack()
dismissNotification(device)

// Check overview and next reminders
navigateTo(MainMenu.OVERVIEW)
Expand Down Expand Up @@ -139,4 +125,18 @@ class SettingsTest : BaseTestHelper() {
val nextNotification = device.wait(Until.findObject(By.textContains("Test med")), 2000)
Assert.assertNotNull(nextNotification)
}

private fun dismissNotification(device: UiDevice) {
// Now dismiss notification
// We navigate to analysis first to not accidentally grab another UI object with text "Test med"
navigateTo(MainMenu.ANALYSIS)
device.openNotification()
var notification = device.wait(Until.findObject(By.textContains("Test med")), 2000)
Assert.assertNotNull(notification)
notification.fling(Direction.RIGHT)
notification = device.wait(Until.findObject(By.textContains("Test med")), 500)
notification?.fling(Direction.RIGHT)

device.pressBack()
}
}

0 comments on commit ce4f2b6

Please sign in to comment.