diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm index 53d8688077..2af636a71c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm @@ -87,17 +87,24 @@ class MockDelegate : public PlatformView::Delegate { OCMVerify([mockEngine notifyLowMemory]); OCMReject([mockEngine notifyLowMemory]); + XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc] + initWithName:UIApplicationDidReceiveMemoryWarningNotification]; [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil]; + [self waitForExpectations:@[ memoryExpectation ] timeout:5.0]; OCMVerify([mockEngine notifyLowMemory]); OCMReject([mockEngine notifyLowMemory]); + XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc] + initWithName:UIApplicationDidEnterBackgroundNotification]; [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidEnterBackgroundNotification object:nil]; + [self waitForExpectations:@[ backgroundExpectation ] timeout:5.0]; OCMVerify([mockEngine notifyLowMemory]); + [mockEngine stopMocking]; } @end diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.m b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.m index 21501c7421..9891f52cf8 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.m +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.m @@ -11,7 +11,6 @@ FLUTTER_ASSERT_ARC @interface FlutterPluginAppLifeCycleDelegateTest : XCTestCase - @end @implementation FlutterPluginAppLifeCycleDelegateTest @@ -22,51 +21,71 @@ FLUTTER_ASSERT_ARC } - (void)testDidEnterBackground { + XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc] + initWithName:UIApplicationDidEnterBackgroundNotification]; FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init]; id plugin = OCMProtocolMock(@protocol(FlutterPlugin)); [delegate addDelegate:plugin]; [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidEnterBackgroundNotification object:nil]; + + [self waitForExpectations:@[ expectation ] timeout:5.0]; OCMVerify([plugin applicationDidEnterBackground:[UIApplication sharedApplication]]); } - (void)testWillEnterForeground { + XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc] + initWithName:UIApplicationWillEnterForegroundNotification]; + FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init]; id plugin = OCMProtocolMock(@protocol(FlutterPlugin)); [delegate addDelegate:plugin]; [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillEnterForegroundNotification object:nil]; + [self waitForExpectations:@[ expectation ] timeout:5.0]; OCMVerify([plugin applicationWillEnterForeground:[UIApplication sharedApplication]]); } -- (void)skip_testWillResignActive { +- (void)testWillResignActive { + XCTNSNotificationExpectation* expectation = + [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillResignActiveNotification]; + FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init]; id plugin = OCMProtocolMock(@protocol(FlutterPlugin)); [delegate addDelegate:plugin]; [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillResignActiveNotification object:nil]; + [self waitForExpectations:@[ expectation ] timeout:5.0]; OCMVerify([plugin applicationWillResignActive:[UIApplication sharedApplication]]); } -- (void)skip_testDidBecomeActive { +- (void)testDidBecomeActive { + XCTNSNotificationExpectation* expectation = + [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationDidBecomeActiveNotification]; + FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init]; id plugin = OCMProtocolMock(@protocol(FlutterPlugin)); [delegate addDelegate:plugin]; [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidBecomeActiveNotification object:nil]; + [self waitForExpectations:@[ expectation ] timeout:5.0]; OCMVerify([plugin applicationDidBecomeActive:[UIApplication sharedApplication]]); } - (void)testWillTerminate { + XCTNSNotificationExpectation* expectation = + [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillTerminateNotification]; + FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init]; id plugin = OCMProtocolMock(@protocol(FlutterPlugin)); [delegate addDelegate:plugin]; [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification object:nil]; + [self waitForExpectations:@[ expectation ] timeout:5.0]; OCMVerify([plugin applicationWillTerminate:[UIApplication sharedApplication]]); } diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index 4e7a3b6108..06f53c39ff 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -885,9 +885,8 @@ FLUTTER_ASSERT_ARC - (void)testFlutterTextInputPluginRetainsFlutterTextInputView { FlutterTextInputPlugin* myInputPlugin; - id myEngine = OCMClassMock([FlutterEngine class]); myInputPlugin = [[FlutterTextInputPlugin alloc] init]; - myInputPlugin.textInputDelegate = myEngine; + myInputPlugin.textInputDelegate = engine; __weak UIView* activeView; @autoreleasepool { FlutterMethodCall* setClientCall = [FlutterMethodCall diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm index 41f8072afd..260a7eb19a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm @@ -970,5 +970,6 @@ fml::RefPtr CreateNewThread(std::string name) { }); latch.Wait(); OCMVerify([messenger cleanupConnection:connection]); + [engine stopMocking]; } @end