-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Color state list now checks all possible states #351
Conversation
4b7dd60
to
909e157
Compare
return currentColorList == expectedColorInt | ||
val expectedColorList = ContextCompat.getColorStateList(textView.context, expectedColor)!! | ||
|
||
val allStates = ALL_COLOR_STATE_LIST_STATES.flatMap { state -> listOf(state, -state) }.map { state -> intArrayOf(state) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this -
of listOf(state, -state)
mean? Just curiosity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It reverses the state:
state enabled: android.R.attr.state_enabled
state disabled: -android.R.attr.state_enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WOW, that's a big WTF. What's the magic behind that?
IMHO we could do something easier to catch...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! And it was a real error, i wasn't just a flaky test. Nice fix :) |
Thanks to @BraisGabin on #350 that pointed out that
checkColorList_whenDisabled
andcheckColorList_whenChecked
tests were failing.I've investigated and found that on API 22 color state was not returning the same instance, (I believe android does some caching in future versions).
So I've moved color state list check to verify all possible states of color state list instead of checking for the same instance.