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

Commit 400fcda

Browse files
committed
Some cleanup
1 parent 91b78ee commit 400fcda

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

shell/platform/windows/flutter_windows_engine_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ TEST(FlutterWindowsEngine, SendPlatformMessageWithoutResponse) {
102102
const char* channel = "test";
103103
const std::vector<uint8_t> test_message = {1, 2, 3, 4};
104104

105-
// Without a responses, SendPlatformMessage should be a simple pass-through.
105+
// Without a response, SendPlatformMessage should be a simple pass-through.
106106
bool called = false;
107107
modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
108108
SendPlatformMessage, ([&called, test_message](auto engine, auto message) {

shell/platform/windows/flutter_windows_view.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ inline constexpr uint32_t kWindowFrameBufferID = 0;
3535
// view that works with win32 hwnds and Windows::UI::Composition visuals.
3636
class FlutterWindowsView : public WindowBindingHandlerDelegate {
3737
public:
38-
// Creates a FlutterWindowsView with the given implementator of
38+
// Creates a FlutterWindowsView with the given implementor of
3939
// WindowBindingHandler.
4040
//
4141
// In order for object to render Flutter content the SetEngine method must be
4242
// called with a valid FlutterWindowsEngine instance.
4343
FlutterWindowsView(std::unique_ptr<WindowBindingHandler> window_binding);
4444

45-
~FlutterWindowsView();
45+
virtual ~FlutterWindowsView();
4646

4747
// Configures the window instance with an instance of a running Flutter
4848
// engine.

shell/platform/windows/testing/win32_flutter_window_test.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_WIN32_FLUTTER_WINDOW_TEST_H_
66
#define FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_WIN32_FLUTTER_WINDOW_TEST_H_
77

8-
#include <windowsx.h>
9-
108
#include "flutter/shell/platform/windows/win32_flutter_window.h"
11-
#include "gmock/gmock.h"
129

1310
namespace flutter {
1411
namespace testing {

shell/platform/windows/win32_window.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "flutter/shell/platform/windows/win32_window.h"
66

77
#include <cstring>
8-
#include <iostream>
98

109
#include "win32_dpi_utils.h"
1110

shell/platform/windows/win32_window_unittests.cc

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ using testing::_;
99

1010
namespace flutter {
1111
namespace testing {
12+
namespace {
13+
14+
// Creates a valid Windows LPARAM for WM_KEYDOWN and WM_KEYUP from parameters
15+
// given.
16+
static LPARAM CreateKeyEventLparam(USHORT ScanCode,
17+
bool extended = false,
18+
USHORT RepeatCount = 1,
19+
bool ContextCode = 0,
20+
bool PreviousKeyState = 1,
21+
bool TransitionState = 1) {
22+
return ((LPARAM(TransitionState) << 31) | (LPARAM(PreviousKeyState) << 30) |
23+
(LPARAM(ContextCode) << 29) | (LPARAM(extended ? 0x1 : 0x0) << 24) |
24+
(LPARAM(ScanCode) << 16) | LPARAM(RepeatCount));
25+
}
26+
27+
} // namespace
1228

1329
TEST(MockWin32Window, CreateDestroy) {
1430
MockWin32Window window;
@@ -39,36 +55,25 @@ TEST(MockWin32Window, HorizontalScroll) {
3955
window.InjectWindowMessage(WM_MOUSEHWHEEL, MAKEWPARAM(0, scroll_amount), 0);
4056
}
4157

42-
static LPARAM CreateKeyEventLparam(USHORT RepeatCount,
43-
USHORT ScanCode,
44-
bool extended,
45-
bool ContextCode,
46-
bool PreviousKeyState,
47-
bool TransitionState) {
48-
return ((LPARAM(TransitionState) << 31) | (LPARAM(PreviousKeyState) << 30) |
49-
(LPARAM(ContextCode) << 29) | (LPARAM(extended ? 0x1 : 0x0) << 24) |
50-
(LPARAM(ScanCode) << 16) | LPARAM(RepeatCount));
51-
}
52-
5358
TEST(MockWin32Window, KeyDown) {
5459
MockWin32Window window;
5560
EXPECT_CALL(window, OnKey(_, _, _, _, _)).Times(1);
56-
LPARAM lparam = CreateKeyEventLparam(1, 42, false, 0, 1, 1);
61+
LPARAM lparam = CreateKeyEventLparam(42);
5762
// send a "Shift" key down event.
5863
window.InjectWindowMessage(WM_KEYDOWN, 16, lparam);
5964
}
6065

6166
TEST(MockWin32Window, KeyUp) {
6267
MockWin32Window window;
6368
EXPECT_CALL(window, OnKey(_, _, _, _, _)).Times(1);
64-
LPARAM lparam = CreateKeyEventLparam(1, 42, false, 0, 1, 1);
69+
LPARAM lparam = CreateKeyEventLparam(42);
6570
// send a "Shift" key up event.
6671
window.InjectWindowMessage(WM_KEYUP, 16, lparam);
6772
}
6873

6974
TEST(MockWin32Window, KeyDownPrintable) {
7075
MockWin32Window window;
71-
LPARAM lparam = CreateKeyEventLparam(1, 30, false, 0, 1, 1);
76+
LPARAM lparam = CreateKeyEventLparam(30);
7277
// OnKey shouldn't be called until the WM_CHAR message.
7378
EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 65, false)).Times(0);
7479
// send a "A" key down event.

0 commit comments

Comments
 (0)