5#include "flutter/shell/platform/linux/fl_settings_plugin.h"
6#include "flutter/shell/platform/embedder/embedder.h"
7#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
8#include "flutter/shell/platform/linux/fl_engine_private.h"
9#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
10#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_message_codec.h"
11#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.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"
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>()))
40TEST(FlSettingsPluginTest, 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)))
66TEST(FlSettingsPluginTest, 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)))
92TEST(FlSettingsPluginTest, 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));
120TEST(FlSettingsPluginTest, AccessibilityFeatures) {
124 std::vector<FlutterAccessibilityFeature> calls;
126 UpdateAccessibilityFeatures,
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));
157 EXPECT_THAT(calls, ::testing::SizeIs(2));
161 EXPECT_THAT(calls, ::testing::SizeIs(3));
166 EXPECT_THAT(calls, ::testing::SizeIs(4));
FlutterAccessibilityFeature
@ kFlutterAccessibilityFeatureHighContrast
Request that UI be rendered with darker colors.
@ kFlutterAccessibilityFeatureDisableAnimations
Request that animations be disabled or simplified.
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
static FlEngine * make_mock_engine()
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
G_MODULE_EXPORT FlValue * fl_message_codec_decode_message(FlMessageCodec *self, GBytes *message, GError **error)
gboolean fl_settings_get_high_contrast(FlSettings *self)
gdouble fl_settings_get_text_scaling_factor(FlSettings *self)
void fl_settings_emit_changed(FlSettings *self)
gboolean fl_settings_get_enable_animations(FlSettings *self)
FlColorScheme fl_settings_get_color_scheme(FlSettings *self)
FlClockFormat fl_settings_get_clock_format(FlSettings *self)
FlSettingsPlugin * fl_settings_plugin_new(FlEngine *engine)
void fl_settings_plugin_start(FlSettingsPlugin *self, FlSettings *settings)
TEST(FlSettingsPluginTest, AlwaysUse24HourFormat)
#define EXPECT_SETTING(messenger, key, value)
MATCHER_P2(HasSetting, key, value, "")
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
typedefG_BEGIN_DECLS struct _FlValue FlValue
static CStringUniquePtr PrintToString(const char *format,...)
#define MOCK_ENGINE_PROC(proc, mock_impl)
Function-pointer-based versions of the APIs above.
FlutterEngineUpdateAccessibilityFeaturesFnPtr UpdateAccessibilityFeatures