Skip to content
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

Add support text view style assertions bold and italic #59

Conversation

hongwei-bai
Copy link
Contributor

Hi @Vacxe , feel typeface match might be quite strict sometimes(has to match style and weight too), maybe add this one as well for a few simple scenarios?

private val isItalic: Boolean? = null
) : BoundedMatcher<View, TextView>(TextView::class.java) {
override fun describeTo(description: Description) {
description.appendText("Text style doesn't match")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add a bit more for this reporting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will append similar information


override fun matchesSafely(item: TextView): Boolean {
var compareResult = true
if (isBold != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val boldCheck = isBolt?.let { item.typeface.isBold == it} ?: true

@hongwei-bai hongwei-bai force-pushed the add-text-styles-n-compound-drawables-verifications branch 5 times, most recently from c49467f to ebe5316 Compare July 15, 2022 01:31
@Vacxe
Copy link
Member

Vacxe commented Jul 16, 2022

@hongwei-bai I terribly sorry, but I think will be better to have two separates
ItalicStyleMatcher() and BoldStyleMatcher() without any parameters for constructor
and then for negative assertion just use not(<Matcher>)

https://stackoverflow.com/questions/28431647/matchesnotisdisplayed-fails-with-nomatchingviewexception

With this approach we will have single responsibility + avoiding Boolean in constructor

@hongwei-bai
Copy link
Contributor Author

@hongwei-bai I terribly sorry, but I think will be better to have two separates ItalicStyleMatcher() and BoldStyleMatcher() without any parameters for constructor and then for negative assertion just use not(<Matcher>)

https://stackoverflow.com/questions/28431647/matchesnotisdisplayed-fails-with-nomatchingviewexception

With this approach we will have single responsibility + avoiding Boolean in constructor

sure np @Vacxe. tbh I was swinging betweens the two. will make the changes. Thanks! 👍

@hongwei-bai hongwei-bai force-pushed the add-text-styles-n-compound-drawables-verifications branch from ebe5316 to 46ad1c4 Compare July 21, 2022 02:52
@hongwei-bai hongwei-bai force-pushed the add-text-styles-n-compound-drawables-verifications branch from 46ad1c4 to 8d9de25 Compare July 21, 2022 02:53
@Vacxe Vacxe merged commit 9e5898d into KakaoCup:master Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants