Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,17 @@ - (void)testCallsNotifyLowMemory {
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
FLUTTER_ASSERT_ARC

@interface FlutterPluginAppLifeCycleDelegateTest : XCTestCase

@end

@implementation FlutterPluginAppLifeCycleDelegateTest
Expand All @@ -21,71 +22,51 @@ - (void)testCreate {
}

- (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)testWillResignActive {
XCTNSNotificationExpectation* expectation =
[[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillResignActiveNotification];

- (void)skip_testWillResignActive {
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)testDidBecomeActive {
XCTNSNotificationExpectation* expectation =
[[XCTNSNotificationExpectation alloc] initWithName:UIApplicationDidBecomeActiveNotification];

- (void)skip_testDidBecomeActive {
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]]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,9 @@ - (void)testFlutterTokenizerCanParseLines {

- (void)testFlutterTextInputPluginRetainsFlutterTextInputView {
FlutterTextInputPlugin* myInputPlugin;
id myEngine = OCMClassMock([FlutterEngine class]);
myInputPlugin = [[FlutterTextInputPlugin alloc] init];
myInputPlugin.textInputDelegate = engine;
myInputPlugin.textInputDelegate = myEngine;
__weak UIView* activeView;
@autoreleasepool {
FlutterMethodCall* setClientCall = [FlutterMethodCall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,5 @@ - (void)testAccessibilityMessageAfterDeletion {
});
latch.Wait();
OCMVerify([messenger cleanupConnection:connection]);
[engine stopMocking];
}
@end