5 #import <OCMock/OCMock.h>
6 #import <XCTest/XCTest.h>
26 XCTAssertNotNil(delegate);
29 #if not APPLICATION_EXTENSION_API_ONLY
30 - (void)testDidEnterBackground {
31 XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc]
32 initWithName:UIApplicationDidEnterBackgroundNotification];
36 [[NSNotificationCenter defaultCenter]
37 postNotificationName:UIApplicationDidEnterBackgroundNotification
40 [
self waitForExpectations:@[ expectation ] timeout:5.0];
41 OCMVerify([plugin applicationDidEnterBackground:[UIApplication sharedApplication]]);
44 - (void)testWillEnterForeground {
45 XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc]
46 initWithName:UIApplicationWillEnterForegroundNotification];
51 [[NSNotificationCenter defaultCenter]
52 postNotificationName:UIApplicationWillEnterForegroundNotification
54 [
self waitForExpectations:@[ expectation ] timeout:5.0];
55 OCMVerify([plugin applicationWillEnterForeground:[UIApplication sharedApplication]]);
58 - (void)testWillResignActive {
59 XCTNSNotificationExpectation* expectation =
60 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillResignActiveNotification];
65 [[NSNotificationCenter defaultCenter]
66 postNotificationName:UIApplicationWillResignActiveNotification
68 [
self waitForExpectations:@[ expectation ] timeout:5.0];
69 OCMVerify([plugin applicationWillResignActive:[UIApplication sharedApplication]]);
72 - (void)testDidBecomeActive {
73 XCTNSNotificationExpectation* expectation =
74 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationDidBecomeActiveNotification];
79 [[NSNotificationCenter defaultCenter]
80 postNotificationName:UIApplicationDidBecomeActiveNotification
82 [
self waitForExpectations:@[ expectation ] timeout:5.0];
83 OCMVerify([plugin applicationDidBecomeActive:[UIApplication sharedApplication]]);
86 - (void)testWillTerminate {
87 XCTNSNotificationExpectation* expectation =
88 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillTerminateNotification];
93 [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification
95 [
self waitForExpectations:@[ expectation ] timeout:5.0];
96 OCMVerify([plugin applicationWillTerminate:[UIApplication sharedApplication]]);
99 - (void)testReleasesPluginOnDealloc {
100 __weak id<FlutterApplicationLifeCycleDelegate> weakPlugin;
104 weakPlugin = fakePlugin;
107 weakDelegate = delegate;
109 XCTAssertNil(weakPlugin);
110 XCTAssertNil(weakDelegate);