Skip to content
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

Espresso.pressBack() sometimes throw "Pressed back and killed the app" while it actually didn't #47

Closed
GoogleCodeExporter opened this issue Mar 18, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link
Collaborator

What steps will reproduce the problem?
Write Espresso.pressBack() on the activity where pressing back once doesn't 
exit the app.

What is the expected output? What do you see instead?
Expected: The app does what it is expected to do when back is pressed
Actual: 
com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException: 
Pressed back and killed the app

What version of the product are you using? On what operating system?
Espresso 1.1

Please provide any additional information below.
This is a very rare problem, but it happens. I know know how UiController 
handles activity lifecycle, but it seems like it doesn't wait until activity to 
be resumed to continue. As a result, the following codes at the end of 
pressBack() can sometimes get no activity, because it's in the middle of 
switching activity:

    if (this.key.getKeyCode() == KeyEvent.KEYCODE_BACK) {
      controller.loopMainThreadUntilIdle();
      boolean activeActivities = !ActivityLifecycleMonitorRegistry.getInstance()
          .getActivitiesInStage(Stage.RESUMED)
          .isEmpty();
      if (!activeActivities) {
        Throwable cause = new PerformException.Builder()
          .withActionDescription(this.getDescription())
          .withViewDescription(HumanReadables.describe(view))
          .build();
        throw new NoActivityResumedException("Pressed back and killed the app", cause);
      }
    }

I checked my error log and found that it calls 
getActivitiesInStage(Stage.RESUMED) when my previous activity is in pause and 
the next activity which should show up after the back was still on its way to 
resumed.

Original issue reported on code.google.com by K76...@gmail.com on 17 Jan 2014 at 5:53

@GoogleCodeExporter
Copy link
Collaborator Author

Original comment by vale...@google.com on 7 May 2014 at 4:44

  • Changed state: Duplicate

@GoogleCodeExporter
Copy link
Collaborator Author

This was not a dupe of #55.

This has been fixed internally - targeted for Espresso 1.2 publicly

Original comment by thoma...@google.com on 8 Oct 2014 at 8:43

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant