1111FLUTTER_ASSERT_ARC
1212
1313@interface FlutterPluginAppLifeCycleDelegateTest : XCTestCase
14-
1514@end
1615
1716@implementation FlutterPluginAppLifeCycleDelegateTest
@@ -22,51 +21,71 @@ - (void)testCreate {
2221}
2322
2423- (void )testDidEnterBackground {
24+ XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc ]
25+ initWithName: UIApplicationDidEnterBackgroundNotification];
2526 FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc ] init ];
2627 id plugin = OCMProtocolMock (@protocol (FlutterPlugin));
2728 [delegate addDelegate: plugin];
2829 [[NSNotificationCenter defaultCenter ]
2930 postNotificationName: UIApplicationDidEnterBackgroundNotification
3031 object: nil ];
32+
33+ [self waitForExpectations: @[expectation] timeout: 5.0 ];
3134 OCMVerify ([plugin applicationDidEnterBackground: [UIApplication sharedApplication ]]);
3235}
3336
3437- (void )testWillEnterForeground {
38+ XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc ]
39+ initWithName: UIApplicationWillEnterForegroundNotification];
40+
3541 FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc ] init ];
3642 id plugin = OCMProtocolMock (@protocol (FlutterPlugin));
3743 [delegate addDelegate: plugin];
3844 [[NSNotificationCenter defaultCenter ]
3945 postNotificationName: UIApplicationWillEnterForegroundNotification
4046 object: nil ];
47+ [self waitForExpectations: @[expectation] timeout: 5.0 ];
4148 OCMVerify ([plugin applicationWillEnterForeground: [UIApplication sharedApplication ]]);
4249}
4350
44- - (void )skip_testWillResignActive {
51+ - (void )testWillResignActive {
52+ XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc ]
53+ initWithName: UIApplicationWillResignActiveNotification];
54+
4555 FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc ] init ];
4656 id plugin = OCMProtocolMock (@protocol (FlutterPlugin));
4757 [delegate addDelegate: plugin];
4858 [[NSNotificationCenter defaultCenter ]
4959 postNotificationName: UIApplicationWillResignActiveNotification
5060 object: nil ];
61+ [self waitForExpectations: @[expectation] timeout: 5.0 ];
5162 OCMVerify ([plugin applicationWillResignActive: [UIApplication sharedApplication ]]);
5263}
5364
54- - (void )skip_testDidBecomeActive {
65+ - (void )testDidBecomeActive {
66+ XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc ]
67+ initWithName: UIApplicationDidBecomeActiveNotification];
68+
5569 FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc ] init ];
5670 id plugin = OCMProtocolMock (@protocol (FlutterPlugin));
5771 [delegate addDelegate: plugin];
5872 [[NSNotificationCenter defaultCenter ]
5973 postNotificationName: UIApplicationDidBecomeActiveNotification
6074 object: nil ];
75+ [self waitForExpectations: @[expectation] timeout: 5.0 ];
6176 OCMVerify ([plugin applicationDidBecomeActive: [UIApplication sharedApplication ]]);
6277}
6378
6479- (void )testWillTerminate {
80+ XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc ]
81+ initWithName: UIApplicationWillTerminateNotification];
82+
6583 FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc ] init ];
6684 id plugin = OCMProtocolMock (@protocol (FlutterPlugin));
6785 [delegate addDelegate: plugin];
6886 [[NSNotificationCenter defaultCenter ] postNotificationName: UIApplicationWillTerminateNotification
6987 object: nil ];
88+ [self waitForExpectations: @[expectation] timeout: 5.0 ];
7089 OCMVerify ([plugin applicationWillTerminate: [UIApplication sharedApplication ]]);
7190}
7291
0 commit comments