Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Yes, providing something like our internal ActivityScenario.withActivity
FragmentScenario
.
The key part is returning a result and rethrowing exceptions.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 081112f1ba20684bebf5dcace0b9bdc39a403d90
Author: Ian Lake <ilake@google.com>
Date: Wed Jun 10 17:18:57 2020
Add FragmentScenario.withFragment for returning a result
Provide an alternative to onFragment for Kotlin
users in withActivity. withActivity notably returns
a result and rethrows any exceptions raised in the
given block.
Test: new FragmentScenarioTest tests
BUG: 158697631
Change-Id: If28636adc7c54e9fa7e92f1992323b1b270222be
M fragment/fragment-testing/api/1.3.0-alpha07.txt
M fragment/fragment-testing/api/current.txt
M fragment/fragment-testing/api/public_plus_experimental_1.3.0-alpha07.txt
M fragment/fragment-testing/api/public_plus_experimental_current.txt
M fragment/fragment-testing/api/restricted_1.3.0-alpha07.txt
M fragment/fragment-testing/api/restricted_current.txt
M fragment/fragment-testing/src/androidTest/java/androidx/fragment/app/testing/FragmentScenarioTest.kt
M fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.kt
https://android-review.googlesource.com/1330480
Branch: androidx-master-dev
commit 081112f1ba20684bebf5dcace0b9bdc39a403d90
Author: Ian Lake <ilake@google.com>
Date: Wed Jun 10 17:18:57 2020
Add FragmentScenario.withFragment for returning a result
Provide an alternative to onFragment for Kotlin
users in withActivity. withActivity notably returns
a result and rethrows any exceptions raised in the
given block.
Test: new FragmentScenarioTest tests
BUG: 158697631
Change-Id: If28636adc7c54e9fa7e92f1992323b1b270222be
M fragment/fragment-testing/api/1.3.0-alpha07.txt
M fragment/fragment-testing/api/current.txt
M fragment/fragment-testing/api/public_plus_experimental_1.3.0-alpha07.txt
M fragment/fragment-testing/api/public_plus_experimental_current.txt
M fragment/fragment-testing/api/restricted_1.3.0-alpha07.txt
M fragment/fragment-testing/api/restricted_current.txt
M fragment/fragment-testing/src/androidTest/java/androidx/fragment/app/testing/FragmentScenarioTest.kt
M fragment/fragment-testing/src/main/java/androidx/fragment/app/testing/FragmentScenario.kt
il...@google.com <il...@google.com> #4
This has been fixed internally and will be available in Fragment 1.3.0-alpha07
.
Description
Component used: fragment-testing
It would be great to have a
FragmentScenario.withFragment()
extension function which has equivalent capabilities toActivityScenario.withActivity()
(return value, caching and rethrowing of exceptions).If it's helpful, I have added this to one of my tests here . It is a direct port of
ActivityScenario.withActivity()
, so I'm not sure if I'm missing any fragment-specific considerations, but it has been working for my use case.