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

Commit 6614de3

Browse files
authored
[Windows] Reduce Visual Studio build errors caused by keyboard unit tests (#49814)
The `EXPECT_CALL_IS_EVENT` macro used features that are not supported by Visual Studio 2022's intellisense, which results in >130 errors when editing in Visual Studio. These issues only affect the editing experience, building still works as expected. This change reduces false errors in Visual Studio by making `EXPECT_CALL_IS_EVENT` buildable in Visual Studio. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent bfef069 commit 6614de3

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

shell/platform/windows/keyboard_unittests.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,11 @@ class KeyboardTest : public WindowsTest {
544544
// Define compound `expect` in macros. If they're defined in functions, the
545545
// stacktrace wouldn't print where the function is called in the unit tests.
546546

547-
#define EXPECT_CALL_IS_EVENT(_key_call, ...) \
548-
EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnKey); \
549-
EXPECT_EVENT_EQUALS(_key_call.key_event, __VA_ARGS__);
547+
#define EXPECT_CALL_IS_EVENT(_key_call, _type, _physical, _logical, \
548+
_character, _synthesized) \
549+
EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnKey); \
550+
EXPECT_EVENT_EQUALS(_key_call.key_event, _type, _physical, _logical, \
551+
_character, _synthesized);
550552

551553
#define EXPECT_CALL_IS_TEXT(_key_call, u16_string) \
552554
EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnText); \

shell/platform/windows/testing/test_keyboard.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,17 @@ class MockMessageQueue {
145145
// Expect the |_target| FlutterKeyEvent has the required properties.
146146
#define EXPECT_EVENT_EQUALS(_target, _type, _physical, _logical, _character, \
147147
_synthesized) \
148-
EXPECT_PRED_FORMAT2(_EventEquals, _target, \
149-
(FlutterKeyEvent{ \
150-
.type = _type, \
151-
.physical = _physical, \
152-
.logical = _logical, \
153-
.character = _character, \
154-
.synthesized = _synthesized, \
155-
}));
148+
EXPECT_PRED_FORMAT2( \
149+
_EventEquals, _target, \
150+
(FlutterKeyEvent{ \
151+
/* struct_size = */ sizeof(FlutterKeyEvent), \
152+
/* timestamp = */ 0, \
153+
/* type = */ _type, \
154+
/* physical = */ _physical, \
155+
/* logical = */ _logical, \
156+
/* character = */ _character, \
157+
/* synthesized = */ _synthesized, \
158+
/* device_type = */ kFlutterKeyEventDeviceTypeKeyboard, \
159+
}));
156160

157161
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_TEST_KEYBOARD_H_

0 commit comments

Comments
 (0)