Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f560517

Browse files
committed
Add ability to monitor GTK logs
1 parent 72977cb commit f560517

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5082,6 +5082,7 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_view_accessible.cc + ../../../f
50825082
ORIGIN: ../../../flutter/shell/platform/linux/fl_view_accessible.h + ../../../flutter/LICENSE
50835083
ORIGIN: ../../../flutter/shell/platform/linux/fl_view_accessible_test.cc + ../../../flutter/LICENSE
50845084
ORIGIN: ../../../flutter/shell/platform/linux/fl_view_private.h + ../../../flutter/LICENSE
5085+
ORIGIN: ../../../flutter/shell/platform/linux/fl_view_test.cc + ../../../flutter/LICENSE
50855086
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping.g.cc + ../../../flutter/LICENSE
50865087
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping.h + ../../../flutter/LICENSE
50875088
ORIGIN: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h + ../../../flutter/LICENSE
@@ -7893,6 +7894,7 @@ FILE: ../../../flutter/shell/platform/linux/fl_view_accessible.cc
78937894
FILE: ../../../flutter/shell/platform/linux/fl_view_accessible.h
78947895
FILE: ../../../flutter/shell/platform/linux/fl_view_accessible_test.cc
78957896
FILE: ../../../flutter/shell/platform/linux/fl_view_private.h
7897+
FILE: ../../../flutter/shell/platform/linux/fl_view_test.cc
78967898
FILE: ../../../flutter/shell/platform/linux/key_mapping.g.cc
78977899
FILE: ../../../flutter/shell/platform/linux/key_mapping.h
78987900
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h

shell/platform/linux/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ executable("flutter_linux_unittests") {
227227
"fl_texture_registrar_test.cc",
228228
"fl_value_test.cc",
229229
"fl_view_accessible_test.cc",
230+
"fl_view_test.cc",
230231
"testing/fl_test.cc",
232+
"testing/fl_test_gtk_logs.cc",
233+
"testing/fl_test_gtk_logs.h",
231234
"testing/mock_binary_messenger.cc",
232235
"testing/mock_binary_messenger_response_handle.cc",
233236
"testing/mock_engine.cc",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"
6+
#include "flutter/shell/platform/linux/testing/fl_test_gtk_logs.h"
7+
8+
#include "gtest/gtest.h"
9+
10+
TEST(FlViewTest, StateUpdateDoesNotHappenInInit) {
11+
flutter::testing::fl_ensure_gtk_init();
12+
g_autoptr(FlDartProject) project = fl_dart_project_new();
13+
g_autoptr(FlView) view = fl_view_new(project);
14+
// Check that creating a view doesn't try to query the window state in
15+
// initialization, causing a critical log to be issued.
16+
EXPECT_EQ(
17+
flutter::testing::fl_get_received_gtk_log_levels() & G_LOG_LEVEL_CRITICAL,
18+
(GLogLevelFlags)0x0);
19+
g_object_ref_sink(view);
20+
}

testing/BUILD.gn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ source_set("testing") {
4949

5050
sources = [ "run_all_unittests.cc" ]
5151

52+
if (is_linux) {
53+
# So that we can call gtk_init in main().
54+
configs += [ "//flutter/shell/platform/linux/config:gtk" ]
55+
}
56+
5257
public_deps = [ ":testing_lib" ]
5358
public_configs = [ ":dynamic_symbols" ]
5459
}

0 commit comments

Comments
 (0)