6 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
8 #include "flutter/shell/platform/linux/testing/fl_test.h"
9 #include "flutter/shell/platform/linux/testing/fl_test_gtk_logs.h"
10 #include "flutter/shell/platform/linux/testing/mock_window.h"
12 #include "gtest/gtest.h"
15 *first_frame_emitted =
TRUE;
18 TEST(FlViewTest, GetEngine) {
19 flutter::testing::fl_ensure_gtk_init();
26 EXPECT_NE(engine,
nullptr);
29 TEST(FlViewTest, StateUpdateDoesNotHappenInInit) {
30 flutter::testing::fl_ensure_gtk_init();
36 flutter::testing::fl_get_received_gtk_log_levels() & G_LOG_LEVEL_CRITICAL,
42 TEST(FlViewTest, FirstFrameSignal) {
43 flutter::testing::fl_ensure_gtk_init();
47 gboolean first_frame_emitted = FALSE;
49 &first_frame_emitted);
51 EXPECT_FALSE(first_frame_emitted);
56 while (g_main_context_iteration(g_main_context_default(), FALSE)) {
61 EXPECT_TRUE(first_frame_emitted);
65 TEST(FlViewTest, SecondaryView) {
66 flutter::testing::fl_ensure_gtk_init();
73 FlutterViewId view_id = -1;
75 AddView, ([&view_id](
auto engine,
const FlutterAddViewInfo* info) {
76 view_id = info->view_id;
77 FlutterAddViewResult result = {
78 .struct_size =
sizeof(FlutterAddViewResult),
81 info->add_view_callback(&result);
85 g_autoptr(GError)
error =
nullptr;
93 TEST(FlViewTest, SecondaryViewError) {
94 flutter::testing::fl_ensure_gtk_init();
101 FlutterViewId view_id = -1;
103 AddView, ([&view_id](
auto engine,
const FlutterAddViewInfo* info) {
104 view_id = info->view_id;
105 return kInvalidArguments;
108 g_autoptr(GError)
error =
nullptr;
116 TEST(FlViewTest, ViewDestroy) {
117 flutter::testing::fl_ensure_gtk_init();
124 g_autoptr(GPtrArray) removed_views = g_ptr_array_new();
127 ([removed_views](
auto engine,
const FlutterRemoveViewInfo* info) {
128 g_ptr_array_add(removed_views, GINT_TO_POINTER(info->view_id));
132 g_autoptr(GError)
error =
nullptr;
140 fl_gtk_widget_destroy(GTK_WIDGET(secondary_view));
141 fl_gtk_widget_destroy(GTK_WIDGET(implicit_view));
143 EXPECT_EQ(removed_views->len, 2u);
144 EXPECT_EQ(GPOINTER_TO_INT(g_ptr_array_index(removed_views, 0)),
146 EXPECT_EQ(GPOINTER_TO_INT(g_ptr_array_index(removed_views, 1)),
151 TEST(FlViewTest, ViewDestroyError) {
152 flutter::testing::fl_ensure_gtk_init();
160 RemoveView, ([](
auto engine,
const FlutterRemoveViewInfo* info) {
161 return kInvalidArguments;
164 g_autoptr(GError)
error =
nullptr;
169 fl_gtk_widget_destroy(GTK_WIDGET(secondary_view));
170 fl_gtk_widget_destroy(GTK_WIDGET(implicit_view));