| Flutter Linux Embedder |

Classes | Macros | Functions
fl_gnome_settings_test.cc File Reference
`#include "flutter/shell/platform/linux/fl_gnome_settings.h"`
`#include "flutter/shell/platform/linux/testing/fl_test.h"`
`#include "flutter/shell/platform/linux/testing/mock_settings.h"`
`#include "flutter/shell/platform/linux/testing/mock_signal_handler.h"`
`#include "flutter/testing/testing.h"`
`#include <gio/gio.h>`
`#include <gio/gsettingsbackend.h>`
`#include "gmock/gmock.h"`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Classes
class | FlGnomeSettingsTest

## Macros
#define | G_SETTINGS_ENABLE_BACKEND

## Functions
static GSettings * | create_settings (const gchar *name, const gchar *schema_id)
| TEST_F (FlGnomeSettingsTest, ClockFormat)
| TEST_F (FlGnomeSettingsTest, GtkTheme)
| TEST_F (FlGnomeSettingsTest, EnableAnimations)
| TEST_F (FlGnomeSettingsTest, HighContrast)
| TEST_F (FlGnomeSettingsTest, TextScalingFactor)
| TEST_F (FlGnomeSettingsTest, SignalHandlers)

## Macro Definition Documentation

## ◆ G_SETTINGS_ENABLE_BACKEND

#define G_SETTINGS_ENABLE_BACKEND

Definition at line 12 of file fl_gnome_settings_test.cc.

## Function Documentation

## ◆ create_settings()

static GSettings* create_settings | ( | const gchar * | name,
|  | const gchar * | schema_id
| ) |  |
| static

Definition at line 26 of file fl_gnome_settings_test.cc.

26 {
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,
31 nullptr);
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);
36 }
g_autoptr
g_autoptr(FlEngine) engine

References g_autoptr().

Referenced by TEST_F().

## ◆ TEST_F() [1/6]

TEST_F | ( | FlGnomeSettingsTest | ,
|  | ClockFormat |
| ) |  |

Definition at line 38 of file fl_gnome_settings_test.cc.

38 {
39 g_autoptr(GSettings) interface_settings =
40 create_settings("ubuntu-20.04", "org.gnome.desktop.interface");
41 g_settings_set_string(interface_settings, "clock-format", "24h");
42
43 g_autoptr(FlSettings) settings = FL_SETTINGS(
44 g_object_new(fl_gnome_settings_get_type(), "interface_settings",
45 interface_settings, nullptr));
46 EXPECT_EQ(fl_settings_get_clock_format(settings), FL_CLOCK_FORMAT_24H);
47
48 flutter::testing::MockSignalHandler settings_changed(settings, "changed");
49 EXPECT_SIGNAL(settings_changed).Times(1);
50
51 g_settings_set_string(interface_settings, "clock-format", "12h");
52 EXPECT_EQ(fl_settings_get_clock_format(settings), FL_CLOCK_FORMAT_12H);
53 }
create_settings
static GSettings * create_settings(const gchar *name, const gchar *schema_id)
Definition: fl_gnome_settings_test.cc:26
fl_settings_get_clock_format
FlClockFormat fl_settings_get_clock_format(FlSettings *self)
Definition: fl_settings.cc:30
FL_CLOCK_FORMAT_12H
@ FL_CLOCK_FORMAT_12H
Definition: fl_settings.h:22
FL_CLOCK_FORMAT_24H
@ FL_CLOCK_FORMAT_24H
Definition: fl_settings.h:23

References create_settings(), FL_CLOCK_FORMAT_12H, FL_CLOCK_FORMAT_24H, fl_settings_get_clock_format(), and g_autoptr().

## ◆ TEST_F() [2/6]

TEST_F | ( | FlGnomeSettingsTest | ,
|  | EnableAnimations |
| ) |  |

Definition at line 72 of file fl_gnome_settings_test.cc.

72 {
73 g_autoptr(FlSettings) settings = fl_gnome_settings_new();
74 EXPECT_TRUE(fl_settings_get_enable_animations(settings));
75 }
fl_gnome_settings_new
FlSettings * fl_gnome_settings_new()
Definition: fl_gnome_settings.cc:164
fl_settings_get_enable_animations
gboolean fl_settings_get_enable_animations(FlSettings *self)
Definition: fl_settings.cc:38

References fl_gnome_settings_new(), fl_settings_get_enable_animations(), and g_autoptr().

## ◆ TEST_F() [3/6]

TEST_F | ( | FlGnomeSettingsTest | ,
|  | GtkTheme |
| ) |  |

Definition at line 55 of file fl_gnome_settings_test.cc.

55 {
56 g_autoptr(GSettings) interface_settings =
57 create_settings("ubuntu-20.04", "org.gnome.desktop.interface");
58 g_settings_set_string(interface_settings, "gtk-theme", "Yaru");
59
60 g_autoptr(FlSettings) settings = FL_SETTINGS(
61 g_object_new(fl_gnome_settings_get_type(), "interface_settings",
62 interface_settings, nullptr));
63 EXPECT_EQ(fl_settings_get_color_scheme(settings), FL_COLOR_SCHEME_LIGHT);
64
65 flutter::testing::MockSignalHandler settings_changed(settings, "changed");
66 EXPECT_SIGNAL(settings_changed).Times(1);
67
68 g_settings_set_string(interface_settings, "gtk-theme", "Yaru-dark");
69 EXPECT_EQ(fl_settings_get_color_scheme(settings), FL_COLOR_SCHEME_DARK);
70 }
fl_settings_get_color_scheme
FlColorScheme fl_settings_get_color_scheme(FlSettings *self)
Definition: fl_settings.cc:34
FL_COLOR_SCHEME_DARK
@ FL_COLOR_SCHEME_DARK
Definition: fl_settings.h:35
FL_COLOR_SCHEME_LIGHT
@ FL_COLOR_SCHEME_LIGHT
Definition: fl_settings.h:34

References create_settings(), FL_COLOR_SCHEME_DARK, FL_COLOR_SCHEME_LIGHT, fl_settings_get_color_scheme(), and g_autoptr().

## ◆ TEST_F() [4/6]

TEST_F | ( | FlGnomeSettingsTest | ,
|  | HighContrast |
| ) |  |

Definition at line 77 of file fl_gnome_settings_test.cc.

77 {
78 g_autoptr(FlSettings) settings = fl_gnome_settings_new();
79 EXPECT_FALSE(fl_settings_get_high_contrast(settings));
80 }
fl_settings_get_high_contrast
gboolean fl_settings_get_high_contrast(FlSettings *self)
Definition: fl_settings.cc:42

References fl_gnome_settings_new(), fl_settings_get_high_contrast(), and g_autoptr().

## ◆ TEST_F() [5/6]

TEST_F | ( | FlGnomeSettingsTest | ,
|  | SignalHandlers |
| ) |  |

Definition at line 99 of file fl_gnome_settings_test.cc.

99 {
100 g_autoptr(GSettings) interface_settings =
101 create_settings("ubuntu-20.04", "org.gnome.desktop.interface");
102
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");
107
108 EXPECT_SIGNAL(settings_changed).Times(3);
109
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);
113
114 EXPECT_SIGNAL(settings_changed).Times(0);
115
116 g_clear_object(&settings);
117
118 // destroyed FlSettings object must have disconnected its signal handlers
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);
122 }

References create_settings(), and g_autoptr().

## ◆ TEST_F() [6/6]

TEST_F | ( | FlGnomeSettingsTest | ,
|  | TextScalingFactor |
| ) |  |

Definition at line 82 of file fl_gnome_settings_test.cc.

82 {
83 g_autoptr(GSettings) interface_settings =
84 create_settings("ubuntu-20.04", "org.gnome.desktop.interface");
85 g_settings_set_double(interface_settings, "text-scaling-factor", 1.0);
86
87 g_autoptr(FlSettings) settings = FL_SETTINGS(
88 g_object_new(fl_gnome_settings_get_type(), "interface_settings",
89 interface_settings, nullptr));
90 EXPECT_EQ(fl_settings_get_text_scaling_factor(settings), 1.0);
91
92 flutter::testing::MockSignalHandler settings_changed(settings, "changed");
93 EXPECT_SIGNAL(settings_changed).Times(1);
94
95 g_settings_set_double(interface_settings, "text-scaling-factor", 1.5);
96 EXPECT_EQ(fl_settings_get_text_scaling_factor(settings), 1.5);
97 }
fl_settings_get_text_scaling_factor
gdouble fl_settings_get_text_scaling_factor(FlSettings *self)
Definition: fl_settings.cc:46

References create_settings(), fl_settings_get_text_scaling_factor(), and g_autoptr().