6 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
9 #include "flutter/shell/platform/linux/testing/fl_test.h"
10 #include "flutter/shell/platform/linux/testing/fl_test_gtk_logs.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();
74 FlutterViewId view_id = -1;
75 embedder_api->AddView = MOCK_ENGINE_PROC(
76 AddView, ([&view_id](
auto engine,
const FlutterAddViewInfo* info) {
77 view_id = info->view_id;
78 FlutterAddViewResult
result = {
79 .struct_size =
sizeof(FlutterAddViewResult),
82 info->add_view_callback(&
result);
91 TEST(FlViewTest, SecondaryViewError) {
92 flutter::testing::fl_ensure_gtk_init();
100 FlutterViewId view_id = -1;
101 embedder_api->AddView = MOCK_ENGINE_PROC(
102 AddView, ([&view_id](
auto engine,
const FlutterAddViewInfo* info) {
103 view_id = info->view_id;
104 return kInvalidArguments;
112 TEST(FlViewTest, ViewDestroy) {
113 flutter::testing::fl_ensure_gtk_init();
121 g_autoptr(GPtrArray) removed_views = g_ptr_array_new();
122 embedder_api->RemoveView = MOCK_ENGINE_PROC(
124 ([removed_views](
auto engine,
const FlutterRemoveViewInfo* info) {
125 g_ptr_array_add(removed_views, GINT_TO_POINTER(info->view_id));
134 gtk_widget_destroy(GTK_WIDGET(secondary_view));
135 gtk_widget_destroy(GTK_WIDGET(implicit_view));
137 EXPECT_EQ(removed_views->len, 2u);
138 EXPECT_EQ(GPOINTER_TO_INT(g_ptr_array_index(removed_views, 0)),
140 EXPECT_EQ(GPOINTER_TO_INT(g_ptr_array_index(removed_views, 1)),
145 TEST(FlViewTest, ViewDestroyError) {
146 flutter::testing::fl_ensure_gtk_init();
154 embedder_api->RemoveView = MOCK_ENGINE_PROC(
155 RemoveView, ([](
auto engine,
const FlutterRemoveViewInfo* info) {
156 return kInvalidArguments;
161 gtk_widget_destroy(GTK_WIDGET(secondary_view));
162 gtk_widget_destroy(GTK_WIDGET(implicit_view));