Bug 1469683 - 3. Make sure cached session is closed after crash; r?esawin
If @IgnoreCrash is specified, assume there has been a crash and
therefore wait for the cached session to close at the end of the test,
so that the closing operation doesn't carry over to the next test.
MozReview-Commit-ID: KrMfHgIiELQ
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
@@ -1396,18 +1396,30 @@ public class GeckoSessionTestRule extend
mCallRecordHandler = null;
}
}
/**
* Internal method to perform callback checks at the end of a test.
*/
public void performTestEndCheck() {
+ if (sCachedSession != null && mIgnoreCrash) {
+ // Make sure the cached session has been closed by crashes.
+ while (sCachedSession.isOpen()) {
+ loopUntilIdle(mTimeoutMillis);
+ }
+ }
+
mWaitScopeDelegates.clearAndAssert();
mTestScopeDelegates.clearAndAssert();
+
+ if (sCachedSession != null && mReuseSession) {
+ assertThat("Cached session should be open",
+ sCachedSession.isOpen(), equalTo(true));
+ }
}
protected void cleanupSession(final GeckoSession session) {
final Tab tab = (mRDPTabs != null) ? mRDPTabs.get(session) : null;
if (tab != null) {
if (session.isOpen()) {
tab.getPromises().detach();
tab.detach();
@@ -1419,35 +1431,31 @@ public class GeckoSessionTestRule extend
session.close();
}
}
protected boolean isUsingSession(final GeckoSession session) {
return session.equals(mMainSession) || mSubSessions.contains(session);
}
- protected void deleteCrashDumps() {
+ protected static void deleteCrashDumps() {
File dumpDir = new File(sRuntime.getProfileDir(), "minidumps");
for (final File dump : dumpDir.listFiles()) {
dump.delete();
}
}
protected void cleanupStatement() throws Throwable {
mWaitScopeDelegates.clear();
mTestScopeDelegates.clear();
for (final GeckoSession session : mSubSessions) {
cleanupSession(session);
}
- if (sCachedSession != null && mReuseSession && !mIgnoreCrash) {
- assertThat("Cached session should be open", sCachedSession.isOpen(), equalTo(true));
- }
-
if (mMainSession.isOpen() && mMainSession.equals(sCachedSession)) {
// We have to detach the Promises object, but keep the Tab itself.
sCachedRDPTab.getPromises().detach();
} else {
cleanupSession(mMainSession);
}
if (mIgnoreCrash) {