7 #import "flutter/testing/testing.h"
8 #include "third_party/googletest/googletest/include/gtest/gtest.h"
16 - (void)setNotification:(NSNotification*)notification {
20 - (void)handleWillFinishLaunching:(NSNotification*)notification {
21 [
self setNotification:notification];
24 - (void)handleDidFinishLaunching:(NSNotification*)notification {
25 [
self setNotification:notification];
28 - (void)handleWillBecomeActive:(NSNotification*)notification {
29 [
self setNotification:notification];
32 - (void)handleDidBecomeActive:(NSNotification*)notification {
33 [
self setNotification:notification];
36 - (void)handleWillResignActive:(NSNotification*)notification {
37 [
self setNotification:notification];
40 - (void)handleDidResignActive:(NSNotification*)notification {
41 [
self setNotification:notification];
44 - (void)handleWillHide:(NSNotification*)notification {
45 [
self setNotification:notification];
48 - (void)handleDidHide:(NSNotification*)notification {
49 [
self setNotification:notification];
52 - (void)handleWillUnhide:(NSNotification*)notification {
53 [
self setNotification:notification];
56 - (void)handleDidUnhide:(NSNotification*)notification {
57 [
self setNotification:notification];
60 - (void)handleDidChangeScreenParameters:(NSNotification*)notification {
61 [
self setNotification:notification];
64 - (void)handleDidChangeOcclusionState:(NSNotification*)notification API_AVAILABLE(macos(10.9)) {
65 [
self setNotification:notification];
68 - (void)handleWillTerminate:(NSNotification*)notification {
69 [
self setNotification:notification];
76 TEST(FlutterAppLifecycleDelegateTest, RespondsToWillFinishLaunching) {
81 NSNotification* willFinishLaunching =
82 [NSNotification notificationWithName:NSApplicationWillFinishLaunchingNotification object:nil];
87 TEST(FlutterAppLifecycleDelegateTest, RespondsToDidFinishLaunching) {
92 NSNotification* didFinishLaunching =
93 [NSNotification notificationWithName:NSApplicationDidFinishLaunchingNotification object:nil];
98 TEST(FlutterAppLifecycleDelegateTest, RespondsToWillBecomeActive) {
103 NSNotification* willBecomeActive =
104 [NSNotification notificationWithName:NSApplicationWillBecomeActiveNotification object:nil];
109 TEST(FlutterAppLifecycleDelegateTest, RespondsToDidBecomeActive) {
114 NSNotification* didBecomeActive =
115 [NSNotification notificationWithName:NSApplicationDidBecomeActiveNotification object:nil];
120 TEST(FlutterAppLifecycleDelegateTest, RespondsToWillResignActive) {
125 NSNotification* willResignActive =
126 [NSNotification notificationWithName:NSApplicationWillResignActiveNotification object:nil];
131 TEST(FlutterAppLifecycleDelegateTest, RespondsToDidResignActive) {
136 NSNotification* didResignActive =
137 [NSNotification notificationWithName:NSApplicationDidResignActiveNotification object:nil];
142 TEST(FlutterAppLifecycleDelegateTest, RespondsToWillTerminate) {
147 NSNotification* applicationWillTerminate =
148 [NSNotification notificationWithName:NSApplicationWillTerminateNotification object:nil];
153 TEST(FlutterAppLifecycleDelegateTest, RespondsToWillHide) {
158 NSNotification* willHide = [NSNotification notificationWithName:NSApplicationWillHideNotification
164 TEST(FlutterAppLifecycleDelegateTest, RespondsToWillUnhide) {
169 NSNotification* willUnhide =
170 [NSNotification notificationWithName:NSApplicationWillUnhideNotification object:nil];
175 TEST(FlutterAppLifecycleDelegateTest, RespondsToDidHide) {
180 NSNotification* didHide = [NSNotification notificationWithName:NSApplicationDidHideNotification
186 TEST(FlutterAppLifecycleDelegateTest, RespondsToDidUnhide) {
191 NSNotification* didUnhide =
192 [NSNotification notificationWithName:NSApplicationDidUnhideNotification object:nil];
197 TEST(FlutterAppLifecycleDelegateTest, RespondsToDidChangeScreenParameters) {
202 NSNotification* didChangeScreenParameters =
203 [NSNotification notificationWithName:NSApplicationDidChangeScreenParametersNotification
209 TEST(FlutterAppLifecycleDelegateTest, RespondsToDidChangeOcclusionState) {
214 NSNotification* didChangeOcclusionState =
215 [NSNotification notificationWithName:NSApplicationDidChangeOcclusionStateNotification
217 if ([registrar respondsToSelector:
@selector(handleDidChangeOcclusionState:)]) {
223 TEST(FlutterAppLifecycleDelegateTest, ReleasesDelegateOnDealloc) {
228 weakRegistrar = registrar;
230 weakDelegate = delegate;
233 EXPECT_EQ(weakRegistrar, nil);
234 EXPECT_EQ(weakDelegate, nil);