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

Delete AppLifecycleTests testDismissedFlutterViewControllerNotRespondingToApplicationLifecycle #32971

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 0 additions & 103 deletions testing/scenario_app/ios/Scenarios/ScenariosTests/AppLifecycleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,109 +197,6 @@ - (void)skip_testDismissedFlutterViewControllerNotRespondingToApplicationLifecyc
[engine destroyContext];
}

- (void)skip_testVisibleFlutterViewControllerRespondsToApplicationLifecycle {
XCTestExpectation* engineStartedExpectation = [self expectationWithDescription:@"Engine started"];

// Let the engine finish booting (at the end of which the channels are properly set-up) before
// moving onto the next step of showing the next view controller.
ScreenBeforeFlutter* rootVC = [[ScreenBeforeFlutter alloc] initWithEngineRunCompletion:^void() {
[engineStartedExpectation fulfill];
}];

[self waitForExpectationsWithTimeout:5 handler:nil];

UIApplication* application = UIApplication.sharedApplication;
application.delegate.window.rootViewController = rootVC;
FlutterEngine* engine = rootVC.engine;

NSMutableArray* lifecycleExpectations = [NSMutableArray arrayWithCapacity:10];

// Expected sequence from showing the FlutterViewController is inactive and resumed.
[lifecycleExpectations addObjectsFromArray:[self initialPresentLifecycles]];

[engine.lifecycleChannel setMessageHandler:^(id message, FlutterReply callback) {
if (lifecycleExpectations.count == 0) {
XCTFail(@"Unexpected lifecycle transition: %@", message);
return;
}
XCAppLifecycleTestExpectation* nextExpectation = [lifecycleExpectations objectAtIndex:0];
if (![[nextExpectation expectedLifecycle] isEqualToString:message]) {
XCTFail(@"Expected lifecycle %@ but instead received %@", [nextExpectation expectedLifecycle],
message);
return;
}

[nextExpectation fulfill];
[lifecycleExpectations removeObjectAtIndex:0];
}];

FlutterViewController* flutterVC;
@autoreleasepool {
XCTestExpectation* vcShown = [self expectationWithDescription:@"present"];
flutterVC = [rootVC showFlutter:^{
[vcShown fulfill];
}];
[self waitForExpectationsWithTimeout:5.0 handler:nil];
[self waitForExpectations:lifecycleExpectations timeout:5];

// Now put the FlutterViewController into background.
[lifecycleExpectations addObjectsFromArray:@[
[[XCAppLifecycleTestExpectation alloc]
initForLifecycle:@"AppLifecycleState.inactive"
forStep:@"putting FlutterViewController to the background"],
[[XCAppLifecycleTestExpectation alloc]
initForLifecycle:@"AppLifecycleState.paused"
forStep:@"putting FlutterViewController to the background"]
]];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationDidEnterBackgroundNotification
object:nil];
[self waitForExpectations:lifecycleExpectations timeout:5];

// Now restore to foreground
[lifecycleExpectations addObjectsFromArray:@[
[[XCAppLifecycleTestExpectation alloc]
initForLifecycle:@"AppLifecycleState.inactive"
forStep:@"putting FlutterViewController back to foreground"],
[[XCAppLifecycleTestExpectation alloc]
initForLifecycle:@"AppLifecycleState.resumed"
forStep:@"putting FlutterViewController back to foreground"]
]];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationWillEnterForegroundNotification
object:nil];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationDidBecomeActiveNotification
object:nil];
[self waitForExpectations:lifecycleExpectations timeout:5];

// The final dismissal cycles through inactive and paused again.
[lifecycleExpectations addObjectsFromArray:@[
[[XCAppLifecycleTestExpectation alloc] initForLifecycle:@"AppLifecycleState.inactive"
forStep:@"popping the FlutterViewController"],
[[XCAppLifecycleTestExpectation alloc]
initForLifecycle:@"AppLifecycleState.paused"
forStep:@"popping the FlutterViewController"]
]];
XCTestExpectation* vcDismissed = [self expectationWithDescription:@"dismiss"];
[flutterVC dismissViewControllerAnimated:NO
completion:^{
[vcDismissed fulfill];
}];
[self waitForExpectationsWithTimeout:5.0 handler:nil];
flutterVC = nil;
[engine setViewController:nil];
}

// Dismantle.
[engine.lifecycleChannel setMessageHandler:nil];
[rootVC dismissViewControllerAnimated:NO completion:nil];
[engine destroyContext];
}

- (void)skip_testFlutterViewControllerDetachingSendsApplicationLifecycle {
XCTestExpectation* engineStartedExpectation = [self expectationWithDescription:@"Engine started"];

Expand Down