5#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppLifecycleDelegate.h"
7#import "flutter/testing/testing.h"
8#include "third_party/googletest/googletest/include/gtest/gtest.h"
16- (void)setNotification:(NSNotification*)notification {
17 self.lastNotification = notification;
20- (void)handleWillFinishLaunching:(NSNotification*)notification {
24- (void)handleDidFinishLaunching:(NSNotification*)notification {
28- (void)handleWillBecomeActive:(NSNotification*)notification {
32- (void)handleDidBecomeActive:(NSNotification*)notification {
36- (void)handleWillResignActive:(NSNotification*)notification {
40- (void)handleDidResignActive:(NSNotification*)notification {
44- (void)handleWillHide:(NSNotification*)notification {
48- (void)handleDidHide:(NSNotification*)notification {
52- (void)handleWillUnhide:(NSNotification*)notification {
56- (void)handleDidUnhide:(NSNotification*)notification {
60- (void)handleDidChangeScreenParameters:(NSNotification*)notification {
64- (void)handleDidChangeOcclusionState:(NSNotification*)notification
API_AVAILABLE(macos(10.9)) {
68- (void)handleWillTerminate:(NSNotification*)notification {
76TEST(FlutterAppLifecycleDelegateTest, RespondsToWillFinishLaunching) {
81 NSNotification* willFinishLaunching =
82 [NSNotification notificationWithName:NSApplicationWillFinishLaunchingNotification object:nil];
84 EXPECT_EQ([delegate lastNotification], willFinishLaunching);
87TEST(FlutterAppLifecycleDelegateTest, RespondsToDidFinishLaunching) {
92 NSNotification* didFinishLaunching =
93 [NSNotification notificationWithName:NSApplicationDidFinishLaunchingNotification object:nil];
95 EXPECT_EQ([delegate lastNotification], didFinishLaunching);
98TEST(FlutterAppLifecycleDelegateTest, RespondsToWillBecomeActive) {
103 NSNotification* willBecomeActive =
104 [NSNotification notificationWithName:NSApplicationWillBecomeActiveNotification object:nil];
106 EXPECT_EQ([delegate lastNotification], willBecomeActive);
109TEST(FlutterAppLifecycleDelegateTest, RespondsToDidBecomeActive) {
114 NSNotification* didBecomeActive =
115 [NSNotification notificationWithName:NSApplicationDidBecomeActiveNotification object:nil];
117 EXPECT_EQ([delegate lastNotification], didBecomeActive);
120TEST(FlutterAppLifecycleDelegateTest, RespondsToWillResignActive) {
125 NSNotification* willResignActive =
126 [NSNotification notificationWithName:NSApplicationWillResignActiveNotification object:nil];
128 EXPECT_EQ([delegate lastNotification], willResignActive);
131TEST(FlutterAppLifecycleDelegateTest, RespondsToDidResignActive) {
136 NSNotification* didResignActive =
137 [NSNotification notificationWithName:NSApplicationDidResignActiveNotification object:nil];
139 EXPECT_EQ([delegate lastNotification], didResignActive);
142TEST(FlutterAppLifecycleDelegateTest, RespondsToWillTerminate) {
147 NSNotification* applicationWillTerminate =
148 [NSNotification notificationWithName:NSApplicationWillTerminateNotification object:nil];
150 EXPECT_EQ([delegate lastNotification], applicationWillTerminate);
153TEST(FlutterAppLifecycleDelegateTest, RespondsToWillHide) {
158 NSNotification* willHide = [NSNotification notificationWithName:NSApplicationWillHideNotification
161 EXPECT_EQ([delegate lastNotification], willHide);
164TEST(FlutterAppLifecycleDelegateTest, RespondsToWillUnhide) {
169 NSNotification* willUnhide =
170 [NSNotification notificationWithName:NSApplicationWillUnhideNotification object:nil];
172 EXPECT_EQ([delegate lastNotification], willUnhide);
175TEST(FlutterAppLifecycleDelegateTest, RespondsToDidHide) {
180 NSNotification* didHide = [NSNotification notificationWithName:NSApplicationDidHideNotification
183 EXPECT_EQ([delegate lastNotification], didHide);
186TEST(FlutterAppLifecycleDelegateTest, RespondsToDidUnhide) {
191 NSNotification* didUnhide =
192 [NSNotification notificationWithName:NSApplicationDidUnhideNotification object:nil];
194 EXPECT_EQ([delegate lastNotification], didUnhide);
197TEST(FlutterAppLifecycleDelegateTest, RespondsToDidChangeScreenParameters) {
202 NSNotification* didChangeScreenParameters =
203 [NSNotification notificationWithName:NSApplicationDidChangeScreenParametersNotification
206 EXPECT_EQ([delegate lastNotification], didChangeScreenParameters);
209TEST(FlutterAppLifecycleDelegateTest, RespondsToDidChangeOcclusionState) {
214 NSNotification* didChangeOcclusionState =
215 [NSNotification notificationWithName:NSApplicationDidChangeOcclusionStateNotification
217 if ([registrar respondsToSelector:
@selector(handleDidChangeOcclusionState:)]) {
219 EXPECT_EQ([delegate lastNotification], didChangeOcclusionState);
#define TEST(S, s, D, expected)
void addDelegate:(NSObject< FlutterAppLifecycleDelegate > *delegate)
void setNotification:(NSNotification *notification)
NSNotification * lastNotification
UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0))
void handleWillUnhide:(NSNotification *notification)
void handleWillTerminate:(NSNotification *notification)
void handleDidUnhide:(NSNotification *notification)
void handleDidBecomeActive:(NSNotification *notification)
void handleDidHide:(NSNotification *notification)
void handleDidResignActive:(NSNotification *notification)
void handleWillResignActive:(NSNotification *notification)
void handleDidChangeScreenParameters:(NSNotification *notification)
void handleWillBecomeActive:(NSNotification *notification)
void handleWillHide:(NSNotification *notification)
void handleDidFinishLaunching:(NSNotification *notification)
void handleDidChangeOcclusionState:(NSNotification *notification)
void handleWillFinishLaunching:(NSNotification *notification)