Flutter Engine
The Flutter Engine
fl_test_gtk_logs.cc
Go to the documentation of this file.
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 "fl_test_gtk_logs.h"
6#include "gtest/gtest.h"
7
8namespace flutter {
9namespace testing {
10
11namespace {
12
13bool gtk_initialized = false;
14GLogWriterFunc log_writer_cb = nullptr;
15GLogLevelFlags fl_received_log_levels = (GLogLevelFlags)0x0;
16
17GLogWriterOutput log_writer(GLogLevelFlags log_level,
18 const GLogField* fields,
19 gsize n_fields,
20 gpointer user_data) {
21 fl_received_log_levels = (GLogLevelFlags)(log_level | fl_received_log_levels);
22 if (log_writer_cb == nullptr) {
23 return g_log_writer_default(log_level, fields, n_fields, user_data);
24 }
25 GLogWriterOutput result =
26 log_writer_cb(log_level, fields, n_fields, user_data);
27 if (result != G_LOG_WRITER_HANDLED) {
28 return g_log_writer_default(log_level, fields, n_fields, user_data);
29 }
30 return result;
31}
32
33} // namespace
34
35void fl_ensure_gtk_init(GLogWriterFunc writer) {
36 if (!gtk_initialized) {
37 gtk_init(0, nullptr);
38 g_log_set_writer_func(log_writer, nullptr, nullptr);
39 gtk_initialized = true;
40 }
42 log_writer_cb = writer;
43}
44
46 fl_received_log_levels = (GLogLevelFlags)0x0;
47}
48
50 return fl_received_log_levels;
51}
52
53} // namespace testing
54} // namespace flutter
GAsyncResult * result
GLogLevelFlags fl_get_received_gtk_log_levels()
Returns the recorded log levels.
void fl_ensure_gtk_init(GLogWriterFunc writer)
Ensures that GTK has been initialized and starts monitoring logs.
void fl_reset_received_gtk_log_levels()
Resets the recorded log levels.
void * user_data