6 #include "flutter/shell/platform/linux/testing/fl_test.h"
7 #include "flutter/shell/platform/linux/testing/mock_settings.h"
8 #include "flutter/shell/platform/linux/testing/mock_signal_handler.h"
9 #include "flutter/testing/testing.h"
12 #define G_SETTINGS_ENABLE_BACKEND
13 #include <gio/gsettingsbackend.h>
15 #include "gmock/gmock.h"
16 #include "gtest/gtest.h"
22 g_settings_backend_get_default();
27 g_autofree gchar* path =
28 g_build_filename(flutter::testing::GetFixturesPath(), name,
nullptr);
29 g_autoptr(GSettingsSchemaSource) source =
30 g_settings_schema_source_new_from_directory(path,
nullptr,
false,
32 g_autoptr(GSettingsSchema) schema =
33 g_settings_schema_source_lookup(source, schema_id,
false);
34 g_autoptr(GSettingsBackend) backend = g_memory_settings_backend_new();
35 return g_settings_new_full(schema, backend,
nullptr);
39 g_autoptr(GSettings) interface_settings =
41 g_settings_set_string(interface_settings,
"clock-format",
"24h");
43 g_autoptr(FlSettings) settings = FL_SETTINGS(
44 g_object_new(fl_gnome_settings_get_type(),
"interface_settings",
45 interface_settings,
nullptr));
48 flutter::testing::MockSignalHandler settings_changed(settings,
"changed");
49 EXPECT_SIGNAL(settings_changed).Times(1);
51 g_settings_set_string(interface_settings,
"clock-format",
"12h");
56 g_autoptr(GSettings) interface_settings =
58 g_settings_set_string(interface_settings,
"gtk-theme",
"Yaru");
60 g_autoptr(FlSettings) settings = FL_SETTINGS(
61 g_object_new(fl_gnome_settings_get_type(),
"interface_settings",
62 interface_settings,
nullptr));
65 flutter::testing::MockSignalHandler settings_changed(settings,
"changed");
66 EXPECT_SIGNAL(settings_changed).Times(1);
68 g_settings_set_string(interface_settings,
"gtk-theme",
"Yaru-dark");
83 g_autoptr(GSettings) interface_settings =
85 g_settings_set_double(interface_settings,
"text-scaling-factor", 1.0);
87 g_autoptr(FlSettings) settings = FL_SETTINGS(
88 g_object_new(fl_gnome_settings_get_type(),
"interface_settings",
89 interface_settings,
nullptr));
92 flutter::testing::MockSignalHandler settings_changed(settings,
"changed");
93 EXPECT_SIGNAL(settings_changed).Times(1);
95 g_settings_set_double(interface_settings,
"text-scaling-factor", 1.5);
100 g_autoptr(GSettings) interface_settings =
103 g_autoptr(FlSettings) settings = FL_SETTINGS(
104 g_object_new(fl_gnome_settings_get_type(),
"interface_settings",
105 interface_settings,
nullptr));
106 flutter::testing::MockSignalHandler settings_changed(settings,
"changed");
108 EXPECT_SIGNAL(settings_changed).Times(3);
110 g_settings_set_string(interface_settings,
"clock-format",
"12h");
111 g_settings_set_string(interface_settings,
"gtk-theme",
"Yaru-dark");
112 g_settings_set_double(interface_settings,
"text-scaling-factor", 1.5);
114 EXPECT_SIGNAL(settings_changed).Times(0);
116 g_clear_object(&settings);
119 g_settings_set_string(interface_settings,
"clock-format",
"24h");
120 g_settings_set_string(interface_settings,
"gtk-theme",
"Yaru");
121 g_settings_set_double(interface_settings,
"text-scaling-factor", 2.0);