20#import "flutter/shell/platform/darwin/common/test_utils_swift/test_utils_swift.h"
21#import "flutter/shell/platform/darwin/macos/InternalFlutterSwift/InternalFlutterSwift.h"
34#include "gtest/gtest.h"
39@interface FlutterEngine (Test)
54 arguments:(nullable
id)
args {
55 return viewIdentifier == 42 ? [[NSView alloc] init] : nil;
64- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication* _Nonnull)sender {
66 return NSTerminateCancel;
74@property(nonatomic, strong, readonly) NSPointerArray* registeredDelegates;
77- (
BOOL)hasDelegate:(nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate;
93- (void)addApplicationLifecycleDelegate:(nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate {
94 _delegates.push_back((__bridge
void*)delegate);
97- (void)removeApplicationLifecycleDelegate:
98 (nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate {
101 @"Attempting to unregister a delegate that was not registered.");
105- (
BOOL)hasDelegate:(nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate {
118+ (void)registerWithRegistrar:(id<FlutterPluginRegistrar>)registrar {
128- (NSArray<NSScreen*>*)screens {
129 id mockScreen = OCMClassMock([NSScreen
class]);
130 OCMStub([mockScreen backingScaleFactor]).andReturn(2.0);
131 OCMStub([mockScreen deviceDescription]).andReturn(@{
132 @"NSScreenNumber" : [NSNumber numberWithInt:10]
134 OCMStub([mockScreen frame]).andReturn(NSMakeRect(10, 20, 30, 40));
135 return [NSArray arrayWithObject:mockScreen];
145 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
146 ASSERT_TRUE(
engine.running);
151 std::string executable_name = [[engine executableName] UTF8String];
152 ASSERT_FALSE(executable_name.empty());
158 Dart_GetNativeArgument(
args, 0));
159 EXPECT_EQ(executable_name, dart_string);
164 EXPECT_TRUE([
engine runWithEntrypoint:
@"executableNameNotNull"]);
167 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
171#ifndef FLUTTER_RELEASE
173 setenv(
"FLUTTER_ENGINE_SWITCHES",
"2", 1);
174 setenv(
"FLUTTER_ENGINE_SWITCH_1",
"abc", 1);
175 setenv(
"FLUTTER_ENGINE_SWITCH_2",
"foo=\"bar, baz\"", 1);
178 std::vector<std::string> switches =
engine.switches;
179 ASSERT_EQ(switches.size(), 2UL);
180 EXPECT_EQ(switches[0],
"--abc");
181 EXPECT_EQ(switches[1],
"--foo=\"bar, baz\"");
183 unsetenv(
"FLUTTER_ENGINE_SWITCHES");
184 unsetenv(
"FLUTTER_ENGINE_SWITCH_1");
185 unsetenv(
"FLUTTER_ENGINE_SWITCH_2");
192 initWithAssetsPath:fixtures
193 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
194 EXPECT_TRUE([project enableSDFs]);
199 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
201 NSData* test_message = [@"a message" dataUsingEncoding:NSUTF8StringEncoding];
205 SendPlatformMessage, ([&called, test_message](
auto engine,
auto message) {
207 EXPECT_STREQ(
message->channel,
"test");
208 EXPECT_EQ(memcmp(
message->message, test_message.bytes,
message->message_size), 0);
212 [engine.binaryMessenger sendOnChannel:@"test" message:test_message];
219 AddNativeCallback(
"SignalNativeTest",
223 FlutterStringOutputWriter* writer = [[FlutterStringOutputWriter alloc] init];
224 writer.expectedOutput =
@"Hello logging";
225 FlutterLogger.outputWriter = writer;
229 EXPECT_TRUE([
engine runWithEntrypoint:
@"canLogToStdout"]);
230 ASSERT_TRUE(
engine.running);
233 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
237 EXPECT_TRUE(writer.gotExpectedOutput);
247 EXPECT_TRUE(rootLayer.backgroundColor != nil);
248 if (rootLayer.backgroundColor != nil) {
249 NSColor* actualBackgroundColor =
250 [NSColor colorWithCGColor:rootLayer.backgroundColor];
251 EXPECT_EQ(actualBackgroundColor, [NSColor blackColor]);
257 EXPECT_TRUE([
engine runWithEntrypoint:
@"backgroundTest"]);
258 ASSERT_TRUE(
engine.running);
263 [viewController loadView];
267 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
278 EXPECT_TRUE(rootLayer.backgroundColor != nil);
279 if (rootLayer.backgroundColor != nil) {
280 NSColor* actualBackgroundColor =
281 [NSColor colorWithCGColor:rootLayer.backgroundColor];
282 EXPECT_EQ(actualBackgroundColor, [NSColor whiteColor]);
288 EXPECT_TRUE([
engine runWithEntrypoint:
@"backgroundTest"]);
289 ASSERT_TRUE(
engine.running);
294 [viewController loadView];
299 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
309 Initialize, ([&update_semantics_callback, &original_init](
312 update_semantics_callback =
args->update_semantics_callback2;
313 return original_init(version, config,
args,
user_data, engine_out);
315 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
320 [viewController loadView];
322 bool enabled_called =
false;
325 enabled_called = enabled;
328 engine.semanticsEnabled = YES;
329 EXPECT_TRUE(enabled_called);
347 int32_t children[] = {1};
354 child1.
flags2 = &child_flags;
359 child1.
label =
"child 1";
372 update.
nodes = nodes;
374 update_semantics_callback(&update, (__bridge
void*)
engine);
378 NSAccessibilityElement* native_root =
engine.
viewController.flutterView.accessibilityChildren[0];
379 std::string root_label = [native_root.accessibilityLabel UTF8String];
380 EXPECT_TRUE(root_label ==
"root");
381 EXPECT_EQ(native_root.accessibilityRole, NSAccessibilityGroupRole);
382 EXPECT_EQ([native_root.accessibilityChildren count], 1u);
383 NSAccessibilityElement* native_child1 = native_root.accessibilityChildren[0];
384 std::string child1_value = [native_child1.accessibilityValue UTF8String];
385 EXPECT_TRUE(child1_value ==
"child 1");
386 EXPECT_EQ(native_child1.accessibilityRole, NSAccessibilityStaticTextRole);
387 EXPECT_EQ([native_child1.accessibilityChildren count], 0u);
389 bool semanticsEnabled =
true;
392 semanticsEnabled = enabled;
395 engine.semanticsEnabled = NO;
396 EXPECT_FALSE(semanticsEnabled);
400 [engine setViewController:nil];
409 Initialize, ([&update_semantics_callback, &original_init](
412 update_semantics_callback =
args->update_semantics_callback2;
413 return original_init(version, config,
args,
user_data, engine_out);
415 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
418 bool enabled_called =
false;
421 enabled_called = enabled;
424 engine.semanticsEnabled = YES;
425 EXPECT_TRUE(enabled_called);
443 int32_t children[] = {1};
449 child1.
flags2 = &child_flags;
454 child1.
label =
"child 1";
466 update.
nodes = nodes;
470 update_semantics_callback(&update, (__bridge
void*)
engine);
476 bool semanticsEnabled =
true;
479 semanticsEnabled = enabled;
482 engine.semanticsEnabled = NO;
483 EXPECT_FALSE(semanticsEnabled);
490 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
493 bool enabled_called =
false;
496 enabled_called = enabled;
499 engine.semanticsEnabled = YES;
500 EXPECT_TRUE(enabled_called);
514 BOOL latch_called = NO;
515 AddNativeCallback(
"SignalNativeTest",
519 EXPECT_TRUE([
engine runWithEntrypoint:
@"nativeCallback"]);
520 ASSERT_TRUE(
engine.running);
522 while (!latch_called) {
523 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
525 ASSERT_TRUE(latch_called);
531 initWithAssetsPath:fixtures
532 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
538 [viewController loadView];
539 [viewController viewDidLoad];
542 EXPECT_TRUE([
engine runWithEntrypoint:
@"canCompositePlatformViews"]);
545 withId:@"factory_id"];
546 [engine.platformViewController
550 @"viewType" : @"factory_id",
556 CFAbsoluteTime
start = CFAbsoluteTimeGetCurrent();
558 while (rootLayer.sublayers.count == 0) {
559 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
560 if (CFAbsoluteTimeGetCurrent() -
start > 1) {
566 EXPECT_EQ(rootLayer.sublayers.count, 2u);
571 [engine shutDownEngine];
579 Initialize, ([&compositor, &original_init](
582 compositor = *
args->compositor;
583 return original_init(version, config,
args,
user_data, engine_out);
589 [viewController loadView];
591 EXPECT_TRUE([
engine runWithEntrypoint:
@"empty"]);
604 .backing_store = &backing_store,
606 std::vector<FlutterLayer*>
layers = {&layer};
620 [engine shutDownEngine];
626 initWithAssetsPath:fixtures
627 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
629 project.dartEntrypointArguments = @[ @"arg1", @"arg2" ];
639 EXPECT_EQ(
args->dart_entrypoint_argc, 2);
640 NSString* arg1 = [[NSString alloc] initWithCString:args->dart_entrypoint_argv[0]
641 encoding:NSUTF8StringEncoding];
642 NSString* arg2 = [[NSString alloc] initWithCString:args->dart_entrypoint_argv[1]
643 encoding:NSUTF8StringEncoding];
645 EXPECT_TRUE([arg1 isEqualToString:
@"arg1"]);
646 EXPECT_TRUE([arg2 isEqualToString:
@"arg2"]);
648 return original_init(version, config,
args,
user_data, engine_out);
651 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
653 [engine shutDownEngine];
664 id<FlutterBinaryMessenger> binaryMessenger = nil;
669 initWithAssetsPath:fixtures
670 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
673 allowHeadlessExecution:YES];
680 EXPECT_NE(binaryMessenger, nil);
681 EXPECT_EQ(weakEngine, nil);
688 id<FlutterTextureRegistry> textureRegistry;
693 initWithAssetsPath:fixtures
694 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
697 allowHeadlessExecution:YES];
698 id<FlutterPluginRegistrar> registrar = [engine registrarForPlugin:@"MyPlugin"];
699 textureRegistry = registrar.textures;
704 EXPECT_NE(textureRegistry, nil);
705 EXPECT_EQ(weakEngine, nil);
711 initWithAssetsPath:fixtures
712 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
715 allowHeadlessExecution:YES];
717 EXPECT_EQ([
engine valuePublishedByPlugin:
@"NoSuchPlugin"], nil);
723 initWithAssetsPath:fixtures
724 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
727 allowHeadlessExecution:YES];
728 NSString* pluginName =
@"MyPlugin";
730 [engine registrarForPlugin:pluginName];
734 EXPECT_EQ([
engine valuePublishedByPlugin:pluginName], [NSNull null]);
740 initWithAssetsPath:fixtures
741 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
744 allowHeadlessExecution:YES];
745 NSString* pluginName =
@"MyPlugin";
746 id<FlutterPluginRegistrar> registrar = [engine registrarForPlugin:pluginName];
748 NSString* firstValue =
@"A published value";
749 NSArray* secondValue = @[ @"A different published value" ];
751 [registrar publish:firstValue];
752 EXPECT_EQ([
engine valuePublishedByPlugin:pluginName], firstValue);
754 [registrar publish:secondValue];
755 EXPECT_EQ([
engine valuePublishedByPlugin:pluginName], secondValue);
761 initWithAssetsPath:fixtures
762 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
768 id<FlutterPluginRegistrar> registrar = [engine registrarForPlugin:@"MyPlugin"];
781 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
784 NSData* channel_data = [channel dataUsingEncoding:NSUTF8StringEncoding];
790 SendPlatformMessage, ([](
auto engine_,
auto message_) {
791 if (strcmp(message_->channel,
"test/send_message") == 0) {
793 std::string message = R
"|({"method": "a"})|";
794 std::string channel(reinterpret_cast<const char*>(message_->message),
795 message_->message_size);
796 reinterpret_cast<EmbedderEngine*>(engine_)
799 ->HandlePlatformMessage(std::make_unique<PlatformMessage>(
800 channel.c_str(), fml::MallocMapping::Copy(message.c_str(), message.length()),
801 fml::RefPtr<PlatformMessageResponse>()));
806 __block
int record = 0;
816 [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
817 EXPECT_EQ(record, 1);
827 [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
828 EXPECT_EQ(record, 11);
832 [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
833 EXPECT_EQ(record, 21);
840 __block
bool calledAfterClear =
false;
841 __block
bool valueAfterClear;
843 calledAfterClear =
true;
844 NSNumber* valueNumber = [result valueForKey:@"value"];
845 valueAfterClear = [valueNumber boolValue];
849 [engineMock handleMethodCall:methodCallAfterClear result:resultAfterClear];
850 EXPECT_TRUE(calledAfterClear);
851 EXPECT_FALSE(valueAfterClear);
858 __block
bool called =
false;
862 NSNumber* valueNumber = [result valueForKey:@"value"];
863 value = [valueNumber boolValue];
867 [engineMock handleMethodCall:methodCall result:result];
876 binaryMessenger:engine.binaryMessenger
878 __block
BOOL didCallCallback = NO;
882 didCallCallback = YES;
884 EXPECT_TRUE([
engine runWithEntrypoint:
@"sendFooMessage"]);
887 while (!didCallCallback) {
888 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
896 binaryMessenger:engine.binaryMessenger
898 __block
BOOL didCallCallback = NO;
900 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
902 dispatch_async(dispatch_get_main_queue(), ^{
903 didCallCallback = YES;
907 EXPECT_TRUE([
engine runWithEntrypoint:
@"sendFooMessage"]);
909 while (!didCallCallback) {
910 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
918 std::optional<int64_t> engineId;
920 const auto argument = Dart_GetNativeArgument(
args, 0);
921 if (!Dart_IsNull(argument)) {
928 EXPECT_TRUE([
engine runWithEntrypoint:
@"testEngineId"]);
930 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
933 EXPECT_TRUE(engineId.has_value());
934 if (!engineId.has_value()) {
942 FlutterResizeSynchronizer* threadSynchronizer = [[FlutterResizeSynchronizer alloc] init];
943 [threadSynchronizer shutDown];
945 std::thread rasterThread([&threadSynchronizer] {
946 [threadSynchronizer performCommitForSize:CGSizeMake(100, 100)
958 initWithAssetsPath:fixtures
959 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
967 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
984 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
993 allowHeadlessExecution:NO];
998 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
1006 EXPECT_EQ(viewController2.viewIdentifier, 0ll);
1015 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
1021 initWithAssetsPath:fixtures
1022 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
1028 [viewController loadView];
1029 [viewController viewDidLoad];
1032 EXPECT_TRUE([
engine runWithEntrypoint:
@"drawIntoAllViews"]);
1034 CFTimeInterval
start = CACurrentMediaTime();
1036 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES);
1037 if (CACurrentMediaTime() -
start > 1) {
1047 [engine shutDownEngine];
1053 __block NSString* nextResponse =
@"exit";
1054 __block
BOOL triedToTerminate = NO;
1057 terminator:^(id sender) {
1058 triedToTerminate = TRUE;
1061 OCMStub([engineMock terminationHandler]).andReturn(terminationHandler);
1062 id binaryMessengerMock = OCMProtocolMock(
@protocol(FlutterBinaryMessenger));
1064 [engineMock binaryMessenger])
1065 .andReturn(binaryMessengerMock);
1066 OCMStub([engineMock sendOnChannel:
@"flutter/platform"
1068 binaryReply:[OCMArg any]])
1069 .andDo((^(NSInvocation* invocation) {
1070 [invocation retainArguments];
1072 NSData* returnedMessage;
1073 [invocation getArgument:&callback atIndex:4];
1074 if ([nextResponse isEqualToString:
@"error"]) {
1081 NSDictionary* responseDict = @{
@"response" : nextResponse};
1087 __block NSString* calledAfterTerminate =
@"";
1089 NSDictionary* resultDict = result;
1090 calledAfterTerminate = resultDict[@"response"];
1097 triedToTerminate = NO;
1098 calledAfterTerminate =
@"";
1099 nextResponse =
@"cancel";
1100 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1101 EXPECT_STREQ([calledAfterTerminate UTF8String],
"");
1102 EXPECT_TRUE(triedToTerminate);
1106 triedToTerminate = NO;
1107 calledAfterTerminate =
@"";
1108 nextResponse =
@"exit";
1109 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1110 EXPECT_STREQ([calledAfterTerminate UTF8String],
"exit");
1111 EXPECT_TRUE(triedToTerminate);
1113 triedToTerminate = NO;
1114 calledAfterTerminate =
@"";
1115 nextResponse =
@"cancel";
1116 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1117 EXPECT_STREQ([calledAfterTerminate UTF8String],
"cancel");
1118 EXPECT_FALSE(triedToTerminate);
1121 triedToTerminate = NO;
1122 calledAfterTerminate =
@"";
1123 nextResponse =
@"error";
1124 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1125 EXPECT_STREQ([calledAfterTerminate UTF8String],
"");
1126 EXPECT_TRUE(triedToTerminate);
1130 id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1132 [NSApplication sharedApplication].delegate = plainDelegate;
1139 EXPECT_EQ([[[NSApplication sharedApplication] delegate] applicationShouldTerminate:NSApp],
1142 [NSApplication sharedApplication].delegate = previousDelegate;
1146 __block
BOOL announced = NO;
1149 OCMStub([engineMock announceAccessibilityMessage:[OCMArg any]
1150 withPriority:NSAccessibilityPriorityMedium])
1151 .andDo((^(NSInvocation* invocation) {
1153 [invocation retainArguments];
1155 [invocation getArgument:&message atIndex:2];
1156 EXPECT_EQ(
message,
@"error message");
1159 NSDictionary<NSString*, id>* annotatedEvent =
1160 @{
@"type" :
@"announce",
1161 @"data" : @{
@"message" :
@"error message"}};
1163 [engineMock handleAccessibilityEvent:annotatedEvent];
1165 EXPECT_TRUE(announced);
1175 .andDo((^(NSInvocation* invocation) {
1179 .andDo((^(NSInvocation* invocation) {
1183 .andDo((^(NSInvocation* invocation) {
1187 .andDo((^(NSInvocation* invocation) {
1191 .andDo((^(NSInvocation* invocation) {
1195 __block NSApplicationOcclusionState visibility = NSApplicationOcclusionStateVisible;
1196 id mockApplication = OCMPartialMock([NSApplication sharedApplication]);
1197 OCMStub((NSApplicationOcclusionState)[mockApplication occlusionState])
1198 .andDo(^(NSInvocation* invocation) {
1199 [invocation setReturnValue:&visibility];
1202 NSNotification* willBecomeActive =
1203 [[NSNotification alloc] initWithName:NSApplicationWillBecomeActiveNotification
1206 NSNotification* willResignActive =
1207 [[NSNotification alloc] initWithName:NSApplicationWillResignActiveNotification
1211 NSNotification* didChangeOcclusionState;
1212 didChangeOcclusionState =
1213 [[NSNotification alloc] initWithName:NSApplicationDidChangeOcclusionStateNotification
1217 [engineMock handleDidChangeOcclusionState:didChangeOcclusionState];
1220 [engineMock handleWillBecomeActive:willBecomeActive];
1223 [engineMock handleWillResignActive:willResignActive];
1227 [engineMock handleDidChangeOcclusionState:didChangeOcclusionState];
1230 [engineMock handleWillBecomeActive:willBecomeActive];
1233 [engineMock handleWillResignActive:willResignActive];
1236 [mockApplication stopMocking];
1240 id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1242 [NSApplication sharedApplication].delegate = fakeAppDelegate;
1247 [[engine registrarForPlugin:@"TestPlugin"] addApplicationDelegate:plugin];
1249 EXPECT_TRUE([fakeAppDelegate hasDelegate:plugin]);
1251 [NSApplication sharedApplication].delegate = previousDelegate;
1255 id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1257 [NSApplication sharedApplication].delegate = fakeAppDelegate;
1264 [[engine registrarForPlugin:@"TestPlugin"] addApplicationDelegate:plugin];
1265 EXPECT_TRUE([fakeAppDelegate hasDelegate:plugin]);
1270 EXPECT_FALSE([fakeAppDelegate hasDelegate:plugin]);
1272 [NSApplication sharedApplication].delegate = previousDelegate;
1280 NotifyDisplayUpdate, ([&updated, &original_update_displays](
1281 auto engine,
auto update_type,
auto*
displays,
auto display_count) {
1283 return original_update_displays(
engine, update_type,
displays, display_count);
1286 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
1287 EXPECT_TRUE(updated);
1290 [[NSNotificationCenter defaultCenter]
1291 postNotificationName:NSApplicationDidChangeScreenParametersNotification
1293 EXPECT_TRUE(updated);
1301 SendWindowMetricsEvent,
1302 ([&updated, &original_set_viewport_metrics](
auto engine,
auto* window_metrics) {
1304 return original_set_viewport_metrics(
engine, window_metrics);
1307 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
1310 [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1313 EXPECT_FALSE(updated);
1318 [viewController loadView];
1321 [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1323 EXPECT_TRUE(updated);
1327 NSString* fixtures = @(testing::GetFixturesPath());
1329 initWithAssetsPath:fixtures
1330 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
1334 allowHeadlessExecution:true];
1338 NotifyDisplayUpdate, ([&updated, &original_update_displays](
1339 auto engine,
auto update_type,
auto*
displays,
auto display_count) {
1340 EXPECT_EQ(display_count, 1UL);
1341 EXPECT_EQ(
displays->display_id, 10UL);
1344 EXPECT_EQ(
displays->device_pixel_ratio, 2UL);
1346 return original_update_displays(
engine, update_type,
displays, display_count);
1348 EXPECT_TRUE([
engine runWithEntrypoint:
@"main"]);
1349 EXPECT_TRUE(updated);
1355 __block
BOOL expectedValue;
1359 OCMStub([channelMock messageChannelWithName:
@"flutter/settings"
1360 binaryMessenger:[OCMArg any]
1361 codec:[OCMArg any]])
1362 .andReturn(channelMock);
1363 OCMStub([channelMock sendMessage:[OCMArg any]]).andDo((^(NSInvocation* invocation) {
1365 [invocation getArgument:&message atIndex:2];
1366 EXPECT_EQ(
message[
@"alwaysUse24HourFormat"], @(expectedValue));
1370 OCMStub([mockHourFormat isAlwaysUse24HourFormat]).andDo((^(NSInvocation* invocation) {
1371 [invocation setReturnValue:&expectedValue];
1377 expectedValue = YES;
1378 EXPECT_TRUE([engineMock runWithEntrypoint:
@"main"]);
1379 [engineMock shutDownEngine];
1383 EXPECT_TRUE([engineMock runWithEntrypoint:
@"main"]);
1384 [engineMock shutDownEngine];
1387 [mockHourFormat stopMocking];
1388 [engineMock stopMocking];
1389 [channelMock stopMocking];
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
void(^ FlutterResult)(id _Nullable result)
TEST_F(FlutterDisplayLinkTest, ViewAddedToWindowFirst)
NSPointerArray * _delegates
flutter::FlutterCompositor * macOSCompositor
FlutterEngine * engine() const
#define FLUTTER_API_SYMBOL(symbol)
@ kFlutterLayerContentTypeBackingStore
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
void setMessageHandler:(FlutterMessageHandler _Nullable handler)
void(* rootIsolateCreateCallback)(void *_Nullable)
NSObject< FlutterBinaryMessenger > * binaryMessenger
flutter::FlutterCompositor * macOSCompositor
FlutterViewController * viewController
FlutterEngineProcTable & embedderAPI
instancetype errorWithCode:message:details:(NSString *code,[message] NSString *_Nullable message,[details] id _Nullable details)
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
void setMethodCallHandler:(FlutterMethodCallHandler _Nullable handler)
instancetype methodChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMethodCodec > *codec)
NSColor * backgroundColor
UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0))
FlutterViewController * viewController
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
id CreateMockFlutterEngine(NSString *pasteboardString)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
#define MOCK_ENGINE_PROC(proc, mock_impl)
instancetype sharedInstance()
FlutterBackingStoreCreateCallback create_backing_store_callback
FlutterPresentViewCallback present_view_callback
FlutterBackingStoreCollectCallback collect_backing_store_callback
FlutterEngineSendWindowMetricsEventFnPtr SendWindowMetricsEvent
FlutterEngineInitializeFnPtr Initialize
FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate
FlutterEngineSendPlatformMessageFnPtr SendPlatformMessage
FlutterEngineUpdateSemanticsEnabledFnPtr UpdateSemanticsEnabled
FlutterLayerContentType type
const char * increased_value
const char * tooltip
A textual tooltip attached to the node.
size_t custom_accessibility_actions_count
The number of custom accessibility action associated with this node.
const int32_t * children_in_traversal_order
Array of child node IDs in traversal order. Has length child_count.
int32_t text_selection_extent
The position at which the text selection terminates.
FlutterSemanticsAction actions
The set of semantics actions applicable to this node.
int32_t id
The unique identifier for this node.
size_t child_count
The number of children this node has.
const char * decreased_value
const char * label
A textual description of the node.
int32_t text_selection_base
The position at which the text selection originates.
const char * hint
A brief description of the result of performing an action on the node.
FlutterSemanticsFlags * flags2
const char * value
A textual description of the current value of the node.
A batch of updates to semantics nodes and custom actions.
size_t node_count
The number of semantics node updates.
size_t custom_action_count
The number of semantics custom action updates.
FlutterSemanticsNode2 ** nodes
A structure to represent the width and height.
#define CREATE_NATIVE_ENTRY(native_entry)