| Flutter Linux Embedder |

Functions
fl_windowing_handler_test.cc File Reference
`#include "flutter/shell/platform/linux/fl_windowing_handler.h"`
`#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include "flutter/shell/platform/linux/testing/fl_mock_binary_messenger.h"`
`#include "flutter/shell/platform/linux/testing/fl_test_gtk_logs.h"`
`#include "flutter/shell/platform/linux/testing/mock_gtk.h"`
`#include "flutter/testing/testing.h"`
`#include "gmock/gmock.h"`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Functions
static void | set_size_arg (FlValue *args, const gchar *name, double width, double height)
static FlValue * | make_create_regular_args (double width, double height)
static int64_t | parse_create_regular_response (FlMethodResponse *response)
static FlValue * | make_modify_regular_args (int64_t view_id)
static FlValue * | make_destroy_window_args (int64_t view_id)
| TEST (FlWindowingHandlerTest, CreateRegular)
| TEST (FlWindowingHandlerTest, CreateRegularMinSize)
| TEST (FlWindowingHandlerTest, CreateRegularMaxSize)
| TEST (FlWindowingHandlerTest, CreateRegularWithTitle)
| TEST (FlWindowingHandlerTest, CreateRegularMaximized)
| TEST (FlWindowingHandlerTest, CreateRegularMinimized)
| TEST (FlWindowingHandlerTest, ModifyRegularSize)
| TEST (FlWindowingHandlerTest, ModifyRegularTitle)
| TEST (FlWindowingHandlerTest, ModifyRegularMaximize)
| TEST (FlWindowingHandlerTest, ModifyRegularUnmaximize)
| TEST (FlWindowingHandlerTest, ModifyRegularMinimize)
| TEST (FlWindowingHandlerTest, ModifyRegularUnminimize)
| TEST (FlWindowingHandlerTest, ModifyUnknownWindow)
| TEST (FlWindowingHandlerTest, DestroyWindow)
| TEST (FlWindowingHandlerTest, DestroyUnknownWindow)

## Function Documentation

## ◆ make_create_regular_args()

static FlValue* make_create_regular_args | ( | double | width,
|  | double | height
| ) |  |
| static

Definition at line 26 of file fl_windowing_handler_test.cc.

26 {
27 FlValue* args = fl_value_new_map();
28 set_size_arg(args, "size", width, height);
29 return args;
30 }
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
set_size_arg
static void set_size_arg(FlValue *args, const gchar *name, double width, double height)
Definition: fl_windowing_handler_test.cc:16

References args, fl_value_new_map(), height, set_size_arg(), and width.

Referenced by TEST().

## ◆ make_destroy_window_args()

static FlValue* make_destroy_window_args | ( | int64_t | view_id | ) |
| static

Definition at line 67 of file fl_windowing_handler_test.cc.

67 {
68 FlValue* args = fl_value_new_map();
69 fl_value_set_string_take(args, "viewId", fl_value_new_int(view_id));
70 return args;
71 }
fl_value_set_string_take
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:650
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References args, fl_value_new_int(), fl_value_new_map(), fl_value_set_string_take(), and view_id.

Referenced by TEST().

## ◆ make_modify_regular_args()

static FlValue* make_modify_regular_args | ( | int64_t | view_id | ) |
| static

Definition at line 61 of file fl_windowing_handler_test.cc.

61 {
62 FlValue* args = fl_value_new_map();
63 fl_value_set_string_take(args, "viewId", fl_value_new_int(view_id));
64 return args;
65 }

References args, fl_value_new_int(), fl_value_new_map(), fl_value_set_string_take(), and view_id.

Referenced by TEST().

## ◆ parse_create_regular_response()

static int64_t parse_create_regular_response | ( | FlMethodResponse * | response | ) |
| static

Definition at line 32 of file fl_windowing_handler_test.cc.

32 {
33 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
34
35 FlValue* result = fl_method_success_response_get_result(
36 FL_METHOD_SUCCESS_RESPONSE(response));
37 EXPECT_EQ(fl_value_get_type(result), FL_VALUE_TYPE_MAP);
38
39 FlValue* view_id_value = fl_value_lookup_string(result, "viewId");
40 EXPECT_NE(view_id_value, nullptr);
41 EXPECT_EQ(fl_value_get_type(view_id_value), FL_VALUE_TYPE_INT);
42 int64_t view_id = fl_value_get_int(view_id_value);
43 EXPECT_GT(view_id, 0);
44
45 FlValue* size_value = fl_value_lookup_string(result, "size");
46 EXPECT_NE(size_value, nullptr);
47 EXPECT_EQ(fl_value_get_type(size_value), FL_VALUE_TYPE_LIST);
48 EXPECT_EQ(fl_value_get_length(size_value), 2u);
49 EXPECT_EQ(fl_value_get_type(fl_value_get_list_value(size_value, 0)),
50 FL_VALUE_TYPE_FLOAT);
51 EXPECT_EQ(fl_value_get_type(fl_value_get_list_value(size_value, 1)),
52 FL_VALUE_TYPE_FLOAT);
53
54 FlValue* state_value = fl_value_lookup_string(result, "state");
55 EXPECT_NE(state_value, nullptr);
56 EXPECT_EQ(fl_value_get_type(state_value), FL_VALUE_TYPE_STRING);
57
58 return view_id;
59 }
fl_method_success_response_get_result
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)
Definition: fl_method_response.cc:138
fl_value_lookup_string
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
Definition: fl_value.cc:811
fl_value_get_list_value
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition: fl_value.cc:776
fl_value_get_int
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:668
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
fl_value_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
FL_VALUE_TYPE_STRING
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:68
FL_VALUE_TYPE_INT
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:66
FL_VALUE_TYPE_LIST
@ FL_VALUE_TYPE_LIST
Definition: fl_value.h:73
FL_VALUE_TYPE_MAP
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:74
FL_VALUE_TYPE_FLOAT
@ FL_VALUE_TYPE_FLOAT
Definition: fl_value.h:67

References fl_method_success_response_get_result(), fl_value_get_int(), fl_value_get_length(), fl_value_get_list_value(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_STRING, and view_id.

Referenced by TEST().

## ◆ set_size_arg()

static void set_size_arg | ( | FlValue * | args,
|  | const gchar * | name,
|  | double | width,
|  | double | height
| ) |  |
| static

Definition at line 16 of file fl_windowing_handler_test.cc.

19 {
20 g_autoptr(FlValue) size_value = fl_value_new_list();
21 fl_value_append_take(size_value, fl_value_new_float(width));
22 fl_value_append_take(size_value, fl_value_new_float(height));
23 fl_value_set_string(args, name, size_value);
24 }
fl_value_set_string
G_MODULE_EXPORT void fl_value_set_string(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:639
fl_value_new_float
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition: fl_value.cc:269
fl_value_new_list
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:349
fl_value_append_take
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:600

References args, fl_value_append_take(), fl_value_new_float(), fl_value_new_list(), fl_value_set_string(), height, and width.

Referenced by make_create_regular_args(), and TEST().

## ◆ TEST() [1/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | CreateRegular |
| ) |  |

Definition at line 73 of file fl_windowing_handler_test.cc.

73 {
74 flutter::testing::fl_ensure_gtk_init();
75 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
76
77 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
78 g_autoptr(FlEngine) engine =
79 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
80 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
81
82 EXPECT_CALL(mock_gtk, gtk_window_new);
83 EXPECT_CALL(mock_gtk, gtk_window_set_default_size(::testing::_, 800, 600));
84
85 g_autoptr(FlValue) args = make_create_regular_args(800, 600);
86
87 gboolean called = FALSE;
88 fl_mock_binary_messenger_invoke_standard_method(
89 messenger, "flutter/windowing", "createRegular", args,
90 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
91 gpointer user_data) {
92 parse_create_regular_response(response);
93 gboolean* called = static_cast<gboolean*>(user_data);
94 *called = TRUE;
95 },
96 &called);
97 EXPECT_TRUE(called);
98
99 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
100 }
fl_binary_messenger_shutdown
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
Definition: fl_binary_messenger.cc:500
fl_engine_new_with_binary_messenger
FlEngine * fl_engine_new_with_binary_messenger(FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:695
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
fl_windowing_handler_new
FlWindowingHandler * fl_windowing_handler_new(FlEngine *engine)
Definition: fl_windowing_handler.cc:260
parse_create_regular_response
static int64_t parse_create_regular_response(FlMethodResponse *response)
Definition: fl_windowing_handler_test.cc:32
make_create_regular_args
static FlValue * make_create_regular_args(double width, double height)
Definition: fl_windowing_handler_test.cc:26

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_windowing_handler_new(), make_create_regular_args(), parse_create_regular_response(), TRUE, and user_data.

## ◆ TEST() [2/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | CreateRegularMaximized |
| ) |  |

