-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: resolve FIXME in sleep create test
Try the uiautomator approach, espresso doesn't seem to be able to cope with the coroutines/room/observer-based UI updates.
- Loading branch information
Showing
3 changed files
with
50 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/src/androidTest/java/hu/vmiklos/plees_tracker/MainActivityUITest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2024 Miklos Vajna | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package hu.vmiklos.plees_tracker | ||
|
||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.Until | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* UI tests for MainActivity. | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class MainActivityUITest { | ||
@JvmField | ||
@Rule | ||
var activityScenarioRule = ActivityScenarioRule(MainActivity::class.java) | ||
|
||
@Test | ||
fun testCreate() { | ||
val instrumentation = InstrumentationRegistry.getInstrumentation() | ||
val device = UiDevice.getInstance(instrumentation) | ||
val pkg = instrumentation.processName | ||
val timeout: Long = 5000 | ||
|
||
val startStop = device.wait(Until.findObject(By.res(pkg, "start_stop")), timeout) | ||
startStop.click() | ||
startStop.click() | ||
|
||
val sleeps = device.wait( | ||
Until.findObject(By.res(pkg, "fragment_stats_sleeps").text("1")), | ||
timeout | ||
) | ||
assertNotNull(sleeps) | ||
} | ||
} | ||
|
||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |