ci: Instrumentation tests coverage in ci.
This commit is contained in:
@ -35,13 +35,13 @@ import java.io.IOException
|
||||
import java.util.Locale
|
||||
|
||||
// For now, do not move this as it is modified by the integration tests
|
||||
val defaultUrl = "http://10.0.2.2:8888"
|
||||
const val DEFAULT_URL = "http://10.0.2.2:8888"
|
||||
|
||||
fun performLogin(someUrl: String? = null) {
|
||||
Log.i("AUTOMATION", "The url used will be ${if (!someUrl.isNullOrEmpty()) someUrl else defaultUrl}")
|
||||
Log.i("AUTOMATION", "The url used will be ${if (!someUrl.isNullOrEmpty()) someUrl else DEFAULT_URL}")
|
||||
onView(withId(R.id.urlView)).perform(click()).perform(
|
||||
typeTextIntoFocusedView(
|
||||
if (!someUrl.isNullOrEmpty()) someUrl else defaultUrl,
|
||||
if (!someUrl.isNullOrEmpty()) someUrl else DEFAULT_URL,
|
||||
),
|
||||
)
|
||||
onView(withId(R.id.signInButton)).perform(click())
|
||||
@ -160,7 +160,7 @@ open class WithANRException {
|
||||
"default root matcher, it may be picking a root that never takes focus. " +
|
||||
"Root:",
|
||||
)
|
||||
private val otherException = "System Ul isn't responding"
|
||||
private const val OTHER_EXCEPTION = "System Ul isn't responding"
|
||||
|
||||
private fun handleAnrDialogue() {
|
||||
val device = UiDevice.getInstance(getInstrumentation())
|
||||
@ -175,7 +175,7 @@ open class WithANRException {
|
||||
Espresso.setFailureHandler { error, viewMatcher ->
|
||||
|
||||
takeScreenshot()
|
||||
if (error.message!!.contains(otherException)) {
|
||||
if (error.message!!.contains(OTHER_EXCEPTION)) {
|
||||
handleAnrDialogue()
|
||||
} else if (error.message!!.contains(rootViewWithoutFocusExceptionMsg) &&
|
||||
anrCount < 20
|
||||
@ -192,6 +192,7 @@ open class WithANRException {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("detekt:NestedBlockDepth")
|
||||
fun takeScreenshot() {
|
||||
try {
|
||||
val bitmap = getInstrumentation().uiAutomation.takeScreenshot()
|
||||
|
@ -132,6 +132,7 @@ class LoginActivity :
|
||||
showProgress(false)
|
||||
}
|
||||
|
||||
@Suppress("detekt:LongMethod")
|
||||
private fun attemptLogin() {
|
||||
// Reset errors.
|
||||
binding.urlView.error = null
|
||||
|
Reference in New Issue
Block a user