Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit bebce3d

Browse files
committed
clean up
1 parent fb75e54 commit bebce3d

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

shell/platform/darwin/ios/framework/Source/FlutterViewController.mm

-8
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ - (void)viewWillAppear:(BOOL)animated {
607607
if (_viewportMetrics.physical_width) {
608608
[self surfaceUpdated:YES];
609609
}
610-
NSLog(@"FlutterViewController instance %@ is viewWillAppear", self);
611610
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.inactive"];
612611

613612
[super viewWillAppear:animated];
@@ -617,15 +616,13 @@ - (void)viewDidAppear:(BOOL)animated {
617616
TRACE_EVENT0("flutter", "viewDidAppear");
618617
[self onUserSettingsChanged:nil];
619618
[self onAccessibilityStatusChanged:nil];
620-
NSLog(@"FlutterViewController instance %@ is viewDidAppear", self);
621619
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"];
622620

623621
[super viewDidAppear:animated];
624622
}
625623

626624
- (void)viewWillDisappear:(BOOL)animated {
627625
TRACE_EVENT0("flutter", "viewWillDisappear");
628-
NSLog(@"FlutterViewController instance %@ is viewWillDisappear", self);
629626
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.inactive"];
630627

631628
[super viewWillDisappear:animated];
@@ -635,7 +632,6 @@ - (void)viewDidDisappear:(BOOL)animated {
635632
TRACE_EVENT0("flutter", "viewDidDisappear");
636633
if ([_engine.get() viewController] == self) {
637634
[self surfaceUpdated:NO];
638-
NSLog(@"FlutterViewController instance %@ is viewDidDisappear", self);
639635
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.paused"];
640636
[self flushOngoingTouches];
641637
[_engine.get() notifyLowMemory];
@@ -693,26 +689,22 @@ - (void)applicationBecameActive:(NSNotification*)notification {
693689
TRACE_EVENT0("flutter", "applicationBecameActive");
694690
if (_viewportMetrics.physical_width)
695691
[self surfaceUpdated:YES];
696-
NSLog(@"FlutterViewController instance %@ is applicationBecameActive", self);
697692
[self goToApplicationLifecycle:@"AppLifecycleState.resumed"];
698693
}
699694

700695
- (void)applicationWillResignActive:(NSNotification*)notification {
701696
TRACE_EVENT0("flutter", "applicationWillResignActive");
702697
[self surfaceUpdated:NO];
703-
NSLog(@"FlutterViewController instance %@ is applicationWillResignActive", self);
704698
[self goToApplicationLifecycle:@"AppLifecycleState.inactive"];
705699
}
706700

707701
- (void)applicationDidEnterBackground:(NSNotification*)notification {
708702
TRACE_EVENT0("flutter", "applicationDidEnterBackground");
709-
NSLog(@"FlutterViewController instance %@ is applicationDidEnterBackground", self);
710703
[self goToApplicationLifecycle:@"AppLifecycleState.paused"];
711704
}
712705

713706
- (void)applicationWillEnterForeground:(NSNotification*)notification {
714707
TRACE_EVENT0("flutter", "applicationWillEnterForeground");
715-
NSLog(@"FlutterViewController instance %@ is applicationWillEnterForeground", self);
716708
[self goToApplicationLifecycle:@"AppLifecycleState.inactive"];
717709
}
718710

testing/scenario_app/ios/Scenarios/ScenariosTests/AppLifecycleTests.m

+13-18
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ @implementation AppLifecycleTests
3838
- (void)setUp {
3939
[super setUp];
4040
self.continueAfterFailure = NO;
41+
// Since this test checks for view controller and application lifecycles, the starting point
42+
// must be well defined.
43+
XCTAssertEqual([UIApplication sharedApplication].applicationState, UIApplicationStateActive);
4144
}
4245

4346
- (void)testDismissedFlutterViewControllerNotRespondingToApplicationLifecycle {
4447
XCTestExpectation* engineStartedExpectation = [self expectationWithDescription:@"Engine started"];
45-
4648
// Let the engine finish booting (at the end of which the channels are properly set-up) before
4749
// moving onto the next step of showing the next view controller.
4850
ScreenBeforeFlutter* rootVC = [[ScreenBeforeFlutter alloc] initWithEngineRunCompletion:^void() {
4951
[engineStartedExpectation fulfill];
5052
}];
51-
5253
[self waitForExpectationsWithTimeout:5 handler:nil];
5354

5455
UIApplication* application = UIApplication.sharedApplication;
@@ -64,16 +65,16 @@ - (void)testDismissedFlutterViewControllerNotRespondingToApplicationLifecycle {
6465
[[XCAppLifecycleTestExpectation alloc] initForLifecycle:@"AppLifecycleState.resumed"
6566
forStep:@"showing a FlutterViewController"]
6667
]];
67-
68+
6869
[engine.lifecycleChannel setMessageHandler:^(id message, FlutterReply callback) {
6970
if (lifecycleExpectations.count == 0) {
7071
XCTFail(@"Unexpected lifecycle transition: %@", message);
7172
return;
7273
}
7374
XCAppLifecycleTestExpectation* nextExpectation = [lifecycleExpectations objectAtIndex:0];
7475
if (![[nextExpectation expectedLifecycle] isEqualToString:message]) {
75-
XCTFail(@"Expected lifecycle %@ but instead received %@",
76-
[nextExpectation expectedLifecycle], message);
76+
XCTFail(@"Expected lifecycle %@ but instead received %@", [nextExpectation expectedLifecycle],
77+
message);
7778
return;
7879
}
7980

@@ -91,8 +92,6 @@ - (void)testDismissedFlutterViewControllerNotRespondingToApplicationLifecycle {
9192
[vcShown fulfill];
9293
}];
9394
[self waitForExpectationsWithTimeout:5.0 handler:nil];
94-
NSLog(@"FlutterViewController instance %@ created", flutterVC);
95-
9695
// The expectations list isn't dequeued by the message handler yet.
9796
[self waitForExpectations:lifecycleExpectations timeout:5 enforceOrder:YES];
9897

@@ -208,16 +207,16 @@ - (void)testVisibleFlutterViewControllerRespondsToApplicationLifecycle {
208207
[[XCAppLifecycleTestExpectation alloc] initForLifecycle:@"AppLifecycleState.resumed"
209208
forStep:@"showing a FlutterViewController"]
210209
]];
211-
210+
212211
[engine.lifecycleChannel setMessageHandler:^(id message, FlutterReply callback) {
213212
if (lifecycleExpectations.count == 0) {
214213
XCTFail(@"Unexpected lifecycle transition: %@", message);
215214
return;
216215
}
217216
XCAppLifecycleTestExpectation* nextExpectation = [lifecycleExpectations objectAtIndex:0];
218217
if (![[nextExpectation expectedLifecycle] isEqualToString:message]) {
219-
XCTFail(@"Expected lifecycle %@ but instead received %@",
220-
[nextExpectation expectedLifecycle], message);
218+
XCTFail(@"Expected lifecycle %@ but instead received %@", [nextExpectation expectedLifecycle],
219+
message);
221220
return;
222221
}
223222

@@ -232,8 +231,6 @@ - (void)testVisibleFlutterViewControllerRespondsToApplicationLifecycle {
232231
[vcShown fulfill];
233232
}];
234233
[self waitForExpectationsWithTimeout:5.0 handler:nil];
235-
NSLog(@"FlutterViewController instance %@ created", flutterVC);
236-
237234
[self waitForExpectations:lifecycleExpectations timeout:5];
238235

239236
// Now put the FlutterViewController into background.
@@ -318,23 +315,23 @@ - (void)testFlutterViewControllerDetachingSendsApplicationLifecycle {
318315
[[XCAppLifecycleTestExpectation alloc] initForLifecycle:@"AppLifecycleState.resumed"
319316
forStep:@"showing a FlutterViewController"]
320317
]];
321-
318+
322319
[engine.lifecycleChannel setMessageHandler:^(id message, FlutterReply callback) {
323320
if (lifecycleExpectations.count == 0) {
324321
XCTFail(@"Unexpected lifecycle transition: %@", message);
325322
return;
326323
}
327324
XCAppLifecycleTestExpectation* nextExpectation = [lifecycleExpectations objectAtIndex:0];
328325
if (![[nextExpectation expectedLifecycle] isEqualToString:message]) {
329-
XCTFail(@"Expected lifecycle %@ but instead received %@",
330-
[nextExpectation expectedLifecycle], message);
326+
XCTFail(@"Expected lifecycle %@ but instead received %@", [nextExpectation expectedLifecycle],
327+
message);
331328
return;
332329
}
333330

334331
[nextExpectation fulfill];
335332
[lifecycleExpectations removeObjectAtIndex:0];
336333
}];
337-
334+
338335
// At the end of Flutter VC, we want to make sure it deallocs and sends detached signal.
339336
// Using autoreleasepool will guarantee that.
340337
FlutterViewController* flutterVC;
@@ -344,8 +341,6 @@ - (void)testFlutterViewControllerDetachingSendsApplicationLifecycle {
344341
[vcShown fulfill];
345342
}];
346343
[self waitForExpectationsWithTimeout:5.0 handler:nil];
347-
NSLog(@"FlutterViewController instance %@ created", flutterVC);
348-
349344
[self waitForExpectations:lifecycleExpectations timeout:5];
350345

351346
// Starts dealloc flutter VC.

0 commit comments

Comments
 (0)