Definition at line 205 of file fl_windowing_handler_test.cc.

205 {
206 flutter::testing::fl_ensure_gtk_init();
207 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
208
209 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
210 g_autoptr(FlEngine) engine =
211 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
212 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
213
214 EXPECT_CALL(mock_gtk, gtk_window_new);
215 EXPECT_CALL(mock_gtk, gtk_window_maximize(::testing::_));
216
217 g_autoptr(FlValue) args = make_create_regular_args(800, 600);
218 fl_value_set_string_take(args, "state",
219 fl_value_new_string("WindowState.maximized"));
220
221 gboolean called = FALSE;
222 fl_mock_binary_messenger_invoke_standard_method(
223 messenger, "flutter/windowing", "createRegular", args,
224 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
225 gpointer user_data) {
226 parse_create_regular_response(response);
227 gboolean* called = static_cast<gboolean*>(user_data);
228 *called = TRUE;
229 },
230 &called);
231 EXPECT_TRUE(called);
232
233 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
234 }
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), parse_create_regular_response(), TRUE, and user_data.

## ◆ TEST() [3/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | CreateRegularMaxSize |
| ) |  |

Definition at line 138 of file fl_windowing_handler_test.cc.

138 {
139 flutter::testing::fl_ensure_gtk_init();
140 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
141
142 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
143 g_autoptr(FlEngine) engine =
144 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
145 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
146
147 EXPECT_CALL(mock_gtk, gtk_window_new);
148 EXPECT_CALL(mock_gtk,
149 gtk_window_set_geometry_hints(
150 ::testing::_, nullptr,
151 ::testing::Pointee(::testing::AllOf(
152 ::testing::Field(&GdkGeometry::max_width, 1000),
153 ::testing::Field(&GdkGeometry::max_height, 2000))),
154 GDK_HINT_MAX_SIZE));
155
156 g_autoptr(FlValue) args = make_create_regular_args(800, 600);
157 set_size_arg(args, "maxSize", 1000, 2000);
158
159 gboolean called = FALSE;
160 fl_mock_binary_messenger_invoke_standard_method(
161 messenger, "flutter/windowing", "createRegular", args,
162 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
163 gpointer user_data) {
164 parse_create_regular_response(response);
165 gboolean* called = static_cast<gboolean*>(user_data);
166 *called = TRUE;
167 },
168 &called);
169 EXPECT_TRUE(called);
170
171 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
172 }

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_windowing_handler_new(), make_create_regular_args(), parse_create_regular_response(), set_size_arg(), TRUE, and user_data.

## ◆ TEST() [4/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | CreateRegularMinimized |
| ) |  |

Definition at line 236 of file fl_windowing_handler_test.cc.

236 {
237 flutter::testing::fl_ensure_gtk_init();
238 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
239
240 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
241 g_autoptr(FlEngine) engine =
242 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
243 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
244
245 EXPECT_CALL(mock_gtk, gtk_window_new);
246 EXPECT_CALL(mock_gtk, gtk_window_iconify(::testing::_));
247
248 g_autoptr(FlValue) args = make_create_regular_args(800, 600);
249 fl_value_set_string_take(args, "state",
250 fl_value_new_string("WindowState.minimized"));
251
252 gboolean called = FALSE;
253 fl_mock_binary_messenger_invoke_standard_method(
254 messenger, "flutter/windowing", "createRegular", args,
255 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
256 gpointer user_data) {
257 parse_create_regular_response(response);
258 gboolean* called = static_cast<gboolean*>(user_data);
259 *called = TRUE;
260 },
261 &called);
262 EXPECT_TRUE(called);
263
264 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
265 }

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), parse_create_regular_response(), TRUE, and user_data.

## ◆ TEST() [5/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | CreateRegularMinSize |
| ) |  |

Definition at line 102 of file fl_windowing_handler_test.cc.

102 {
103 flutter::testing::fl_ensure_gtk_init();
104 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
105
106 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
107 g_autoptr(FlEngine) engine =
108 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
109 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
110
111 EXPECT_CALL(mock_gtk, gtk_window_new);
112 EXPECT_CALL(mock_gtk,
113 gtk_window_set_geometry_hints(
114 ::testing::_, nullptr,
115 ::testing::Pointee(::testing::AllOf(
116 ::testing::Field(&GdkGeometry::min_width, 100),
117 ::testing::Field(&GdkGeometry::min_height, 200))),
118 GDK_HINT_MIN_SIZE));
119
120 g_autoptr(FlValue) args = make_create_regular_args(800, 600);
121 set_size_arg(args, "minSize", 100, 200);
122
123 gboolean called = FALSE;
124 fl_mock_binary_messenger_invoke_standard_method(
125 messenger, "flutter/windowing", "createRegular", args,
126 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
127 gpointer user_data) {
128 parse_create_regular_response(response);
129 gboolean* called = static_cast<gboolean*>(user_data);
130 *called = TRUE;
131 },
132 &called);
133 EXPECT_TRUE(called);
134
135 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
136 }

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_windowing_handler_new(), make_create_regular_args(), parse_create_regular_response(), set_size_arg(), TRUE, and user_data.

## ◆ TEST() [6/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | CreateRegularWithTitle |
| ) |  |

Definition at line 174 of file fl_windowing_handler_test.cc.

174 {
175 flutter::testing::fl_ensure_gtk_init();
176 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
177
178 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
179 g_autoptr(FlEngine) engine =
180 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
181 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
182
183 EXPECT_CALL(mock_gtk, gtk_window_new);
184 EXPECT_CALL(mock_gtk,
185 gtk_window_set_title(::testing::_, ::testing::StrEq("TITLE")));
186
187 g_autoptr(FlValue) args = make_create_regular_args(800, 600);
188 fl_value_set_string_take(args, "title", fl_value_new_string("TITLE"));
189
190 gboolean called = FALSE;
191 fl_mock_binary_messenger_invoke_standard_method(
192 messenger, "flutter/windowing", "createRegular", args,
193 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
194 gpointer user_data) {
195 parse_create_regular_response(response);
196 gboolean* called = static_cast<gboolean*>(user_data);
197 *called = TRUE;
198 },
199 &called);
200 EXPECT_TRUE(called);
201
202 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
203 }

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), parse_create_regular_response(), TRUE, and user_data.

## ◆ TEST() [7/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | DestroyUnknownWindow |
| ) |  |

Definition at line 614 of file fl_windowing_handler_test.cc.

614 {
615 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
616 g_autoptr(FlEngine) engine =
617 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
618 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
619
620 g_autoptr(FlValue) args = make_destroy_window_args(99);
621 gboolean called = FALSE;
622 fl_mock_binary_messenger_invoke_standard_method(
623 messenger, "flutter/windowing", "destroyWindow", args,
624 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
625 gpointer user_data) {
626 EXPECT_TRUE(FL_IS_METHOD_ERROR_RESPONSE(response));
627 EXPECT_STREQ(fl_method_error_response_get_code(
628 FL_METHOD_ERROR_RESPONSE(response)),
629 "Bad Arguments");
630 EXPECT_STREQ(fl_method_error_response_get_message(
631 FL_METHOD_ERROR_RESPONSE(response)),
632 "No window with given view ID");
633 gboolean* called = static_cast<gboolean*>(user_data);
634 *called = TRUE;
635 },
636 &called);
637 EXPECT_TRUE(called);
638
639 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
640 }
fl_method_error_response_get_code
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)
Definition: fl_method_response.cc:160
fl_method_error_response_get_message
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
Definition: fl_method_response.cc:166
make_destroy_window_args
static FlValue * make_destroy_window_args(int64_t view_id)
Definition: fl_windowing_handler_test.cc:67

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_method_error_response_get_code(), fl_method_error_response_get_message(), fl_windowing_handler_new(), make_destroy_window_args(), TRUE, and user_data.

## ◆ TEST() [8/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | DestroyWindow |
| ) |  |

Definition at line 573 of file fl_windowing_handler_test.cc.

573 {
574 flutter::testing::fl_ensure_gtk_init();
575 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
576
577 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
578 g_autoptr(FlEngine) engine =
579 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
580 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
581
582 EXPECT_CALL(mock_gtk, gtk_window_new);
583 EXPECT_CALL(mock_gtk, gtk_widget_destroy);
584
585 g_autoptr(FlValue) create_args = make_create_regular_args(800, 600);
586
587 int64_t view_id = -1;
588 fl_mock_binary_messenger_invoke_standard_method(
589 messenger, "flutter/windowing", "createRegular", create_args,
590 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
591 gpointer user_data) {
592 int64_t* view_id = static_cast<int64_t*>(user_data);
593 *view_id = parse_create_regular_response(response);
594 },
595 &view_id);
596 EXPECT_GT(view_id, 0);
597
598 g_autoptr(FlValue) destroy_args = make_destroy_window_args(view_id);
599 gboolean destroy_called = FALSE;
600 fl_mock_binary_messenger_invoke_standard_method(
601 messenger, "flutter/windowing", "destroyWindow", destroy_args,
602 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
603 gpointer user_data) {
604 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
605 gboolean* called = static_cast<gboolean*>(user_data);
606 *called = TRUE;
607 },
608 &destroy_called);
609 EXPECT_TRUE(destroy_called);
610
611 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
612 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_windowing_handler_new(), make_create_regular_args(), make_destroy_window_args(), parse_create_regular_response(), TRUE, user_data, and view_id.

## ◆ TEST() [9/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | ModifyRegularMaximize |
| ) |  |

Definition at line 354 of file fl_windowing_handler_test.cc.

354 {
355 flutter::testing::fl_ensure_gtk_init();
356 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
357
358 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
359 g_autoptr(FlEngine) engine =
360 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
361 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
362
363 EXPECT_CALL(mock_gtk, gtk_window_new);
364
365 g_autoptr(FlValue) create_args = make_create_regular_args(800, 600);
366
367 int64_t view_id = -1;
368 fl_mock_binary_messenger_invoke_standard_method(
369 messenger, "flutter/windowing", "createRegular", create_args,
370 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
371 gpointer user_data) {
372 int64_t* view_id = static_cast<int64_t*>(user_data);
373 *view_id = parse_create_regular_response(response);
374 },
375 &view_id);
376 EXPECT_GT(view_id, 0);
377
378 EXPECT_CALL(mock_gtk, gtk_window_maximize(::testing::_));
379
380 g_autoptr(FlValue) modify_args = make_modify_regular_args(view_id);
381 fl_value_set_string_take(modify_args, "state",
382 fl_value_new_string("WindowState.maximized"));
383
384 gboolean modify_called = FALSE;
385 fl_mock_binary_messenger_invoke_standard_method(
386 messenger, "flutter/windowing", "modifyRegular", modify_args,
387 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
388 gpointer user_data) {
389 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
390 gboolean* called = static_cast<gboolean*>(user_data);
391 *called = TRUE;
392 },
393 &modify_called);
394 EXPECT_TRUE(modify_called);
395
396 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
397 }
make_modify_regular_args
static FlValue * make_modify_regular_args(int64_t view_id)
Definition: fl_windowing_handler_test.cc:61

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), make_modify_regular_args(), parse_create_regular_response(), TRUE, user_data, and view_id.

