Closed igorwojda closed 4 years ago
@igorwojda no, you're not missing anything. Actually, I would also recommend to add resource id match for error as well.
@igorwojda Yes mate. All good! Maybe will be better to add a new function like
/**
* Checks if this input layout has given hint
*
* @param resId - hint text resource to be checked
*/
fun hasHint(@StringRes resId: Int) {
view.check(ViewAssertion { view, notFoundException ->
if (view is TextInputLayout) {
val expectedHint = view.context.getString(resId)
if (expectedHint != view.hint) {
throw AssertionError(
"Expected hint is $expectedHint," +
" but actual is ${view.hint}"
)
}
} else {
notFoundException?.let { throw AssertionError(it) }
}
})
}
WDYT @igorwojda @Unlimity ?
@Unlimity I have added equivalent method for error
fun hasError(@StringRes resId: Int)
@igorwojda Yes mate. All good! Maybe will be better to add a new function like
/** * Checks if this input layout has given hint * * @param resId - hint text resource to be checked */ fun hasHint(@StringRes resId: Int) { view.check(ViewAssertion { view, notFoundException -> if (view is TextInputLayout) { val expectedHint = view.context.getString(resId) if (expectedHint != view.hint) { throw AssertionError( "Expected hint is $expectedHint," + " but actual is ${view.hint}" ) } } else { notFoundException?.let { throw AssertionError(it) } } }) }
WDYT @igorwojda @Unlimity ?
I don't really see any benefit of doing so (instead of using one overload with in another, like in this PR).
However on the other side we have a big downside of heaving two full/long implementations - higher maintenance cost.
@igorwojda awesome! Thanks a lot! Last request from me. Could u please extract
private fun getResourceString(@StringRes resId: Int) = InstrumentationRegistry.getInstrumentation().targetContext.let { it.resources.getString(resId) }
To
common/utility/ContextUtils.kt
I will name it utilities
(plular) to match other package names
Should docs/kakao
be a apart of this PR?
@igorwojda don't worry about notes. This PR could contain only code related stuff. Cheers.
done
@igorwojda thanks for the contribution
All committers have signed the CLA.