| Flutter Linux Embedder |

Functions
fl_settings_portal_test.cc File Reference
`#include "flutter/shell/platform/linux/fl_settings_portal.h"`
`#include "flutter/shell/platform/linux/testing/fl_test.h"`
`#include "flutter/testing/testing.h"`
`#include <glib.h>`
`#include "gmock/gmock.h"`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Functions
| TEST (FlSettingsPortalTest, ClockFormat)
| TEST (FlSettingsPortalTest, ColorScheme)
| TEST (FlSettingsPortalTest, GtkTheme)
| TEST (FlSettingsPortalTest, EnableAnimations)
| TEST (FlSettingsPortalTest, HighContrast)
| TEST (FlSettingsPortalTest, TextScalingFactor)

## Function Documentation

## ◆ TEST() [1/6]

TEST | ( | FlSettingsPortalTest | ,
|  | ClockFormat |
| ) |  |

Definition at line 14 of file fl_settings_portal_test.cc.

14 {
15 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
16
17 g_autoptr(FlSettings) portal =
18 FL_SETTINGS(fl_settings_portal_new_with_values(settings));
19 EXPECT_EQ(fl_settings_get_clock_format(portal), FL_CLOCK_FORMAT_24H);
20
21 g_variant_dict_insert_value(settings,
22 "org.gnome.desktop.interface::clock-format",
23 g_variant_new_string("24h"));
24 EXPECT_EQ(fl_settings_get_clock_format(portal), FL_CLOCK_FORMAT_24H);
25
26 g_variant_dict_insert_value(settings,
27 "org.gnome.desktop.interface::clock-format",
28 g_variant_new_string("12h"));
29 EXPECT_EQ(fl_settings_get_clock_format(portal), FL_CLOCK_FORMAT_12H);
30
31 g_variant_dict_insert_value(settings,
32 "org.gnome.desktop.interface::clock-format",
33 g_variant_new_string("unknown"));
34 EXPECT_EQ(fl_settings_get_clock_format(portal), FL_CLOCK_FORMAT_24H);
35 }

References FL_CLOCK_FORMAT_12H, FL_CLOCK_FORMAT_24H, fl_settings_get_clock_format(), and fl_settings_portal_new_with_values().

## ◆ TEST() [2/6]

TEST | ( | FlSettingsPortalTest | ,
|  | ColorScheme |
| ) |  |

Definition at line 37 of file fl_settings_portal_test.cc.

37 {
38 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
39
40 g_autoptr(FlSettings) portal =
41 FL_SETTINGS(fl_settings_portal_new_with_values(settings));
42 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
43
44 g_variant_dict_insert_value(settings,
45 "org.freedesktop.appearance::color-scheme",
46 g_variant_new_uint32(1));
47 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_DARK);
48
49 g_variant_dict_insert_value(settings,
50 "org.freedesktop.appearance::color-scheme",
51 g_variant_new_uint32(2));
52 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
53
54 g_variant_dict_insert_value(settings,
55 "org.freedesktop.appearance::color-scheme",
56 g_variant_new_uint32(123));
57 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
58
59 // color-scheme takes precedence over gtk-theme
60 g_variant_dict_insert_value(settings,
61 "org.gnome.desktop.interface::gtk-theme",
62 g_variant_new_string("Yaru-dark"));
63 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
64 }

References FL_COLOR_SCHEME_DARK, FL_COLOR_SCHEME_LIGHT, fl_settings_get_color_scheme(), and fl_settings_portal_new_with_values().

## ◆ TEST() [3/6]

TEST | ( | FlSettingsPortalTest | ,
|  | EnableAnimations |
| ) |  |

Definition at line 100 of file fl_settings_portal_test.cc.

100 {
101 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
102
103 g_autoptr(FlSettings) portal =
104 FL_SETTINGS(fl_settings_portal_new_with_values(settings));
105 EXPECT_TRUE(fl_settings_get_enable_animations(portal));
106
107 g_variant_dict_insert_value(settings,
108 "org.gnome.desktop.interface::enable-animations",
109 g_variant_new_boolean(false));
110 EXPECT_FALSE(fl_settings_get_enable_animations(portal));
111 }

References fl_settings_get_enable_animations(), and fl_settings_portal_new_with_values().

## ◆ TEST() [4/6]

TEST | ( | FlSettingsPortalTest | ,
|  | GtkTheme |
| ) |  |

Definition at line 66 of file fl_settings_portal_test.cc.

66 {
67 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
68
69 g_autoptr(FlSettings) portal =
70 FL_SETTINGS(fl_settings_portal_new_with_values(settings));
71 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
72
73 g_variant_dict_insert_value(settings,
74 "org.gnome.desktop.interface::gtk-theme",
75 g_variant_new_string("Yaru-dark"));
76 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_DARK);
77
78 g_variant_dict_insert_value(settings,
79 "org.gnome.desktop.interface::gtk-theme",
80 g_variant_new_string("Yaru"));
81 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
82
83 g_variant_dict_insert_value(settings,
84 "org.gnome.desktop.interface::gtk-theme",
85 g_variant_new_string("Adwaita"));
86 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
87
88 g_variant_dict_insert_value(settings,
89 "org.gnome.desktop.interface::gtk-theme",
90 g_variant_new_string("Adwaita-dark"));
91 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_DARK);
92
93 // color-scheme takes precedence over gtk-theme
94 g_variant_dict_insert_value(settings,
95 "org.freedesktop.appearance::color-scheme",
96 g_variant_new_uint32(2));
97 EXPECT_EQ(fl_settings_get_color_scheme(portal), FL_COLOR_SCHEME_LIGHT);
98 }

References FL_COLOR_SCHEME_DARK, FL_COLOR_SCHEME_LIGHT, fl_settings_get_color_scheme(), and fl_settings_portal_new_with_values().

## ◆ TEST() [5/6]

TEST | ( | FlSettingsPortalTest | ,
|  | HighContrast |
| ) |  |

Definition at line 113 of file fl_settings_portal_test.cc.

113 {
114 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
115
116 g_autoptr(FlSettings) portal =
117 FL_SETTINGS(fl_settings_portal_new_with_values(settings));
118 EXPECT_FALSE(fl_settings_get_high_contrast(portal));
119
120 g_variant_dict_insert_value(settings,
121 "org.gnome.desktop.a11y.interface::high-contrast",
122 g_variant_new_boolean(true));
123 EXPECT_TRUE(fl_settings_get_high_contrast(portal));
124 }

References fl_settings_get_high_contrast(), and fl_settings_portal_new_with_values().

## ◆ TEST() [6/6]

TEST | ( | FlSettingsPortalTest | ,
|  | TextScalingFactor |
| ) |  |

Definition at line 126 of file fl_settings_portal_test.cc.

126 {
127 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
128
129 g_autoptr(FlSettings) portal =
130 FL_SETTINGS(fl_settings_portal_new_with_values(settings));
131 EXPECT_EQ(fl_settings_get_text_scaling_factor(portal), 1.0);
132
133 g_variant_dict_insert_value(
134 settings, "org.gnome.desktop.interface::text-scaling-factor",
135 g_variant_new_double(1.5));
136 EXPECT_EQ(fl_settings_get_text_scaling_factor(portal), 1.5);
137 }

References fl_settings_get_text_scaling_factor(), and fl_settings_portal_new_with_values().

fl_settings_get_color_scheme
FlColorScheme fl_settings_get_color_scheme(FlSettings *self)
Definition: fl_settings.cc:34
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
fl_settings_get_enable_animations
gboolean fl_settings_get_enable_animations(FlSettings *self)
Definition: fl_settings.cc:38
fl_settings_portal_new_with_values
FlSettingsPortal * fl_settings_portal_new_with_values(GVariantDict *values)
Definition: fl_settings_portal.cc:268
fl_settings_get_high_contrast
gboolean fl_settings_get_high_contrast(FlSettings *self)
Definition: fl_settings.cc:42
fl_settings_get_text_scaling_factor
gdouble fl_settings_get_text_scaling_factor(FlSettings *self)
Definition: fl_settings.cc:46
FL_COLOR_SCHEME_LIGHT
@ FL_COLOR_SCHEME_LIGHT
Definition: fl_settings.h:34
FL_COLOR_SCHEME_DARK
@ FL_COLOR_SCHEME_DARK
Definition: fl_settings.h:35
fl_settings_get_clock_format
FlClockFormat fl_settings_get_clock_format(FlSettings *self)
Definition: fl_settings.cc:30