Commit 2c70cc56 authored by zhaoyangli's avatar zhaoyangli Committed by Commit Bot

[iOS][EG2]Run TestCase +setUp at next launch after app crashes.

After app unexpectedly crashes in EG2 test, it is relaunched at -setUp
of next testMethod. Currently in this situation, |appNeedsLaunching| is
judged false and app is launched without TestCase +setUps at |activate|
method, which will cause DCHECK failures at +tearDown. This change makes
|appNeedsLaunching| judged true in this situation and run TestCase
+setUps after the relaunch to prevent DCHECK failures.

Bug: 1023911
Change-Id: I83bd06df7afdf2402fbb0593a6825910107534f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037852Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739118}
parent ae9e77e9
......@@ -76,16 +76,24 @@ bool LaunchArgumentsAreEqual(NSArray<NSString*>* args1,
BOOL gracefullyKill = (relaunchPolicy == ForceRelaunchByCleanShutdown);
BOOL runResets = (relaunchPolicy == NoForceRelaunchAndResetState);
// If app has crashed, |self.runningApplication| will be at
// |XCUIApplicationStateNotRunning| state and it should be relaunched with
// proper resets. The app also needs a relaunch if it's at
// |XCUIApplicationStateUnknown| state.
BOOL appIsRunning =
(self.runningApplication != nil) &&
(self.runningApplication.state != XCUIApplicationStateNotRunning) &&
(self.runningApplication.state != XCUIApplicationStateUnknown);
bool appNeedsLaunching =
forceRestart || !self.runningApplication ||
forceRestart || !appIsRunning ||
!LaunchArgumentsAreEqual(arguments, self.currentLaunchArgs);
if (!appNeedsLaunching) {
[self.runningApplication activate];
return;
}
if (self.runningApplication) {
if (appIsRunning) {
if (gracefullyKill) {
GREYAssertTrue([EarlGrey backgroundApplication],
@"Failed to background application.");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment