5 #import <OCMock/OCMock.h>
6 #import <XCTest/XCTest.h>
26 XCTAssertNotNil(delegate);
29 - (void)testDidEnterBackground {
30 XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc]
31 initWithName:UIApplicationDidEnterBackgroundNotification];
35 [[NSNotificationCenter defaultCenter]
36 postNotificationName:UIApplicationDidEnterBackgroundNotification
39 [
self waitForExpectations:@[ expectation ] timeout:5.0];
40 OCMVerify([plugin applicationDidEnterBackground:[UIApplication sharedApplication]]);
43 - (void)testWillEnterForeground {
44 XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc]
45 initWithName:UIApplicationWillEnterForegroundNotification];
50 [[NSNotificationCenter defaultCenter]
51 postNotificationName:UIApplicationWillEnterForegroundNotification
53 [
self waitForExpectations:@[ expectation ] timeout:5.0];
54 OCMVerify([plugin applicationWillEnterForeground:[UIApplication sharedApplication]]);
57 - (void)testWillResignActive {
58 XCTNSNotificationExpectation* expectation =
59 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillResignActiveNotification];
64 [[NSNotificationCenter defaultCenter]
65 postNotificationName:UIApplicationWillResignActiveNotification
67 [
self waitForExpectations:@[ expectation ] timeout:5.0];
68 OCMVerify([plugin applicationWillResignActive:[UIApplication sharedApplication]]);
71 - (void)testDidBecomeActive {
72 XCTNSNotificationExpectation* expectation =
73 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationDidBecomeActiveNotification];
78 [[NSNotificationCenter defaultCenter]
79 postNotificationName:UIApplicationDidBecomeActiveNotification
81 [
self waitForExpectations:@[ expectation ] timeout:5.0];
82 OCMVerify([plugin applicationDidBecomeActive:[UIApplication sharedApplication]]);
85 - (void)testWillTerminate {
86 XCTNSNotificationExpectation* expectation =
87 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillTerminateNotification];
92 [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification
94 [
self waitForExpectations:@[ expectation ] timeout:5.0];
95 OCMVerify([plugin applicationWillTerminate:[UIApplication sharedApplication]]);
98 - (void)testReleasesPluginOnDealloc {
99 __weak id<FlutterApplicationLifeCycleDelegate> weakPlugin;
103 weakPlugin = fakePlugin;
106 weakDelegate = delegate;
108 XCTAssertNil(weakPlugin);
109 XCTAssertNil(weakDelegate);
void addDelegate:(NSObject< FlutterApplicationLifeCycleDelegate > *delegate)