6 #include "flutter/shell/platform/embedder/embedder.h"
7 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
12 #include "flutter/shell/platform/linux/testing/fl_test.h"
13 #include "flutter/shell/platform/linux/testing/mock_binary_messenger.h"
14 #include "flutter/shell/platform/linux/testing/mock_settings.h"
15 #include "flutter/testing/testing.h"
17 #include "gmock/gmock.h"
18 #include "gtest/gtest.h"
27 *result_listener << ::testing::PrintToString(message);
31 #define EXPECT_SETTING(messenger, key, value) \
34 fl_binary_messenger_send_on_channel( \
35 ::testing::Eq<FlBinaryMessenger*>(messenger), \
36 ::testing::StrEq("flutter/settings"), HasSetting(key, value), \
37 ::testing::A<GCancellable*>(), ::testing::A<GAsyncReadyCallback>(), \
38 ::testing::A<gpointer>()))
40 TEST(FlSettingsHandlerTest, AlwaysUse24HourFormat) {
41 ::testing::NiceMock<flutter::testing::MockSettings> settings;
42 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
44 g_autoptr(FlEngine) engine =
45 FL_ENGINE(g_object_new(fl_engine_get_type(),
"binary-messenger",
46 FL_BINARY_MESSENGER(messenger),
nullptr));
53 ::testing::Eq<FlSettings*>(settings)))
66 TEST(FlSettingsHandlerTest, PlatformBrightness) {
67 ::testing::NiceMock<flutter::testing::MockSettings> settings;
68 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
70 g_autoptr(FlEngine) engine =
71 FL_ENGINE(g_object_new(fl_engine_get_type(),
"binary-messenger",
72 FL_BINARY_MESSENGER(messenger),
nullptr));
79 ::testing::Eq<FlSettings*>(settings)))
92 TEST(FlSettingsHandlerTest, TextScaleFactor) {
93 ::testing::NiceMock<flutter::testing::MockSettings> settings;
94 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
96 g_autoptr(FlEngine) engine =
97 FL_ENGINE(g_object_new(fl_engine_get_type(),
"binary-messenger",
98 FL_BINARY_MESSENGER(messenger),
nullptr));
105 ::testing::Eq<FlSettings*>(settings)))
106 .WillOnce(::testing::Return(1.0))
107 .WillOnce(::testing::Return(2.0));
120 TEST(FlSettingsHandlerTest, AccessibilityFeatures) {
124 std::vector<FlutterAccessibilityFeature> calls;
125 embedder_api->UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
126 UpdateAccessibilityFeatures,
127 ([&calls](
auto engine, FlutterAccessibilityFeature features) {
128 calls.push_back(features);
134 ::testing::NiceMock<flutter::testing::MockSettings> settings;
137 ::testing::Eq<FlSettings*>(settings)))
138 .WillOnce(::testing::Return(
false))
139 .WillOnce(::testing::Return(
true))
140 .WillOnce(::testing::Return(
false))
141 .WillOnce(::testing::Return(
true));
144 ::testing::Eq<FlSettings*>(settings)))
145 .WillOnce(::testing::Return(
true))
146 .WillOnce(::testing::Return(
false))
147 .WillOnce(::testing::Return(
false))
148 .WillOnce(::testing::Return(
true));
151 EXPECT_THAT(calls, ::testing::SizeIs(1));
152 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(
153 kFlutterAccessibilityFeatureDisableAnimations |
154 kFlutterAccessibilityFeatureHighContrast));
157 EXPECT_THAT(calls, ::testing::SizeIs(2));
158 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(0));
161 EXPECT_THAT(calls, ::testing::SizeIs(3));
162 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(
163 kFlutterAccessibilityFeatureDisableAnimations));
166 EXPECT_THAT(calls, ::testing::SizeIs(4));
167 EXPECT_EQ(calls.back(),
static_cast<FlutterAccessibilityFeature
>(
168 kFlutterAccessibilityFeatureHighContrast));