dylangreenuk
10/12/2020, 4:17 PMimport android.view.View
import androidx.test.espresso.matcher.BoundedMatcher
import com.google.android.material.textfield.TextInputLayout
import org.hamcrest.Description
import org.hamcrest.Matcher
object TextInputLayoutMatchers {
fun errorMatches(matcherText: String?): Matcher<View> {
return object : BoundedMatcher<View, TextInputLayout>(TextInputLayout::class.java) {
var reality: String? = null
override fun describeTo(description: Description) {
description.appendText("with item error: ${matcherText.toString()}, does not match: ${reality.toString()}")
}
override fun matchesSafely(editTextField: TextInputLayout): Boolean {
reality = editTextField.error?.toString()
return matcherText.equals(reality, ignoreCase = false)
}
}
}
}
standard ktlint v0.39.0 errors out with: