13 #import "flutter/testing/testing.h"
14 #import "third_party/googletest/googletest/include/gtest/gtest.h"
29 AddNativeCallback(
"SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
35 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1,
false);
49 FML_LOG(ERROR) <<
"Isolate is not set.";
63 .size = {.width = 800, .height = 600},
64 .on_should_close = [] {},
65 .on_will_close = [] {},
66 .notify_listeners = [] {},
70 int64_t engineId =
reinterpret_cast<int64_t
>(engine);
78 EXPECT_NE(viewController, nil);
79 CGSize size = viewController.view.frame.size;
80 EXPECT_EQ(size.width, 800);
81 EXPECT_EQ(size.height, 600);
88 int64_t engineId =
reinterpret_cast<int64_t
>(engine);
92 .size = {.width = 800, .height = 600},
93 .on_should_close = [] {},
94 .on_will_close = [] {},
95 .notify_listeners = [] {},
98 EXPECT_EQ(parentViewId, 1);
104 rect->
left = parent_rect.left + 10;
105 rect->
top = parent_rect.top + 10;
117 .parent_view_id = parentViewId,
118 .on_should_close = [] {},
119 .on_will_close = [] {},
120 .notify_listeners = [] {},
121 .on_get_window_position = position_callback,
124 const int64_t tooltipViewId =
126 EXPECT_NE(tooltipViewId, 0);
132 .size = {.width = 800, .height = 600},
133 .on_should_close = [] {},
134 .on_will_close = [] {},
135 .notify_listeners = [] {},
140 NSString* fixtures = @(flutter::testing::GetFixturesPath());
141 NSLog(
@"Fixtures path: %@", fixtures);
143 initWithAssetsPath:fixtures
144 ICUDataPath:[fixtures stringByAppendingString:
@"/icudtl.dat"]];
146 static std::optional<flutter::Isolate> isolate;
147 isolate = std::nullopt;
152 allowHeadlessExecution:YES];
154 [engine runWithEntrypoint:
@"testWindowControllerRetainCycle"];
156 int64_t engineId =
reinterpret_cast<int64_t
>(engine);
159 FML_DCHECK(isolate.has_value());
163 EXPECT_EQ(handle, 1);
166 [engine.windowController closeAllWindows];
167 [engine shutDownEngine];
169 EXPECT_EQ(weakEngine, nil);
175 .size = {.width = 800, .height = 600},
176 .on_should_close = [] {},
177 .on_will_close = [] {},
178 .notify_listeners = [] {},
182 int64_t engine_id =
reinterpret_cast<int64_t
>(engine);
189 viewController = [engine viewControllerForIdentifier:handle];
190 EXPECT_EQ(viewController, nil);
196 .size = {.width = 800, .height = 600},
197 .on_should_close = [] {},
198 .on_will_close = [] {},
199 .notify_listeners = [] {},
203 int64_t engine_id =
reinterpret_cast<int64_t
>(engine);
210 EXPECT_EQ(window_handle, (__bridge
void*)viewController.view.window);
216 .size = {.width = 800, .height = 600},
217 .on_should_close = [] {},
218 .on_will_close = [] {},
219 .notify_listeners = [] {},
223 int64_t engine_id =
reinterpret_cast<int64_t
>(engine);
229 NSWindow* window = viewController.view.window;
230 void* windowHandle = (__bridge
void*)window;
232 EXPECT_EQ(window.zoomed, NO);
233 EXPECT_EQ(window.miniaturized, NO);
234 EXPECT_EQ(window.styleMask & NSWindowStyleMaskFullScreen, 0u);
237 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.5,
false);
238 EXPECT_EQ(window.zoomed, YES);
241 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.5,
false);
242 EXPECT_EQ(window.zoomed, NO);
247 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.5,
false);
248 EXPECT_EQ(window.miniaturized, YES);
254 .size = {.width = 800, .height = 600},
255 .on_should_close = [] {},
256 .on_will_close = [] {},
257 .notify_listeners = [] {},
260 int64_t engine_id =
reinterpret_cast<int64_t
>(engine);
273 EXPECT_NE(viewController1, nil);
274 EXPECT_NE(viewController2, nil);
275 EXPECT_NE(viewController3, nil);
278 [engine engineCallbackOnPreEngineRestart];
281 viewController1 = [engine viewControllerForIdentifier:handle1];
282 viewController2 = [engine viewControllerForIdentifier:handle2];
283 viewController3 = [engine viewControllerForIdentifier:handle3];
284 EXPECT_EQ(viewController1, nil);
285 EXPECT_EQ(viewController2, nil);
286 EXPECT_EQ(viewController3, nil);
292 int64_t engineId =
reinterpret_cast<int64_t
>(engine);
297 .size = {.width = 800, .height = 600},
298 .on_should_close = [] {},
299 .on_will_close = [] {},
300 .notify_listeners = [] {},
302 int64_t parentViewId =
304 EXPECT_EQ(parentViewId, 1);
310 rect->
left = parent_rect.left;
311 rect->
top = parent_rect.top;
325 .parent_view_id = parentViewId,
326 .on_should_close = [] {},
327 .on_will_close = [] {},
328 .notify_listeners = [] {},
329 .on_get_window_position = position_callback,
332 const int64_t tooltipViewId =
334 EXPECT_NE(tooltipViewId, 0);
337 FlutterView* flutterView = viewController.flutterView;
341 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1,
false);
343 [flutterView.
sizingDelegate viewDidUpdateContents:flutterView withSize:NSMakeSize(1000, 1000)];
348 EXPECT_LE(maxSize.width, 500);
349 EXPECT_LE(maxSize.height, 400);
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateRegularWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateTooltipWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetMaximized(void *window, bool maximized)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Destroy(int64_t engine_id, void *window)
FLUTTER_DARWIN_EXPORT void * InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Minimize(void *window)
void AddNativeCallback(const char *name, Dart_NativeFunction function)
FlutterEngine * GetFlutterEngine()
std::optional< flutter::Isolate > isolate_
FlutterWindowControllerTest()=default
flutter::Isolate & isolate()
CGSize maximumContentSize
id< FlutterViewSizingDelegate > sizingDelegate
TEST_F(AccessibilityBridgeMacWindowTest, SendsAccessibilityCreateNotificationFlutterViewWindow)