## ◆ TEST() [10/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | ModifyRegularMinimize |
| ) |  |

Definition at line 449 of file fl_windowing_handler_test.cc.

449 {
450 flutter::testing::fl_ensure_gtk_init();
451 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
452
453 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
454 g_autoptr(FlEngine) engine =
455 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
456 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
457
458 EXPECT_CALL(mock_gtk, gtk_window_new);
459
460 g_autoptr(FlValue) create_args = make_create_regular_args(800, 600);
461
462 int64_t view_id = -1;
463 fl_mock_binary_messenger_invoke_standard_method(
464 messenger, "flutter/windowing", "createRegular", create_args,
465 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
466 gpointer user_data) {
467 int64_t* view_id = static_cast<int64_t*>(user_data);
468 *view_id = parse_create_regular_response(response);
469 },
470 &view_id);
471 EXPECT_GT(view_id, 0);
472
473 EXPECT_CALL(mock_gtk, gtk_window_iconify(::testing::_));
474
475 g_autoptr(FlValue) modify_args = make_modify_regular_args(view_id);
476 fl_value_set_string_take(modify_args, "state",
477 fl_value_new_string("WindowState.minimized"));
478
479 gboolean modify_called = FALSE;
480 fl_mock_binary_messenger_invoke_standard_method(
481 messenger, "flutter/windowing", "modifyRegular", modify_args,
482 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
483 gpointer user_data) {
484 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
485 gboolean* called = static_cast<gboolean*>(user_data);
486 *called = TRUE;
487 },
488 &modify_called);
489 EXPECT_TRUE(modify_called);
490
491 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
492 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), make_modify_regular_args(), parse_create_regular_response(), TRUE, user_data, and view_id.

## ◆ TEST() [11/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | ModifyRegularSize |
| ) |  |

Definition at line 267 of file fl_windowing_handler_test.cc.

267 {
268 flutter::testing::fl_ensure_gtk_init();
269 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
270
271 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
272 g_autoptr(FlEngine) engine =
273 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
274 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
275
276 EXPECT_CALL(mock_gtk, gtk_window_new);
277 EXPECT_CALL(mock_gtk, gtk_window_resize(::testing::_, 1024, 768));
278
279 g_autoptr(FlValue) create_args = make_create_regular_args(800, 600);
280
281 int64_t view_id = -1;
282 fl_mock_binary_messenger_invoke_standard_method(
283 messenger, "flutter/windowing", "createRegular", create_args,
284 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
285 gpointer user_data) {
286 int64_t* view_id = static_cast<int64_t*>(user_data);
287 *view_id = parse_create_regular_response(response);
288 },
289 &view_id);
290 EXPECT_GT(view_id, 0);
291
292 g_autoptr(FlValue) modify_args = make_modify_regular_args(view_id);
293 set_size_arg(modify_args, "size", 1024, 768);
294
295 gboolean modify_called = FALSE;
296 fl_mock_binary_messenger_invoke_standard_method(
297 messenger, "flutter/windowing", "modifyRegular", modify_args,
298 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
299 gpointer user_data) {
300 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
301 gboolean* called = static_cast<gboolean*>(user_data);
302 *called = TRUE;
303 },
304 &modify_called);
305 EXPECT_TRUE(modify_called);
306
307 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
308 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_windowing_handler_new(), make_create_regular_args(), make_modify_regular_args(), parse_create_regular_response(), set_size_arg(), TRUE, user_data, and view_id.

## ◆ TEST() [12/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | ModifyRegularTitle |
| ) |  |

Definition at line 310 of file fl_windowing_handler_test.cc.

310 {
311 flutter::testing::fl_ensure_gtk_init();
312 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
313
314 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
315 g_autoptr(FlEngine) engine =
316 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
317 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
318
319 EXPECT_CALL(mock_gtk, gtk_window_new);
320 EXPECT_CALL(mock_gtk,
321 gtk_window_set_title(::testing::_, ::testing::StrEq("TITLE")));
322
323 g_autoptr(FlValue) create_args = make_create_regular_args(800, 600);
324
325 int64_t view_id = -1;
326 fl_mock_binary_messenger_invoke_standard_method(
327 messenger, "flutter/windowing", "createRegular", create_args,
328 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
329 gpointer user_data) {
330 int64_t* view_id = static_cast<int64_t*>(user_data);
331 *view_id = parse_create_regular_response(response);
332 },
333 &view_id);
334 EXPECT_GT(view_id, 0);
335
336 g_autoptr(FlValue) modify_args = make_modify_regular_args(view_id);
337 fl_value_set_string_take(modify_args, "title", fl_value_new_string("TITLE"));
338
339 gboolean modify_called = FALSE;
340 fl_mock_binary_messenger_invoke_standard_method(
341 messenger, "flutter/windowing", "modifyRegular", modify_args,
342 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
343 gpointer user_data) {
344 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
345 gboolean* called = static_cast<gboolean*>(user_data);
346 *called = TRUE;
347 },
348 &modify_called);
349 EXPECT_TRUE(modify_called);
350
351 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
352 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), make_modify_regular_args(), parse_create_regular_response(), TRUE, user_data, and view_id.

## ◆ TEST() [13/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | ModifyRegularUnmaximize |
| ) |  |

Definition at line 399 of file fl_windowing_handler_test.cc.

399 {
400 flutter::testing::fl_ensure_gtk_init();
401 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
402
403 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
404 g_autoptr(FlEngine) engine =
405 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
406 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
407
408 EXPECT_CALL(mock_gtk, gtk_window_new);
409 EXPECT_CALL(mock_gtk, gtk_window_maximize(::testing::_));
410
411 g_autoptr(FlValue) create_args = make_create_regular_args(800, 600);
412 fl_value_set_string_take(create_args, "state",
413 fl_value_new_string("WindowState.maximized"));
414
415 int64_t view_id = -1;
416 fl_mock_binary_messenger_invoke_standard_method(
417 messenger, "flutter/windowing", "createRegular", create_args,
418 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
419 gpointer user_data) {
420 int64_t* view_id = static_cast<int64_t*>(user_data);
421 *view_id = parse_create_regular_response(response);
422 },
423 &view_id);
424 EXPECT_GT(view_id, 0);
425
426 EXPECT_CALL(mock_gtk, gtk_window_is_maximized(::testing::_))
427 .WillOnce(::testing::Return(TRUE));
428 EXPECT_CALL(mock_gtk, gtk_window_unmaximize(::testing::_));
429
430 g_autoptr(FlValue) modify_args = make_modify_regular_args(view_id);
431 fl_value_set_string_take(modify_args, "state",
432 fl_value_new_string("WindowState.restored"));
433
434 gboolean modify_called = FALSE;
435 fl_mock_binary_messenger_invoke_standard_method(
436 messenger, "flutter/windowing", "modifyRegular", modify_args,
437 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
438 gpointer user_data) {
439 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
440 gboolean* called = static_cast<gboolean*>(user_data);
441 *called = TRUE;
442 },
443 &modify_called);
444 EXPECT_TRUE(modify_called);
445
446 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
447 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), make_modify_regular_args(), parse_create_regular_response(), TRUE, user_data, and view_id.

