Closed GoogleCodeExporter closed 9 years ago
I think there's a problem in this code, because this is where the exception was
thrown
RootViewPicker
private void waitForAtLeastOneActivityToBeResumed() {
Collection<Activity> resumedActivities =
activityLifecycleMonitor.getActivitiesInStage(Stage.RESUMED);
if (resumedActivities.isEmpty()) {
uiController.loopMainThreadUntilIdle();
resumedActivities = activityLifecycleMonitor.getActivitiesInStage(Stage.RESUMED);
}
if (resumedActivities.isEmpty()) {
List<Activity> activities = Lists.newArrayList();
for (Stage s : EnumSet.range(Stage.PRE_ON_CREATE, Stage.RESTARTED)) {
activities.addAll(activityLifecycleMonitor.getActivitiesInStage(Stage.RESUMED));
}
if (activities.isEmpty()) {
throw new RuntimeException("No activities found. Did you forget to launch the activity "
+ "by calling getActivity() or startActivitySync or similar?");
}
When there's no activity in resumed state, it tries to find all activities in
other states. However, when calling to the activitymonitor, it still passes
Stage.RESUME in. It should be:
for (Stage s : EnumSet.range(Stage.PRE_ON_CREATE, Stage.RESTARTED)) {
activities.addAll(activityLifecycleMonitor.getActivitiesInStage(s));
}
Original comment by K76...@gmail.com
on 19 Dec 2013 at 6:22
There's another problem in the method:
for (int waitIdx = 0; waitIdx < waitTimes.length; waitIdx++) {
Log.w(TAG, "No activity currently resumed - waiting: " + waitTimes[waitIdx]
+ "ms for one to appear.");
uiController.loopMainThreadForAtLeast(waitTimes[waitIdx]);
resumedActivities = activityLifecycleMonitor.getActivitiesInStage(Stage.RESUMED);
if (!resumedActivities.isEmpty()) {
break;
}
}
throw new RuntimeException("No activities in stage RESUMED. Did you forget to launch the "
+ "activity. (test.getActivity() or similar)?");
Even if it gets the resumed activities in the for loop, it will still throw the
exception. It should be
if(resumedActivities.isEmpty())
{
throw new RuntimeException("No activities in stage RESUMED. Did you forget to launch the "
+ "activity. (test.getActivity() or similar)?");
}
Original comment by K76...@gmail.com
on 29 Dec 2013 at 11:32
Thanks for reporting. Will be fixed in the next release.
Original comment by vale...@google.com
on 2 Jan 2014 at 9:22
Fixed in 1.1
Original comment by vale...@google.com
on 9 Jan 2014 at 7:34
Using 1.1 but still having this issue
Original comment by marconi....@gmail.com
on 9 Mar 2014 at 4:01
Same here, this is still a problem
Original comment by kot...@gmail.com
on 8 Jan 2015 at 7:47
I confirm that the issue still occurs on Espresso 2.0. Marking this as FIXED
seems premature to me.
Original comment by morawski...@gmail.com
on 31 Jan 2015 at 10:53
getActivity() cause app crash.
it mention about attempt to invoke virtual method.
Original comment by jasonars...@gmail.com
on 18 Feb 2015 at 2:56
Original issue reported on code.google.com by
K76...@gmail.com
on 18 Dec 2013 at 6:31