@@ -38,8 +38,14 @@ @implementation AppLifecycleTests
38
38
- (void )setUp {
39
39
[super setUp ];
40
40
self.continueAfterFailure = NO ;
41
+ }
42
+
43
+ - (void )ensureApplicationIsInActiveState {
41
44
// Since this test checks for view controller and application lifecycles, the starting point
42
45
// must be well defined.
46
+
47
+ // Make this check after setting the root view controller since it seems to just hang if
48
+ // done in setUp.
43
49
if ([UIApplication sharedApplication ].applicationState != UIApplicationStateActive) {
44
50
NSLog (@" Initial application state is currently %zd . Waiting for active." ,
45
51
[UIApplication sharedApplication ].applicationState );
@@ -48,7 +54,7 @@ - (void)setUp {
48
54
[self expectationForNotification: UIApplicationDidBecomeActiveNotification
49
55
object: self
50
56
handler: nil ];
51
- [self waitForExpectationsWithTimeout: 60 .0 handler: nil ];
57
+ [self waitForExpectationsWithTimeout: 30 .0 handler: nil ];
52
58
}
53
59
XCTAssertEqual ([UIApplication sharedApplication ].applicationState , UIApplicationStateActive);
54
60
}
@@ -68,6 +74,8 @@ - (void)skip_testDismissedFlutterViewControllerNotRespondingToApplicationLifecyc
68
74
application.delegate .window .rootViewController = rootVC;
69
75
FlutterEngine* engine = rootVC.engine ;
70
76
77
+ [self ensureApplicationIsInActiveState ];
78
+
71
79
NSMutableArray * lifecycleExpectations = [NSMutableArray arrayWithCapacity: 10 ];
72
80
73
81
// Expected sequence from showing the FlutterViewController is inactive and resumed.
@@ -212,6 +220,8 @@ - (void)skip_testVisibleFlutterViewControllerRespondsToApplicationLifecycle {
212
220
application.delegate .window .rootViewController = rootVC;
213
221
FlutterEngine* engine = rootVC.engine ;
214
222
223
+ [self ensureApplicationIsInActiveState ];
224
+
215
225
NSMutableArray * lifecycleExpectations = [NSMutableArray arrayWithCapacity: 10 ];
216
226
217
227
// Expected sequence from showing the FlutterViewController is inactive and resumed.
@@ -322,6 +332,8 @@ - (void)skip_testFlutterViewControllerDetachingSendsApplicationLifecycle {
322
332
application.delegate .window .rootViewController = rootVC;
323
333
FlutterEngine* engine = rootVC.engine ;
324
334
335
+ [self ensureApplicationIsInActiveState ];
336
+
325
337
NSMutableArray * lifecycleExpectations = [NSMutableArray arrayWithCapacity: 10 ];
326
338
327
339
// Expected sequence from showing the FlutterViewController is inactive and resumed.
0 commit comments