-
Notifications
You must be signed in to change notification settings - Fork 319
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
ActivityScenario: expectations for Activity.isTaskRoot() behavior #427
Comments
You can start the activity with intent (
works for me |
The issue occurs when you call
|
I'm not sure this is directly related, but once I migrated to ActivityScenario, my tests involving opening deep links started failing, since NavigationComponent will now recreate the stack, but not pop it when pressing back button for example. The only change was to migrate to ActivityScenario, and we did pass |
Is there any update on this? Seeing as |
Similar situation here, we have very large tests flowing through several activities. We have a launcher activity that relies on |
@brettchabot can you please provide an update here? It stops all of us from migrating from ActivityTestRule for tests using deep links. |
Same here ! I want to test if the Activity A is shown after I open the Activity B with a Deeplink and close the Activity B |
I've made a custom workaround, which registers ActivityLifecycleCallbacks and saves / removes Activities to a stack. Then I check whether a given Activity is the task root as follows:
|
What i've done to solve this issue is to use a bundle argument to disable the check:
and when i launch:
It's a bit hacky, but it works. |
Update 2022_02_11
Description
When using
ActivityScenario
to test activities, the activity under test is not considered as the task root. I guess this is by design sinceFLAG_ACTIVITY_NEW_TASK
is masked when launched viaBootstrapActivity
inInstrumentationActivityInvoker
. For activities that make use ofActivity.isTaskRoot()
this could lead to unexpected behaviors during testing since the activity under test isn't actually the root of the task. This is a behavior change compared to running the test withActivityTestRule
or in some cases compared to running the real application. Is it reasonable to expect the activity under test to be considered as the task root even if it is somehow faked or configurable to return true?Steps to Reproduce
minimal sample:
Expected Results
Be able to test activities that are making use of
isTaskRoot()
reliably.Actual Results
scenario test case cannot run
onActivity
since the activity is immediately finished.testRule test case works as expected.
AndroidX Test and Android OS Versions
1.2.1-alpha02, API 28
The text was updated successfully, but these errors were encountered: