5#import <OCMock/OCMock.h>
6#import <XCTest/XCTest.h>
8#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
9#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h"
26 XCTAssertNotNil(delegate);
29#if not APPLICATION_EXTENSION_API_ONLY
31 XCTNSNotificationExpectation*
expectation = [[XCTNSNotificationExpectation alloc]
32 initWithName:UIApplicationDidEnterBackgroundNotification];
34 id plugin = OCMProtocolMock(
@protocol(FlutterPlugin));
36 [[NSNotificationCenter defaultCenter]
37 postNotificationName:UIApplicationDidEnterBackgroundNotification
40 [
self waitForExpectations:@[ expectation ] timeout:5.0];
41 OCMVerify([plugin applicationDidEnterBackground:[UIApplication sharedApplication]]);
45 XCTNSNotificationExpectation*
expectation = [[XCTNSNotificationExpectation alloc]
46 initWithName:UIApplicationWillEnterForegroundNotification];
49 id plugin = OCMProtocolMock(
@protocol(FlutterPlugin));
51 [[NSNotificationCenter defaultCenter]
52 postNotificationName:UIApplicationWillEnterForegroundNotification
54 [
self waitForExpectations:@[ expectation ] timeout:5.0];
55 OCMVerify([plugin applicationWillEnterForeground:[UIApplication sharedApplication]]);
60 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillResignActiveNotification];
63 id plugin = OCMProtocolMock(
@protocol(FlutterPlugin));
65 [[NSNotificationCenter defaultCenter]
66 postNotificationName:UIApplicationWillResignActiveNotification
68 [
self waitForExpectations:@[ expectation ] timeout:5.0];
69 OCMVerify([plugin applicationWillResignActive:[UIApplication sharedApplication]]);
74 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationDidBecomeActiveNotification];
77 id plugin = OCMProtocolMock(
@protocol(FlutterPlugin));
79 [[NSNotificationCenter defaultCenter]
80 postNotificationName:UIApplicationDidBecomeActiveNotification
82 [
self waitForExpectations:@[ expectation ] timeout:5.0];
83 OCMVerify([plugin applicationDidBecomeActive:[UIApplication sharedApplication]]);
88 [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillTerminateNotification];
91 id plugin = OCMProtocolMock(
@protocol(FlutterPlugin));
93 [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification
95 [
self waitForExpectations:@[ expectation ] timeout:5.0];
96 OCMVerify([plugin applicationWillTerminate:[UIApplication sharedApplication]]);
100 __weak id<FlutterApplicationLifeCycleDelegate> weakPlugin;
104 weakPlugin = fakePlugin;
107 weakDelegate = delegate;
109 XCTAssertNil(weakPlugin);
110 XCTAssertNil(weakDelegate);
void testDidEnterBackground()
void testDidBecomeActive()
void testWillEnterForeground()
void testWillResignActive()
void testReleasesPluginOnDealloc()
void addDelegate:(NSObject< FlutterApplicationLifeCycleDelegate > *delegate)