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

Run iOS UIKit instrumented tests on simulator #1396

Merged
merged 19 commits into from
Jul 5, 2024

Conversation

ASalavei
Copy link
Collaborator

@ASalavei ASalavei commented Jun 8, 2024

Run iOS UIKit tests on simulator
Implement basic keyboard appearing tests

Improvements needed:

  • It's impossible to get a screenshot while running tests.
  • Keyboard should be operated manually when running tests.

Release Notes

Run iOS UIKit instrumented tests on simulator

@ASalavei ASalavei changed the title Andrei.salavei/run xctests Run iOS UIKit tests on simulator Jun 11, 2024
Copy link
Member

@MatkovIvan MatkovIvan left a comment

Choose a reason for hiding this comment

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

cc @m-sasha as ui-test owner where you're inctroducing new public APIs
cc @igordmn / @eymar for changes in buildSrc

Comment on lines 61 to 66
val density = Density(density = UIScreen.mainScreen().scale.toFloat())
val window = UIWindow(frame = UIScreen.mainScreen().bounds())
val screenSize = DpSize(
width = UIScreen.mainScreen().bounds().useContents { size.width.dp },
height = UIScreen.mainScreen().bounds().useContents { size.height.dp }
)
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid multiple calls of UIScreen.mainScreen() function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 158 to 161
fun <T> waitToEquals(expected: () -> T, actual: () -> T, deadline: Duration = 1.seconds) {
waitForExpectation(deadline) {
expected() == actual()
}
Copy link
Member

Choose a reason for hiding this comment

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

  1. I don't think that we need to redefine asserts here
  2. Waiting should be based on isIdle check but not on comparing exect/actual from assert

Copy link
Collaborator Author

@ASalavei ASalavei Jun 12, 2024

Choose a reason for hiding this comment

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

As I mentioned, isIdle does not work correctly when we're not bound with manually operating clocks.
I will be working on the proper implementation in the following MRs.

@@ -262,4 +266,30 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
iosSimulatorArm64("uikitSimArm64") { configureFreeCompilerArgs() }
}
}

override fun configureTestsRunInIosSimulatorEnvironment(device: String?): Unit =
Copy link
Member

Choose a reason for hiding this comment

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

We need to be ready to combine AndroidXCompose copy back into AndroidXExtension (used in AOSP and in fork for lifecycle modules).

Please do that changes in AndroidXPlugin instead of AndroidXComposePlugin (or at least in both places).

Copy link
Collaborator Author

@ASalavei ASalavei Jun 12, 2024

Choose a reason for hiding this comment

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

After discussion with @eymar , we decided to place it here. Let's discuss one more time to have clear understanding.

Copy link
Member

Choose a reason for hiding this comment

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

We need to be ready to combine AndroidXCompose copy back into AndroidXExtension (used in AOSP and in fork for lifecycle modules).

Please do that changes in AndroidXPlugin instead of AndroidXComposePlugin (or at least in both places).

Copy link
Collaborator Author

@ASalavei ASalavei Jun 14, 2024

Choose a reason for hiding this comment

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

Discussed. Keep it in AndroidXCompose for now.

@@ -146,6 +146,7 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
wasm()

configureDarwinFlags()
configureTestsRunInIosSimulatorEnvironment()
Copy link
Member

Choose a reason for hiding this comment

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

Why should it be explicit call for each module?

Copy link
Collaborator Author

@ASalavei ASalavei Jun 12, 2024

Choose a reason for hiding this comment

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

It should be explicit call for the module that support tests with booted simulator. For now, only one module needs this environment.

@MatkovIvan MatkovIvan requested a review from m-sasha June 11, 2024 23:19
@ASalavei
Copy link
Collaborator Author

cc @m-sasha as ui-test owner where you're inctroducing new public APIs

@igordmn , to be clear: we're implementing integration tests for iOS platform, which are not UI tests in their classic definition.

@ASalavei ASalavei changed the title Run iOS UIKit tests on simulator [WIP] Run iOS UIKit tests on simulator Jun 12, 2024
@m-sasha
Copy link

m-sasha commented Jun 13, 2024

Without going too deep into the implementation itself, a few concerns:

  1. Should this be in the ui-test module? Perhaps it's better to introduce a new module.
  2. A test API with a "live" app is useful on all target platforms, not just iOS. If we want to release it publicly (even if experimental) perhaps we should design/discuss it upfront, so that we could have a common (or at least cohesive) API across platforms.

@ASalavei ASalavei changed the title [WIP] Run iOS UIKit tests on simulator Run iOS UIKit instrumented tests on simulator Jun 14, 2024
@ASalavei ASalavei marked this pull request as ready for review June 14, 2024 14:39
@ASalavei ASalavei requested a review from MatkovIvan June 14, 2024 14:39
@ASalavei
Copy link
Collaborator Author

Without going too deep into the implementation itself, a few concerns:

  1. Should this be in the ui-test module? Perhaps it's better to introduce a new module.
  2. A test API with a "live" app is useful on all target platforms, not just iOS. If we want to release it publicly (even if experimental) perhaps we should design/discuss it upfront, so that we could have a common (or at least cohesive) API across platforms.

Test was extracted into another source-set uikitInstrumentedTest (analog to androidInstrumentedTest), to run integration tests having properly configured iOS environment.

compose/ui/ui/build.gradle Outdated Show resolved Hide resolved
@ASalavei ASalavei requested a review from m-sasha June 25, 2024 17:57
@ASalavei ASalavei force-pushed the andrei.salavei/run-xctests branch from dfcc821 to cad7f4c Compare July 2, 2024 15:43
@ASalavei ASalavei requested a review from MatkovIvan July 2, 2024 15:45
Copy link
Collaborator

@igordmn igordmn left a comment

Choose a reason for hiding this comment

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

buildSrc changes LGTM

@ASalavei ASalavei merged commit 5a1befe into jb-main Jul 5, 2024
10 checks passed
@ASalavei ASalavei deleted the andrei.salavei/run-xctests branch July 5, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants