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];
87TEST(FlutterAppLifecycleDelegateTest, RespondsToDidFinishLaunching) {
92 NSNotification* didFinishLaunching =
93 [NSNotification notificationWithName:NSApplicationDidFinishLaunchingNotification object:nil];
98TEST(FlutterAppLifecycleDelegateTest, RespondsToWillBecomeActive) {
103 NSNotification* willBecomeActive =
104 [NSNotification notificationWithName:NSApplicationWillBecomeActiveNotification object:nil];
109TEST(FlutterAppLifecycleDelegateTest, RespondsToDidBecomeActive) {
114 NSNotification* didBecomeActive =
115 [NSNotification notificationWithName:NSApplicationDidBecomeActiveNotification object:nil];
120TEST(FlutterAppLifecycleDelegateTest, RespondsToWillResignActive) {
125 NSNotification* willResignActive =
126 [NSNotification notificationWithName:NSApplicationWillResignActiveNotification object:nil];
131TEST(FlutterAppLifecycleDelegateTest, RespondsToDidResignActive) {
136 NSNotification* didResignActive =
137 [NSNotification notificationWithName:NSApplicationDidResignActiveNotification object:nil];
142TEST(FlutterAppLifecycleDelegateTest, RespondsToWillTerminate) {
147 NSNotification* applicationWillTerminate =
148 [NSNotification notificationWithName:NSApplicationWillTerminateNotification object:nil];
153TEST(FlutterAppLifecycleDelegateTest, RespondsToWillHide) {
158 NSNotification* willHide = [NSNotification notificationWithName:NSApplicationWillHideNotification
164TEST(FlutterAppLifecycleDelegateTest, RespondsToWillUnhide) {
169 NSNotification* willUnhide =
170 [NSNotification notificationWithName:NSApplicationWillUnhideNotification object:nil];
175TEST(FlutterAppLifecycleDelegateTest, RespondsToDidHide) {
180 NSNotification* didHide = [NSNotification notificationWithName:NSApplicationDidHideNotification
186TEST(FlutterAppLifecycleDelegateTest, RespondsToDidUnhide) {
191 NSNotification* didUnhide =
192 [NSNotification notificationWithName:NSApplicationDidUnhideNotification object:nil];
197TEST(FlutterAppLifecycleDelegateTest, RespondsToDidChangeScreenParameters) {
202 NSNotification* didChangeScreenParameters =
203 [NSNotification notificationWithName:NSApplicationDidChangeScreenParametersNotification
209TEST(FlutterAppLifecycleDelegateTest, RespondsToDidChangeOcclusionState) {
214 NSNotification* didChangeOcclusionState =
215 [NSNotification notificationWithName:NSApplicationDidChangeOcclusionStateNotification
217 if ([registrar respondsToSelector:
@selector(handleDidChangeOcclusionState:)]) {
223TEST(FlutterAppLifecycleDelegateTest, ReleasesDelegateOnDealloc) {
228 weakRegistrar = registrar;
230 weakDelegate = delegate;
233 EXPECT_EQ(weakRegistrar, nil);
234 EXPECT_EQ(weakDelegate, nil);
void addDelegate:(NSObject< FlutterAppLifecycleDelegate > *delegate)
void setNotification:(NSNotification *notification)
NSNotification * lastNotification
TEST(FlutterAppLifecycleDelegateTest, ReleasesDelegateOnDealloc)
API_AVAILABLE(ios(14.0), macos(11.0)) static NSString *MTLCommandEncoderErrorStateToString(MTLCommandEncoderErrorState state)
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)