Fixed
Status Update
Comments
ku...@google.com <ku...@google.com>
ku...@google.com <ku...@google.com> #2
The link in the above description doesn't work external to google, expanded link: https://issuetracker.google.com/issues/73450636
nk...@google.com <nk...@google.com>
ma...@gmail.com <ma...@gmail.com> #3
This will be fixed in the next release.
nk...@google.com <nk...@google.com> #4
This will be fixed in the upcoming Runner/Rules v1.0.2 release.
nk...@google.com <nk...@google.com> #5
The release is not out yet but marking this as fixed for now.
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.
}