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

CfW: add a test for Text Baseline #1314

Merged
merged 7 commits into from
May 1, 2024
Merged

Conversation

eymar
Copy link
Collaborator

@eymar eymar commented Apr 24, 2024

The issue JetBrains/compose-multiplatform#4078 was fixed earlier. Probably in skiko: JetBrains/skiko#846

@eymar eymar requested a review from Schahen April 24, 2024 11:53
modifier = Modifier.alignByBaseline()
.onGloballyPositioned {
headingOnPositioned.trySend(it[FirstBaseline])
println("The heading alignment line is ${it[FirstBaseline]}\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we keep this println in test?

assertTrue(headingAlignment > 0)
assertTrue(subtitleAlignment > 0)
assertTrue(headingAlignment > subtitleAlignment)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two questions\suggestions here. First one (more of a suggestion than question) if we do believe that the actual tests would check for something being bigger than specific value, then we can introduce a specialised assertion - so that we'll immediately see which of three has failed and with was exactly value. Something like assertIsGreater

Second (more of a question rather a suggestion) - is it enough? I mean knowng that something is greater than zero? Can we check for a specific value, even with tolerance or something?

Copy link
Collaborator Author

@eymar eymar Apr 24, 2024

Choose a reason for hiding this comment

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

Can we check for a specific value, even with tolerance or something?

I noticed that the actual value on CI is a bit smaller than on my machine. And it's okay. The actual value depends on the screen resolution (and density too), I guess.

I think that pre-calculating the exact expected value is possible, but it would likely contain some hardcode anyway. And then if, for example, the default font changes, the expected value will need to be updated.

Given it's something device specific, I decided to simplify the check to avoid surprising test failures on some machines.


assertIsGreater - ACK

Copy link
Collaborator

Choose a reason for hiding this comment

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

🤝

import kotlinx.browser.document
import org.w3c.dom.HTMLCanvasElement

internal interface OnCanvasTests {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A small doc won't harm - like this interfaces is supposed to be used in such and such cases. I mean, it can be obvious to you and to me but not necessarily for our coworkers, current of future )

@eymar eymar force-pushed the ok/add_text_for_text_baseline branch from a02d87a to 6fb7e9d Compare April 30, 2024 14:54
@eymar eymar merged commit 6b67281 into jb-main May 1, 2024
6 checks passed
@eymar eymar deleted the ok/add_text_for_text_baseline branch May 1, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants