6 #include "flutter/shell/platform/embedder/embedder.h"
7 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
10 #include "flutter/shell/platform/linux/testing/fl_mock_binary_messenger.h"
11 #include "flutter/shell/platform/linux/testing/mock_settings.h"
12 #include "flutter/testing/testing.h"
14 #include "gmock/gmock.h"
15 #include "gtest/gtest.h"
17 TEST(FlSettingsHandlerTest, AlwaysUse24HourFormat) {
18 ::testing::NiceMock<flutter::testing::MockSettings> settings;
20 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
21 g_autoptr(FlEngine) engine =
26 ::testing::Eq<FlSettings*>(settings)))
30 gboolean called = FALSE;
31 fl_mock_binary_messenger_set_json_message_channel(
32 messenger,
"flutter/settings",
33 [](FlMockBinaryMessenger* messenger, GTask* task,
FlValue* message,
35 gboolean* called =
static_cast<gboolean*
>(
user_data);
41 EXPECT_NE(
value,
nullptr);
52 fl_mock_binary_messenger_set_json_message_channel(
53 messenger,
"flutter/settings",
54 [](FlMockBinaryMessenger* messenger, GTask* task,
FlValue* message,
56 gboolean* called =
static_cast<gboolean*
>(
user_data);
62 EXPECT_NE(
value,
nullptr);
75 TEST(FlSettingsHandlerTest, PlatformBrightness) {
76 ::testing::NiceMock<flutter::testing::MockSettings> settings;
78 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
79 g_autoptr(FlEngine) engine =
84 ::testing::Eq<FlSettings*>(settings)))
88 gboolean called = FALSE;
89 fl_mock_binary_messenger_set_json_message_channel(
90 messenger,
"flutter/settings",
91 [](FlMockBinaryMessenger* messenger, GTask* task,
FlValue* message,
93 gboolean* called =
static_cast<gboolean*
>(
user_data);
98 EXPECT_NE(
value,
nullptr);
109 fl_mock_binary_messenger_set_json_message_channel(
110 messenger,
"flutter/settings",
111 [](FlMockBinaryMessenger* messenger, GTask* task,
FlValue* message,
113 gboolean* called =
static_cast<gboolean*
>(
user_data);
118 EXPECT_NE(
value,
nullptr);
131 TEST(FlSettingsHandlerTest, TextScaleFactor) {
132 ::testing::NiceMock<flutter::testing::MockSettings> settings;
134 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
135 g_autoptr(FlEngine) engine =
140 ::testing::Eq<FlSettings*>(settings)))
141 .WillOnce(::testing::Return(1.0))
142 .WillOnce(::testing::Return(2.0));
144 gboolean called = FALSE;
145 fl_mock_binary_messenger_set_json_message_channel(
146 messenger,
"flutter/settings",
147 [](FlMockBinaryMessenger* messenger, GTask* task,
FlValue* message,
149 gboolean* called =
static_cast<gboolean*
>(
user_data);
154 EXPECT_NE(
value,
nullptr);
165 fl_mock_binary_messenger_set_json_message_channel(
166 messenger,
"flutter/settings",
167 [](FlMockBinaryMessenger* messenger, GTask* task,
FlValue* message,
169 gboolean* called =
static_cast<gboolean*
>(
user_data);
174 EXPECT_NE(
value,
nullptr);
189 TEST(FlSettingsHandlerTest, AccessibilityFeatures) {
193 g_autoptr(GError)
error =
nullptr;
195 EXPECT_EQ(
error,
nullptr);
197 std::vector<FlutterAccessibilityFeature> calls;
200 UpdateAccessibilityFeatures,
201 ([&calls](
auto engine, FlutterAccessibilityFeature features) {
202 calls.push_back(features);
208 ::testing::NiceMock<flutter::testing::MockSettings> settings;
211 ::testing::Eq<FlSettings*>(settings)))
212 .WillOnce(::testing::Return(
false))
213 .WillOnce(::testing::Return(
true))
214 .WillOnce(::testing::Return(
false))
215 .WillOnce(::testing::Return(
true));
218 ::testing::Eq<FlSettings*>(settings)))
219 .WillOnce(::testing::Return(
true))
220 .WillOnce(::testing::Return(
false))
221 .WillOnce(::testing::Return(
false))
222 .WillOnce(::testing::Return(
true));
225 EXPECT_THAT(calls, ::testing::SizeIs(1));
226 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(
227 kFlutterAccessibilityFeatureDisableAnimations |
228 kFlutterAccessibilityFeatureHighContrast));
231 EXPECT_THAT(calls, ::testing::SizeIs(2));
232 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(0));
235 EXPECT_THAT(calls, ::testing::SizeIs(3));
236 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(
237 kFlutterAccessibilityFeatureDisableAnimations));
240 EXPECT_THAT(calls, ::testing::SizeIs(4));
241 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(
242 kFlutterAccessibilityFeatureHighContrast));