Fixed
Status Update
Comments
ku...@google.com <ku...@google.com>
ku...@google.com <ku...@google.com> #2
Seems like it happens on API 21-22 too.
nk...@google.com <nk...@google.com>
ma...@gmail.com <ma...@gmail.com> #3
This is expected. You are calling: enqueueUniquePeriodicWork() with an ExistingPeriodicWorkPolicy.REPLACE. This will cancel running work, and kick off new instances of all Workers.
https://github.com/rubensousa/WorkManagerKitkatBug/blob/master/app/src/main/java/com/github/rubensousa/workkitkatbug/MainActivity.kt#L24
nk...@google.com <nk...@google.com> #4
I just ran the sample again and now the behaviour is different for some weird reason. I forgot to mention that I only used REPLACE to test this properly. Because it also happens with KEEP.
nk...@google.com <nk...@google.com> #5
And shouldn't the behaviour be consistent across all Android versions?
Description
Version used: "1.0.1"
What steps will reproduce the problem?
Test an `Activity`'s `setResult()` using `ActivityTestRule.getActivityResult()` and Espresso.
If the activity undergoes a configuration change (such as display rotation) during the test, `ActivityTestRule.getActivity()` will still return the previous instance of the activity (the one existing before the configuration change). This will make any subsequent calls to `ActivityTestRule.getActivityResult()` throw `IllegalStateException` with error message: "Activity is not finishing!".
Example code snippet:
@Rule
public ActivityTestRule<MyActivity> rule = new ActivityTestRule<>(MyActivity.class);
@Test
public void myTest() throws Exception {
rule.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Espresso.onView(ViewMatchers.withId(R.id.button)).perform(click()); // In MyActivity this button click will trigger setResult() and finish().
Instrumentation.ActivityResult result = activityTestRule.getActivityResult(); // Test will crash here.
}