66#include " flutter/shell/platform/windows/flutter_window.h"
77#include " flutter/shell/platform/windows/testing/mock_window_binding_handler.h"
88#include " flutter/shell/platform/windows/testing/mock_window_binding_handler_delegate.h"
9+ #include " flutter/shell/platform/windows/testing/windows_test.h"
910#include " flutter/shell/platform/windows/testing/wm_builders.h"
1011
1112#include " gmock/gmock.h"
@@ -25,7 +26,7 @@ static constexpr int32_t kDefaultPointerDeviceId = 0;
2526class MockFlutterWindow : public FlutterWindow {
2627 public:
2728 MockFlutterWindow (bool reset_view_on_exit = true )
28- : FlutterWindow(800 , 600 ), reset_view_on_exit_(reset_view_on_exit) {
29+ : FlutterWindow(), reset_view_on_exit_(reset_view_on_exit) {
2930 ON_CALL (*this , GetDpiScale ())
3031 .WillByDefault (Return (this ->FlutterWindow ::GetDpiScale ()));
3132 }
@@ -107,14 +108,16 @@ class MockFlutterWindowsView : public FlutterWindowsView {
107108 FML_DISALLOW_COPY_AND_ASSIGN (MockFlutterWindowsView);
108109};
109110
111+ class FlutterWindowTest : public WindowsTest {};
112+
110113} // namespace
111114
112- TEST (FlutterWindowTest, CreateDestroy) {
115+ TEST_F (FlutterWindowTest, CreateDestroy) {
113116 FlutterWindow window (800 , 600 );
114117 ASSERT_TRUE (TRUE );
115118}
116119
117- TEST (FlutterWindowTest, OnBitmapSurfaceUpdated) {
120+ TEST_F (FlutterWindowTest, OnBitmapSurfaceUpdated) {
118121 FlutterWindow win32window (100 , 100 );
119122 int old_handle_count = GetGuiResources (GetCurrentProcess (), GR_GDIOBJECTS);
120123
@@ -131,7 +134,7 @@ TEST(FlutterWindowTest, OnBitmapSurfaceUpdated) {
131134// Tests that composing rect updates are transformed from Flutter logical
132135// coordinates to device coordinates and passed to the text input manager
133136// when the DPI scale is 100% (96 DPI).
134- TEST (FlutterWindowTest, OnCursorRectUpdatedRegularDPI) {
137+ TEST_F (FlutterWindowTest, OnCursorRectUpdatedRegularDPI) {
135138 MockFlutterWindow win32window;
136139 EXPECT_CALL (win32window, GetDpiScale ()).WillOnce (Return (1.0 ));
137140
@@ -144,7 +147,7 @@ TEST(FlutterWindowTest, OnCursorRectUpdatedRegularDPI) {
144147// Tests that composing rect updates are transformed from Flutter logical
145148// coordinates to device coordinates and passed to the text input manager
146149// when the DPI scale is 150% (144 DPI).
147- TEST (FlutterWindowTest, OnCursorRectUpdatedHighDPI) {
150+ TEST_F (FlutterWindowTest, OnCursorRectUpdatedHighDPI) {
148151 MockFlutterWindow win32window;
149152 EXPECT_CALL (win32window, GetDpiScale ()).WillOnce (Return (1.5 ));
150153
@@ -155,7 +158,7 @@ TEST(FlutterWindowTest, OnCursorRectUpdatedHighDPI) {
155158 win32window.OnCursorRectUpdated (cursor_rect);
156159}
157160
158- TEST (FlutterWindowTest, OnPointerStarSendsDeviceType) {
161+ TEST_F (FlutterWindowTest, OnPointerStarSendsDeviceType) {
159162 FlutterWindow win32window (100 , 100 );
160163 MockWindowBindingHandlerDelegate delegate;
161164 EXPECT_CALL (delegate, OnWindowStateEvent).Times (AnyNumber ());
@@ -256,15 +259,16 @@ TEST(FlutterWindowTest, OnPointerStarSendsDeviceType) {
256259
257260// Tests that calls to OnScroll in turn calls GetScrollOffsetMultiplier
258261// for mapping scroll ticks to pixels.
259- TEST (FlutterWindowTest, OnScrollCallsGetScrollOffsetMultiplier) {
262+ TEST_F (FlutterWindowTest, OnScrollCallsGetScrollOffsetMultiplier) {
260263 MockFlutterWindow win32window;
261264 MockWindowBindingHandlerDelegate delegate;
262265 EXPECT_CALL (win32window, OnWindowStateEvent).Times (AnyNumber ());
263266 win32window.SetView (&delegate);
264267
265- ON_CALL (win32window, GetScrollOffsetMultiplier ())
266- .WillByDefault (Return (120 .0f ));
267- EXPECT_CALL (win32window, GetScrollOffsetMultiplier ()).Times (1 );
268+ EXPECT_CALL (win32window, GetWindowHandle).WillOnce ([&win32window]() {
269+ return win32window.FlutterWindow ::GetWindowHandle ();
270+ });
271+ EXPECT_CALL (win32window, GetScrollOffsetMultiplier).WillOnce (Return (120 .0f ));
268272
269273 EXPECT_CALL (delegate,
270274 OnScroll (_, _, 0 , 0 , 120 .0f , kFlutterPointerDeviceKindMouse ,
@@ -275,7 +279,7 @@ TEST(FlutterWindowTest, OnScrollCallsGetScrollOffsetMultiplier) {
275279 kDefaultPointerDeviceId );
276280}
277281
278- TEST (FlutterWindowTest, OnWindowRepaint) {
282+ TEST_F (FlutterWindowTest, OnWindowRepaint) {
279283 MockFlutterWindow win32window;
280284 MockWindowBindingHandlerDelegate delegate;
281285 EXPECT_CALL (win32window, OnWindowStateEvent).Times (AnyNumber ());
@@ -286,7 +290,7 @@ TEST(FlutterWindowTest, OnWindowRepaint) {
286290 win32window.InjectWindowMessage (WM_PAINT, 0 , 0 );
287291}
288292
289- TEST (FlutterWindowTest, OnThemeChange) {
293+ TEST_F (FlutterWindowTest, OnThemeChange) {
290294 MockFlutterWindow win32window;
291295 MockWindowBindingHandlerDelegate delegate;
292296 EXPECT_CALL (win32window, OnWindowStateEvent).Times (AnyNumber ());
@@ -300,15 +304,15 @@ TEST(FlutterWindowTest, OnThemeChange) {
300304// The window should return no root accessibility node if
301305// it isn't attached to a view.
302306// Regression test for https://github.com/flutter/flutter/issues/129791
303- TEST (FlutterWindowTest, AccessibilityNodeWithoutView) {
307+ TEST_F (FlutterWindowTest, AccessibilityNodeWithoutView) {
304308 MockFlutterWindow win32window;
305309
306310 EXPECT_EQ (win32window.GetNativeViewAccessible (), nullptr );
307311}
308312
309313// Ensure that announcing the alert propagates the message to the alert node.
310314// Different screen readers use different properties for alerts.
311- TEST (FlutterWindowTest, AlertNode) {
315+ TEST_F (FlutterWindowTest, AlertNode) {
312316 std::unique_ptr<MockFlutterWindow> win32window =
313317 std::make_unique<MockFlutterWindow>();
314318 EXPECT_CALL (*win32window.get (), GetAxFragmentRootDelegate ())
@@ -338,7 +342,7 @@ TEST(FlutterWindowTest, AlertNode) {
338342 EXPECT_EQ (role.lVal , ROLE_SYSTEM_ALERT);
339343}
340344
341- TEST (FlutterWindowTest, LifecycleFocusMessages) {
345+ TEST_F (FlutterWindowTest, LifecycleFocusMessages) {
342346 MockFlutterWindow win32window;
343347 EXPECT_CALL (win32window, GetWindowHandle)
344348 .WillRepeatedly (Return (reinterpret_cast <HWND>(1 )));
@@ -370,7 +374,7 @@ TEST(FlutterWindowTest, LifecycleFocusMessages) {
370374 EXPECT_EQ (last_event, WindowStateEvent::kUnfocus );
371375}
372376
373- TEST (FlutterWindowTest, CachedLifecycleMessage) {
377+ TEST_F (FlutterWindowTest, CachedLifecycleMessage) {
374378 MockFlutterWindow win32window;
375379 EXPECT_CALL (win32window, GetWindowHandle)
376380 .WillRepeatedly (Return (reinterpret_cast <HWND>(1 )));
@@ -403,7 +407,7 @@ TEST(FlutterWindowTest, CachedLifecycleMessage) {
403407 EXPECT_TRUE (restored);
404408}
405409
406- TEST (FlutterWindowTest, UpdateCursor) {
410+ TEST_F (FlutterWindowTest, UpdateCursor) {
407411 FlutterWindow win32window (100 , 100 );
408412 win32window.UpdateFlutterCursor (" text" );
409413 HCURSOR cursor = ::GetCursor ();
0 commit comments