Skip to content

Commit

Permalink
[iOS] Reenable device restore tests for devices.
Browse files Browse the repository at this point in the history
The tests can pass on device now, Reenable every test under the bug
number and test utility.

Bug: 1067821
Change-Id: I1fdbeed8bb42eb47705f883426def8e67287d1a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523306
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Eugene But <eugenebut@chromium.org>
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827936}
  • Loading branch information
Zhaoyang Li authored and Commit Bot committed Nov 16, 2020
1 parent 1258642 commit 134c7d5
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 23 deletions.
6 changes: 0 additions & 6 deletions ios/chrome/browser/web/restore_egtest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,10 @@ - (void)setUpRestoreServers {
}

- (void)triggerRestore {
// TODO(crbug.com/1067821):|AppLaunchManager| relaunching with
// |ForceRelaunchByCleanShutdown| policy won't work on real device.
#if !TARGET_IPHONE_SIMULATOR
[ChromeEarlGrey triggerRestoreViaTabGridRemoveAllUndo];
#else
[ChromeEarlGrey saveSessionImmediately];
[[AppLaunchManager sharedManager] ensureAppLaunchedWithFeaturesEnabled:{}
disabled:{}
relaunchPolicy:ForceRelaunchByCleanShutdown];
#endif
}

- (void)loadTestPages {
Expand Down
4 changes: 0 additions & 4 deletions ios/chrome/test/earl_grey2/smoke_egtest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,12 @@ - (void)testAppLaunchManagerLaunchWithArbitraryArgs {

// Tests gracefully kill through AppLaunchManager.
- (void)testAppLaunchManagerForceRelaunchByCleanShutdown {
// TODO(crbug.com/1067821): ForceRelaunchByCleanShutdown only compiles and works
// on simulator.
#if TARGET_IPHONE_SIMULATOR
[ChromeEarlGrey openNewTab];
[[AppLaunchManager sharedManager] ensureAppLaunchedWithFeaturesEnabled:{}
disabled:{}
relaunchPolicy:ForceRelaunchByCleanShutdown];
[[EarlGrey selectElementWithMatcher:grey_text(@"Restore")]
assertWithMatcher:grey_notVisible()];
#endif
}

// Tests hard kill(crash) through AppLaunchManager.
Expand Down
4 changes: 0 additions & 4 deletions ios/testing/earl_grey/app_launch_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ typedef NS_ENUM(NSInteger, RelaunchPolicy) {
// Forces a relaunch. Kills the app directly. Keeps app state the same as
// before relaunch.
ForceRelaunchByKilling,
// TODO(crbug.com/1067821): This relaunch policy will cause failures in real
// devices.
#if TARGET_IPHONE_SIMULATOR
// Forces a relaunch. Backgrounds and then kills the app. Keeps app state same
// as before relaunch.
ForceRelaunchByCleanShutdown,
#endif
};

// Configuration for launching the app in EGTests.
Expand Down
11 changes: 2 additions & 9 deletions ios/testing/earl_grey/app_launch_manager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,9 @@ - (instancetype)initPrivate {
// In EG1, this method is a no-op.
- (void)ensureAppLaunchedWithArgs:(NSArray<NSString*>*)arguments
relaunchPolicy:(RelaunchPolicy)relaunchPolicy {
// TODO(crbug.com/1067821): ForceRelaunchByCleanShutdown doesn't compile on
// real devices.
#if TARGET_IPHONE_SIMULATOR
BOOL forceRestart = (relaunchPolicy == ForceRelaunchByKilling) ||
(relaunchPolicy == ForceRelaunchByCleanShutdown);
BOOL gracefullyKill = (relaunchPolicy == ForceRelaunchByCleanShutdown);
#else
BOOL forceRestart = (relaunchPolicy == ForceRelaunchByKilling);
BOOL gracefullyKill = NO;
#endif // TARGET_IPHONE_SIMULATOR
BOOL runResets = (relaunchPolicy == NoForceRelaunchAndResetState);

// If app has crashed, |self.runningApplication| will be at
Expand Down Expand Up @@ -149,13 +142,13 @@ - (void)ensureAppLaunchedWithArgs:(NSArray<NSString*>*)arguments
}

if (appIsRunning) {
[CoverageUtils writeClangCoverageProfile];

if (gracefullyKill) {
GREYAssertTrue([EarlGrey backgroundApplication],
@"Failed to background application.");
}

[CoverageUtils writeClangCoverageProfile];

[self.runningApplication terminate];
}

Expand Down

0 comments on commit 134c7d5

Please sign in to comment.