Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8ec8af7

Browse files
[windows] Add horizontal scroll support (#20668)
The embedding was only handling vertical scroll events from the OS; this adds horizontal as well. Fixes flutter/flutter#60835
1 parent 0773bf0 commit 8ec8af7

File tree

8 files changed

+250
-272
lines changed

8 files changed

+250
-272
lines changed

shell/platform/windows/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ executable("flutter_windows_unittests") {
123123
sources = [
124124
"string_conversion_unittests.cc",
125125
"system_utils_unittests.cc",
126+
"testing/mock_win32_window.cc",
127+
"testing/mock_win32_window.h",
126128
"testing/win32_flutter_window_test.cc",
127129
"testing/win32_flutter_window_test.h",
128-
"testing/win32_window_test.cc",
129-
"testing/win32_window_test.h",
130130
"win32_dpi_utils_unittests.cc",
131131
"win32_flutter_window_unittests.cc",
132132
"win32_window_proc_delegate_manager_unittests.cc",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "flutter/shell/platform/windows/testing/mock_win32_window.h"
2+
3+
namespace flutter {
4+
namespace testing {
5+
6+
MockWin32Window::MockWin32Window() : Win32Window(){};
7+
8+
MockWin32Window::~MockWin32Window() = default;
9+
10+
UINT MockWin32Window::GetDpi() {
11+
return GetCurrentDPI();
12+
}
13+
14+
void MockWin32Window::InjectWindowMessage(UINT const message,
15+
WPARAM const wparam,
16+
LPARAM const lparam) {
17+
HandleMessage(message, wparam, lparam);
18+
}
19+
20+
} // namespace testing
21+
} // namespace flutter
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include <windowsx.h>
6+
7+
#include "flutter/shell/platform/windows/win32_window.h"
8+
#include "gmock/gmock.h"
9+
10+
namespace flutter {
11+
namespace testing {
12+
13+
/// Mock for the Win32Window base class.
14+
class MockWin32Window : public Win32Window {
15+
public:
16+
MockWin32Window();
17+
virtual ~MockWin32Window();
18+
19+
// Prevent copying.
20+
MockWin32Window(MockWin32Window const&) = delete;
21+
MockWin32Window& operator=(MockWin32Window const&) = delete;
22+
23+
// Wrapper for GetCurrentDPI() which is a protected method.
24+
UINT GetDpi();
25+
26+
// Simulates a WindowProc message from the OS.
27+
void InjectWindowMessage(UINT const message,
28+
WPARAM const wparam,
29+
LPARAM const lparam);
30+
31+
MOCK_METHOD1(OnDpiScale, void(unsigned int));
32+
MOCK_METHOD2(OnResize, void(unsigned int, unsigned int));
33+
MOCK_METHOD2(OnPointerMove, void(double, double));
34+
MOCK_METHOD3(OnPointerDown, void(double, double, UINT));
35+
MOCK_METHOD3(OnPointerUp, void(double, double, UINT));
36+
MOCK_METHOD0(OnPointerLeave, void());
37+
MOCK_METHOD0(OnSetCursor, void());
38+
MOCK_METHOD1(OnText, void(const std::u16string&));
39+
MOCK_METHOD4(OnKey, void(int, int, int, char32_t));
40+
MOCK_METHOD2(OnScroll, void(double, double));
41+
MOCK_METHOD0(OnFontChange, void());
42+
};
43+
44+
} // namespace testing
45+
} // namespace flutter

shell/platform/windows/testing/win32_window_test.cc

Lines changed: 0 additions & 40 deletions
This file was deleted.

shell/platform/windows/testing/win32_window_test.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)