mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
[WIP] Implemented Espresso tests for upload with multilingual descriptions (#2830)
* With more upload tests * Fix tests * Fix tests
This commit is contained in:
parent
99c6f5f105
commit
bd668182b5
5 changed files with 301 additions and 76 deletions
|
|
@ -9,8 +9,12 @@ import androidx.test.espresso.action.ViewActions
|
|||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.hamcrest.BaseMatcher
|
||||
import org.hamcrest.Description
|
||||
import org.hamcrest.Matcher
|
||||
import timber.log.Timber
|
||||
|
||||
|
||||
class UITestHelper {
|
||||
companion object {
|
||||
fun skipWelcome() {
|
||||
|
|
@ -34,7 +38,7 @@ class UITestHelper {
|
|||
closeSoftKeyboard()
|
||||
onView(ViewMatchers.withId(R.id.login_button))
|
||||
.perform(ViewActions.click())
|
||||
sleep(5000)
|
||||
sleep(10000)
|
||||
} catch (ignored: NoMatchingViewException) {
|
||||
}
|
||||
|
||||
|
|
@ -68,5 +72,22 @@ class UITestHelper {
|
|||
activityRule.activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
assert(activityRule.activity.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
|
||||
}
|
||||
|
||||
fun <T> first(matcher: Matcher<T>): Matcher<T>? {
|
||||
return object : BaseMatcher<T>() {
|
||||
var isFirst = true
|
||||
override fun matches(item: Any): Boolean {
|
||||
if (isFirst && matcher.matches(item)) {
|
||||
isFirst = false
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun describeTo(description: Description) {
|
||||
description.appendText("should return first matching item")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue