Flutter Engine
The Flutter Engine
fl_settings_portal_test.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 "flutter/shell/platform/linux/fl_settings_portal.h"
6#include "flutter/shell/platform/linux/testing/fl_test.h"
7#include "flutter/testing/testing.h"
8
9#include <glib.h>
10
11#include "gmock/gmock.h"
12#include "gtest/gtest.h"
13
14TEST(FlSettingsPortalTest, ClockFormat) {
15 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
16
17 g_autoptr(FlSettings) portal =
20
21 g_variant_dict_insert_value(settings,
22 "org.gnome.desktop.interface::clock-format",
23 g_variant_new_string("24h"));
25
26 g_variant_dict_insert_value(settings,
27 "org.gnome.desktop.interface::clock-format",
28 g_variant_new_string("12h"));
30
31 g_variant_dict_insert_value(settings,
32 "org.gnome.desktop.interface::clock-format",
33 g_variant_new_string("unknown"));
35}
36
37TEST(FlSettingsPortalTest, ColorScheme) {
38 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
39
40 g_autoptr(FlSettings) portal =
43
44 g_variant_dict_insert_value(settings,
45 "org.freedesktop.appearance::color-scheme",
46 g_variant_new_uint32(1));
48
49 g_variant_dict_insert_value(settings,
50 "org.freedesktop.appearance::color-scheme",
51 g_variant_new_uint32(2));
53
54 g_variant_dict_insert_value(settings,
55 "org.freedesktop.appearance::color-scheme",
56 g_variant_new_uint32(123));
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"));
64}
65
66TEST(FlSettingsPortalTest, GtkTheme) {
67 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
68
69 g_autoptr(FlSettings) portal =
72
73 g_variant_dict_insert_value(settings,
74 "org.gnome.desktop.interface::gtk-theme",
75 g_variant_new_string("Yaru-dark"));
77
78 g_variant_dict_insert_value(settings,
79 "org.gnome.desktop.interface::gtk-theme",
80 g_variant_new_string("Yaru"));
82
83 g_variant_dict_insert_value(settings,
84 "org.gnome.desktop.interface::gtk-theme",
85 g_variant_new_string("Adwaita"));
87
88 g_variant_dict_insert_value(settings,
89 "org.gnome.desktop.interface::gtk-theme",
90 g_variant_new_string("Adwaita-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));
98}
99
100TEST(FlSettingsPortalTest, EnableAnimations) {
101 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
102
103 g_autoptr(FlSettings) 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}
112
113TEST(FlSettingsPortalTest, HighContrast) {
114 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
115
116 g_autoptr(FlSettings) portal =
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));
124}
125
126TEST(FlSettingsPortalTest, TextScalingFactor) {
127 g_autoptr(GVariantDict) settings = g_variant_dict_new(nullptr);
128
129 g_autoptr(FlSettings) portal =
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}
gboolean fl_settings_get_high_contrast(FlSettings *self)
Definition: fl_settings.cc:42
gdouble fl_settings_get_text_scaling_factor(FlSettings *self)
Definition: fl_settings.cc:46
gboolean fl_settings_get_enable_animations(FlSettings *self)
Definition: fl_settings.cc:38
FlColorScheme fl_settings_get_color_scheme(FlSettings *self)
Definition: fl_settings.cc:34
FlClockFormat fl_settings_get_clock_format(FlSettings *self)
Definition: fl_settings.cc:30
@ FL_COLOR_SCHEME_DARK
Definition: fl_settings.h:38
@ FL_COLOR_SCHEME_LIGHT
Definition: fl_settings.h:37
@ FL_CLOCK_FORMAT_12H
Definition: fl_settings.h:23
@ FL_CLOCK_FORMAT_24H
Definition: fl_settings.h:24
FlSettingsPortal * fl_settings_portal_new_with_values(GVariantDict *values)
TEST(FlSettingsPortalTest, ClockFormat)
SK_API sk_sp< PrecompileColorFilter > HighContrast()
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678