[Windows] Reduce Visual Studio build errors caused by keyboard unit tests (flutter/engine#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
This commit is contained in:
@@ -544,9 +544,11 @@ class KeyboardTest : public WindowsTest {
|
||||
// Define compound `expect` in macros. If they're defined in functions, the
|
||||
// stacktrace wouldn't print where the function is called in the unit tests.
|
||||
|
||||
#define EXPECT_CALL_IS_EVENT(_key_call, ...) \
|
||||
EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnKey); \
|
||||
EXPECT_EVENT_EQUALS(_key_call.key_event, __VA_ARGS__);
|
||||
#define EXPECT_CALL_IS_EVENT(_key_call, _type, _physical, _logical, \
|
||||
_character, _synthesized) \
|
||||
EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnKey); \
|
||||
EXPECT_EVENT_EQUALS(_key_call.key_event, _type, _physical, _logical, \
|
||||
_character, _synthesized);
|
||||
|
||||
#define EXPECT_CALL_IS_TEXT(_key_call, u16_string) \
|
||||
EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnText); \
|
||||
|
||||
@@ -145,13 +145,17 @@ class MockMessageQueue {
|
||||
// Expect the |_target| FlutterKeyEvent has the required properties.
|
||||
#define EXPECT_EVENT_EQUALS(_target, _type, _physical, _logical, _character, \
|
||||
_synthesized) \
|
||||
EXPECT_PRED_FORMAT2(_EventEquals, _target, \
|
||||
(FlutterKeyEvent{ \
|
||||
.type = _type, \
|
||||
.physical = _physical, \
|
||||
.logical = _logical, \
|
||||
.character = _character, \
|
||||
.synthesized = _synthesized, \
|
||||
}));
|
||||
EXPECT_PRED_FORMAT2( \
|
||||
_EventEquals, _target, \
|
||||
(FlutterKeyEvent{ \
|
||||
/* struct_size = */ sizeof(FlutterKeyEvent), \
|
||||
/* timestamp = */ 0, \
|
||||
/* type = */ _type, \
|
||||
/* physical = */ _physical, \
|
||||
/* logical = */ _logical, \
|
||||
/* character = */ _character, \
|
||||
/* synthesized = */ _synthesized, \
|
||||
/* device_type = */ kFlutterKeyEventDeviceTypeKeyboard, \
|
||||
}));
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_TEST_KEYBOARD_H_
|
||||
|
||||
Reference in New Issue
Block a user