Skip to content

Configurable scenario supplier #301

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

Merged

Conversation

compscidr
Copy link
Contributor

Based on this comment: #234 (comment) - I think this will let us be able to run Activities with an intent upon startup.

It still keeps the same behavior as present if the extra parameter is left out since it has a default value, but gives us the flexibility to use a scenario supplier that uses alternate launch options.

for instance we could now do something like:

@OptIn(ExperimentalTestApi::class)
@JvmField
@RegisterExtension
val extension = createAndroidComposeExtension<SomeActivity>(
  scenarioSupplier = { 
    val intent = Intent()
    intent.putExtra("someExtra", true)
    ActivityScenario.launch(intent)
  }
)

https://developer.android.com/reference/androidx/test/core/app/ActivityScenario#launch(android.content.Intent)

Copy link
Owner

@mannodermaus mannodermaus left a comment

Choose a reason for hiding this comment

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

Thank you for contributing! I can see the need to allow custom intents for launching some Activities, so this sounds like a good extension. In addition to my comment about the Javadoc, please also run ./gradlew compose:apiDump and check in the updated API surface file. Thanks!

Comment on lines 49 to 53
@ExperimentalTestApi
public inline fun <reified A : ComponentActivity> createAndroidComposeExtension(noinline scenarioSupplier: () -> ActivityScenario<A>): AndroidComposeExtension<A> {
return createAndroidComposeExtension(A::class.java, scenarioSupplier)
}

Copy link
Owner

Choose a reason for hiding this comment

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

Please add a Javadoc to this! You can copy from the overloaded method and edit the text as necessary.

@compscidr
Copy link
Contributor Author

Okay, I think I have made the changes as you suggested. Let me know if you need anything else.

Copy link
Owner

@mannodermaus mannodermaus left a comment

Choose a reason for hiding this comment

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

Appreciated, thank you. LGTM!

@mannodermaus mannodermaus merged commit 4c200a0 into mannodermaus:main Aug 30, 2023
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.

2 participants