Compare commits

..

1 Commits

Author SHA1 Message Date
514c6b85c3 ci: Instrumentation tests coverage in ci.
Some checks failed
Check PR code / EspressoReports (pull_request) Failing after 51m28s
2025-03-18 12:32:39 +01:00

View File

@ -21,7 +21,7 @@ import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.UiSelector
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.Matchers.hasToString import org.hamcrest.Matchers.hasToString
import org.junit.Before import org.junit.BeforeClass
import java.util.Locale import java.util.Locale
fun performLogin(someUrl: String? = null) { fun performLogin(someUrl: String? = null) {
@ -128,6 +128,7 @@ fun testAddSourceWithUrl(
} }
open class WithANRException { open class WithANRException {
companion object {
// Running count of the number of Android Not Responding dialogues to prevent endless dismissal. // Running count of the number of Android Not Responding dialogues to prevent endless dismissal.
private var anrCount = 0 private var anrCount = 0
@ -141,7 +142,15 @@ open class WithANRException {
"Root:", "Root:",
) )
@Before private fun handleAnrDialogue() {
val device = UiDevice.getInstance(getInstrumentation())
// If running the device in English Locale
val waitButton = device.findObject(UiSelector().textContains("wait"))
if (waitButton.exists()) waitButton.click()
}
@JvmStatic
@BeforeClass
fun setUpHandler() { fun setUpHandler() {
Espresso.setFailureHandler { error, viewMatcher -> Espresso.setFailureHandler { error, viewMatcher ->
@ -153,11 +162,5 @@ open class WithANRException {
} }
} }
} }
private fun handleAnrDialogue() {
val device = UiDevice.getInstance(getInstrumentation())
// If running the device in English Locale
val waitButton = device.findObject(UiSelector().textContains("wait"))
if (waitButton.exists()) waitButton.click()
} }
} }