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

Adopt IdlingResource move from commonMain to supporting platforms #1822

Merged
merged 6 commits into from
Feb 10, 2025

Conversation

eymar
Copy link
Member

@eymar eymar commented Feb 5, 2025

CL: https://android-review.googlesource.com/c/platform/frameworks/support/+/3460196

Main changes:

API changes happend only for Experimtal APIs.

eymar added 2 commits February 5, 2025 10:40
Reasoning: Compose for Web can't support blocking waiting for idling
resources. Several methods in `ui-test` require blocking waiting for
idling resources (for example waitForIdle). A non-idle resource would
block a test using it. Since `IdlingResource` usages can’t be reliably
implemented across all Kotlin targets, we choose to exclude it from
`commonMain` to prevent its usage in common tests.

Test: N/A
Change-Id: I3df6e216fa62b7268bfe3aeb7788214eb527d68e
@eymar eymar requested a review from m-sasha February 5, 2025 13:05
@@ -126,7 +124,7 @@ fun defaultTestDispatcher() = UnconfinedTestDispatcher()
*/
@ExperimentalTestApi
@OptIn(InternalTestApi::class, InternalComposeUiApi::class)
class SkikoComposeUiTest @InternalTestApi constructor(
open class SkikoComposeUiTest @InternalTestApi constructor(
Copy link
Member Author

@eymar eymar Feb 5, 2025

Choose a reason for hiding this comment

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

Why I think it's okay to make it open:

  • it's experimental, so such changes are okay. If someone uses/extends it, it's at their own risk.
  • SkikoComposeUiTest is not available in common tests (with Android), which I believe is the main place where the tests should be added in Compose Multiplatform case. Those tests will use only ComposeUiTest interface.
  • In the future, I believe we will need to update this API, since the intention is to not expose "skiko". SkikoComposeUiTest exposes scene, which is convenient, but it's not supposed to be used outside of Compose - InternalComposeUiApi.

@@ -124,47 +121,6 @@ class TestBasicsTest {
}
}

@Test
fun testIdlingResource() = runComposeUiTest {
Copy link
Member Author

Choose a reason for hiding this comment

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

It's moved to IdlingResourceTest in deskopTest

Copy link
Member

Choose a reason for hiding this comment

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

I'd move it to DesktopTestsTest. I don't think it deserves its own file.

(if you do move it, please also fix the typo in the kdoc for that class: "specified" -> "specific").

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 70 to 74
fun runDesktopTest(block: DesktopComposeUiTest.() -> Unit) {
runTest {
block()
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This function looks a bit weird here. It's member of DesktopComposeUiTest, but you don't ever want to call it inside the test itself. The same actually applies to SkikoComposeUiTest.runTest too.

We could make it internal, or get rid of it completely, replacing it with

    with(DesktopComposeUiTest(width, height, effectContext)) {
        runTest { block() }
    }

runTest could just be made internal (because SkikoComposeUiTest is experimental).

Copy link
Member Author

Choose a reason for hiding this comment

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

  • SkikoComposeUiTest.runTest can't be internal because it's used in DesktopComposeTestRule (ui-test-junit4 module).

  • got rid of runDesktopTest

@@ -124,47 +121,6 @@ class TestBasicsTest {
}
}

@Test
fun testIdlingResource() = runComposeUiTest {
Copy link
Member

Choose a reason for hiding this comment

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

I'd move it to DesktopTestsTest. I don't think it deserves its own file.

(if you do move it, please also fix the typo in the kdoc for that class: "specified" -> "specific").

@eymar eymar requested a review from igordmn February 6, 2025 10:21
@eymar eymar added the desktop label Feb 6, 2025
@eymar eymar merged commit 7024ce3 into jb-main Feb 10, 2025
7 checks passed
@eymar eymar deleted the ok/cherry_pick_idling_resource_move branch February 10, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants