5#include "flutter/shell/platform/windows/settings_plugin.h"
7#include "flutter/fml/macros.h"
8#include "flutter/shell/platform/windows/task_runner.h"
9#include "flutter/shell/platform/windows/testing/test_binary_messenger.h"
10#include "gmock/gmock.h"
11#include "gtest/gtest.h"
18class MockSettingsPlugin :
public SettingsPlugin {
20 explicit MockSettingsPlugin(BinaryMessenger* messenger,
21 TaskRunner* task_runner)
22 : SettingsPlugin(messenger, task_runner) {}
24 virtual ~MockSettingsPlugin() =
default;
26 bool is_high_contrast() {
return is_high_contrast_; }
29 MOCK_METHOD(
bool, GetAlwaysUse24HourFormat, (), (
override));
30 MOCK_METHOD(
float, GetTextScaleFactor, (), (
override));
31 MOCK_METHOD(PlatformBrightness, GetPreferredBrightness, (), (
override));
33 MOCK_METHOD(
void, WatchPreferredBrightnessChanged, (), (
override));
34 MOCK_METHOD(
void, WatchTextScaleFactorChanged, (), (
override));
42TEST(SettingsPluginTest, SendSettingsSendsMessage) {
43 bool message_is_sent =
false;
44 TestBinaryMessenger messenger(
45 [&message_is_sent](
const std::string& channel,
const uint8_t*
message,
48 ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger,
nullptr);
50 settings_plugin.SendSettings();
55TEST(SettingsPluginTest, SendSettingsGetsSettings) {
56 TestBinaryMessenger messenger([](
const std::string& channel,
57 const uint8_t*
message,
size_t message_size,
59 ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger,
nullptr);
61 EXPECT_CALL(settings_plugin, GetAlwaysUse24HourFormat).Times(1);
62 EXPECT_CALL(settings_plugin, GetTextScaleFactor).Times(1);
63 EXPECT_CALL(settings_plugin, GetPreferredBrightness).Times(1);
65 settings_plugin.SendSettings();
68TEST(SettingsPluginTest, StartWatchingStartsWatchingChanges) {
69 TestBinaryMessenger messenger([](
const std::string& channel,
70 const uint8_t*
message,
size_t message_size,
72 ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger,
nullptr);
74 EXPECT_CALL(settings_plugin, WatchPreferredBrightnessChanged).Times(1);
75 EXPECT_CALL(settings_plugin, WatchTextScaleFactorChanged).Times(1);
77 settings_plugin.StartWatching();
80TEST(SettingsPluginTest, HighContrastModeHonored) {
82 TestBinaryMessenger messenger(
83 [&
times](
const std::string& channel,
const uint8_t*
message,
85 ASSERT_EQ(channel,
"flutter/settings");
88 ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger,
nullptr);
90 settings_plugin.UpdateHighContrastMode(
true);
93 settings_plugin.UpdateHighContrastMode(
false);
94 EXPECT_FALSE(settings_plugin.is_high_contrast());
static SkISize times(const SkISize &size, float factor)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
TEST(DisplayListComplexity, EmptyDisplayList)
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply
#define EXPECT_TRUE(handle)