## ◆ TEST() [14/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | ModifyRegularUnminimize |
| ) |  |

Definition at line 494 of file fl_windowing_handler_test.cc.

494 {
495 flutter::testing::fl_ensure_gtk_init();
496 ::testing::NiceMock<flutter::testing::MockGtk> mock_gtk;
497
498 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
499 g_autoptr(FlEngine) engine =
500 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
501 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
502
503 EXPECT_CALL(mock_gtk, gtk_window_new);
504 EXPECT_CALL(mock_gtk, gtk_window_iconify(::testing::_));
505
506 g_autoptr(FlValue) create_args = make_create_regular_args(800, 600);
507 fl_value_set_string_take(create_args, "state",
508 fl_value_new_string("WindowState.minimized"));
509
510 int64_t view_id = -1;
511 fl_mock_binary_messenger_invoke_standard_method(
512 messenger, "flutter/windowing", "createRegular", create_args,
513 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
514 gpointer user_data) {
515 int64_t* view_id = static_cast<int64_t*>(user_data);
516 *view_id = parse_create_regular_response(response);
517 },
518 &view_id);
519 EXPECT_GT(view_id, 0);
520
521 EXPECT_CALL(mock_gtk, gdk_window_get_state(::testing::_))
522 .WillOnce(::testing::Return(GDK_WINDOW_STATE_ICONIFIED));
523 EXPECT_CALL(mock_gtk, gtk_window_deiconify(::testing::_));
524
525 g_autoptr(FlValue) modify_args = make_modify_regular_args(view_id);
526 fl_value_set_string_take(modify_args, "state",
527 fl_value_new_string("WindowState.restored"));
528
529 gboolean modify_called = FALSE;
530 fl_mock_binary_messenger_invoke_standard_method(
531 messenger, "flutter/windowing", "modifyRegular", modify_args,
532 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
533 gpointer user_data) {
534 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
535 gboolean* called = static_cast<gboolean*>(user_data);
536 *called = TRUE;
537 },
538 &modify_called);
539 EXPECT_TRUE(modify_called);
540
541 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
542 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_new_string(), fl_value_set_string_take(), fl_windowing_handler_new(), make_create_regular_args(), make_modify_regular_args(), parse_create_regular_response(), TRUE, user_data, and view_id.

## ◆ TEST() [15/15]

TEST | ( | FlWindowingHandlerTest | ,
|  | ModifyUnknownWindow |
| ) |  |

Definition at line 544 of file fl_windowing_handler_test.cc.

544 {
545 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
546 g_autoptr(FlEngine) engine =
547 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
548 g_autoptr(FlWindowingHandler) handler = fl_windowing_handler_new(engine);
549
550 g_autoptr(FlValue) args = make_modify_regular_args(99);
551
552 gboolean called = FALSE;
553 fl_mock_binary_messenger_invoke_standard_method(
554 messenger, "flutter/windowing", "modifyRegular", args,
555 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
556 gpointer user_data) {
557 EXPECT_TRUE(FL_IS_METHOD_ERROR_RESPONSE(response));
558 EXPECT_STREQ(fl_method_error_response_get_code(
559 FL_METHOD_ERROR_RESPONSE(response)),
560 "Bad Arguments");
561 EXPECT_STREQ(fl_method_error_response_get_message(
562 FL_METHOD_ERROR_RESPONSE(response)),
563 "No window with given view ID");
564 gboolean* called = static_cast<gboolean*>(user_data);
565 *called = TRUE;
566 },
567 &called);
568 EXPECT_TRUE(called);
569
570 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
571 }

References args, fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_method_error_response_get_code(), fl_method_error_response_get_message(), fl_windowing_handler_new(), make_modify_regular_args(), TRUE, and user_data.