9 #include "flutter/shell/platform/windows/testing/flutter_windows_engine_builder.h"
10 #include "flutter/shell/platform/windows/testing/windows_test.h"
11 #include "gmock/gmock.h"
12 #include "gtest/gtest.h"
13 #include "shell/platform/windows/testing/mock_windows_proc_table.h"
16 #define MOCK_WINDOWS_API
22 using ::testing::AllOf;
23 using ::testing::AtLeast;
24 using ::testing::DoAll;
25 using ::testing::Field;
26 using ::testing::NiceMock;
27 using ::testing::Return;
28 using ::testing::SetArgPointee;
29 using ::testing::StrEq;
35 auto mock_windows_proc_table =
36 std::make_shared<NiceMock<MockWindowsProcTable>>();
38 FlutterWindowsEngineBuilder builder(GetContext());
39 builder.SetWindowsProcTable(mock_windows_proc_table);
40 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
42 HMONITOR mock_monitor1 =
reinterpret_cast<HMONITOR
>(123);
43 HMONITOR mock_monitor2 =
reinterpret_cast<HMONITOR
>(456);
45 MONITORINFOEXW monitor_info1 = {};
46 monitor_info1.cbSize =
sizeof(MONITORINFOEXW);
47 monitor_info1.rcMonitor = {0, 0, 1920, 1080};
48 monitor_info1.rcWork = {0, 0, 1920, 1080};
49 monitor_info1.dwFlags = MONITORINFOF_PRIMARY;
50 wcscpy_s(monitor_info1.szDevice, L
"\\\\.\\DISPLAY1");
52 MONITORINFOEXW monitor_info2 = {};
53 monitor_info2.cbSize =
sizeof(MONITORINFOEXW);
54 monitor_info2.rcMonitor = {1920, 0, 1920 + 2560, 1440};
55 monitor_info2.rcWork = {1920, 0, 1920 + 2560, 1440};
56 monitor_info2.dwFlags = 0;
57 wcscpy_s(monitor_info2.szDevice, L
"\\\\.\\DISPLAY2");
59 EXPECT_CALL(*mock_windows_proc_table, GetMonitorInfoW(mock_monitor1, _))
60 .WillOnce(DoAll(SetArgPointee<1>(monitor_info1), Return(TRUE)));
61 EXPECT_CALL(*mock_windows_proc_table, GetMonitorInfoW(mock_monitor2, _))
62 .WillOnce(DoAll(SetArgPointee<1>(monitor_info2), Return(TRUE)));
64 EXPECT_CALL(*mock_windows_proc_table,
65 EnumDisplayMonitors(
nullptr,
nullptr, _, _))
66 .WillOnce([&](HDC hdc, LPCRECT lprcClip, MONITORENUMPROC lpfnEnum,
68 lpfnEnum(mock_monitor1,
nullptr, &monitor_info1.rcMonitor, dwData);
69 lpfnEnum(mock_monitor2,
nullptr, &monitor_info2.rcMonitor, dwData);
75 .WillRepeatedly(Return(96));
77 .WillRepeatedly(Return(144));
79 EXPECT_CALL(*mock_windows_proc_table, EnumDisplaySettings(_, _, _))
80 .WillRepeatedly(Return(TRUE));
83 auto display_manager = std::make_unique<DisplayManagerWin32>(engine.get());
91 auto mock_windows_proc_table =
92 std::make_shared<NiceMock<MockWindowsProcTable>>();
95 FlutterWindowsEngineBuilder builder(GetContext());
96 builder.SetWindowsProcTable(mock_windows_proc_table);
97 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
99 EXPECT_CALL(*mock_windows_proc_table, EnumDisplayMonitors(_, _, _, _))
100 .WillRepeatedly(Return(TRUE));
103 auto display_manager = std::make_unique<DisplayManagerWin32>(engine.get());
106 HWND dummy_hwnd =
reinterpret_cast<HWND
>(1);
111 dummy_hwnd, WM_DISPLAYCHANGE, 0, 0, &result));
114 EXPECT_FALSE(
display_manager->HandleWindowMessage(dummy_hwnd, WM_DPICHANGED,
118 EXPECT_FALSE(
display_manager->HandleWindowMessage(dummy_hwnd, WM_PAINT, 0, 0,
const DisplayManagerWin32 * display_manager
TEST_F(CompositorOpenGLTest, CreateBackingStore)
UINT GetDpiForMonitor(HMONITOR monitor)