[WIP] Implemented Espresso tests for upload with multilingual descriptions (#2830)

* With more upload tests

* Fix tests

* Fix tests
This commit is contained in:
Vivek Maskara 2020-03-10 12:01:22 -07:00 committed by GitHub
parent 99c6f5f105
commit bd668182b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 301 additions and 76 deletions

View file

@ -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")
}
}
}
}
}