-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Guards and null checks against unsaved fragment transactions on configuration change #4374
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
Conversation
…guration change Fixes TeamAmaze#1555
Build test apk |
The requested APKs has been built. Please find them from the artifacts section of this PR. |
|
||
// Force a configuration change by rotating the screen | ||
activityRule.activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE | ||
Thread.sleep(1000) // Give time for the rotation to complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is using a constant time correct here? Doesn't it depend on the speed of the device whether it crashes or not?
Got this when rotating after exiting the app for a bit:
But I think it might not be related. |
I cannot replicate the original bug in my Moto G73, app might be going too smoothly. Will try to replicate with just the tests. |
Okay, executing the emulator tests, I get the notifications permission request and the storage permissions popup. And the tests fail with:
Emulator: Pixel 9 API 34 |
@@ -83,7 +84,7 @@ public class TabFragment extends Fragment { | |||
private boolean savePaths; | |||
private FragmentManager fragmentManager; | |||
|
|||
private final List<Fragment> fragments = new ArrayList<>(); | |||
final List<Fragment> fragments = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be public only for tests. Add @VisibleForTesting
For the robolectric tests, they pass both before and after the changes, which suggests it doesn't add as much new info. |
Indeed, as desktop JVM generally runs faster than Dalvik. Robolectric tests are just for keeping tests at par with Espresso ones. |
The nearest thing I can find: https://stackoverflow.com/questions/75814428/accessing-storage-from-orchestrated-espresso-test Seems Espresso itself isn't going to do anything about this... yet. |
@TranceLove I've added a test and a few fixes, I would approve merging as is, closing the old issue and waiting for new reports. |
Description
Issue tracker
Fixes #1555
Automatic tests
Manual tests
Build tasks success
Successfully running following tasks on local:
./gradlew assembledebug
./gradlew spotlessCheck