5#include "flutter/fml/logging.h"
6#include "flutter/shell/platform/common/json_message_codec.h"
7#include "flutter/shell/platform/embedder/embedder.h"
8#include "flutter/shell/platform/embedder/test_utils/key_codes.g.h"
9#include "flutter/shell/platform/windows/flutter_windows_engine.h"
10#include "flutter/shell/platform/windows/flutter_windows_view.h"
11#include "flutter/shell/platform/windows/keyboard_key_channel_handler.h"
12#include "flutter/shell/platform/windows/keyboard_key_embedder_handler.h"
13#include "flutter/shell/platform/windows/keyboard_key_handler.h"
14#include "flutter/shell/platform/windows/keyboard_manager.h"
15#include "flutter/shell/platform/windows/testing/engine_modifier.h"
16#include "flutter/shell/platform/windows/testing/flutter_windows_engine_builder.h"
17#include "flutter/shell/platform/windows/testing/mock_window_binding_handler.h"
18#include "flutter/shell/platform/windows/testing/test_keyboard.h"
19#include "flutter/shell/platform/windows/testing/windows_test.h"
21#include "gmock/gmock.h"
22#include "gtest/gtest.h"
23#include "rapidjson/stringbuffer.h"
24#include "rapidjson/writer.h"
40constexpr SHORT kStateMaskToggled = 0x01;
41constexpr SHORT kStateMaskPressed = 0x80;
43constexpr uint64_t kScanCodeBackquote = 0x29;
45constexpr uint64_t kScanCodeKeyB = 0x30;
46constexpr uint64_t kScanCodeKeyE = 0x12;
47constexpr uint64_t kScanCodeKeyF = 0x21;
48constexpr uint64_t kScanCodeKeyO = 0x18;
49constexpr uint64_t kScanCodeKeyQ = 0x10;
50constexpr uint64_t kScanCodeKeyW = 0x11;
51constexpr uint64_t kScanCodeDigit1 = 0x02;
52constexpr uint64_t kScanCodeDigit2 = 0x03;
53constexpr uint64_t kScanCodeDigit6 = 0x07;
56constexpr uint64_t kScanCodeControl = 0x1d;
57constexpr uint64_t kScanCodeMetaLeft = 0x5b;
58constexpr uint64_t kScanCodeMetaRight = 0x5c;
59constexpr uint64_t kScanCodeAlt = 0x38;
62constexpr uint64_t kScanCodeBracketLeft = 0x1a;
63constexpr uint64_t kScanCodeArrowLeft = 0x4b;
64constexpr uint64_t kScanCodeEnter = 0x1c;
65constexpr uint64_t kScanCodeBackspace = 0x0e;
67constexpr uint64_t kVirtualDigit1 = 0x31;
69constexpr uint64_t kVirtualKeyB = 0x42;
70constexpr uint64_t kVirtualKeyE = 0x45;
71constexpr uint64_t kVirtualKeyF = 0x46;
72constexpr uint64_t kVirtualKeyO = 0x4f;
73constexpr uint64_t kVirtualKeyQ = 0x51;
74constexpr uint64_t kVirtualKeyW = 0x57;
76constexpr bool kSynthesized =
true;
77constexpr bool kNotSynthesized =
false;
79typedef UINT (*MapVirtualKeyLayout)(
UINT uCode,
UINT uMapType);
83 return MapVirtualKey(uCode, uMapType);
88 case MAPVK_VK_TO_CHAR:
93 return MapVirtualKey(uCode, MAPVK_VK_TO_CHAR);
96 return MapVirtualKey(uCode, uMapType);
100class TestKeyboardManager :
public KeyboardManager {
103 : KeyboardManager(delegate) {}
105 bool DuringRedispatch() {
return during_redispatch_; }
108 void RedispatchEvent(std::unique_ptr<PendingEvent>
event)
override {
110 <<
"RedispatchEvent called while already redispatching an event";
111 during_redispatch_ =
true;
113 during_redispatch_ =
false;
117 bool during_redispatch_ =
false;
124struct KeyStateChange {
136struct ExpectForgedMessage {
142struct KeyboardChange {
145 KeyboardChange(Win32Message
message) :
type(kMessage) {
149 KeyboardChange(KeyStateChange change) :
type(kKeyStateChange) {
150 content.key_state_change = change;
153 KeyboardChange(ExpectForgedMessage forged_message)
154 :
type(kExpectForgedMessage) {
155 content.expected_forged_message = forged_message.message;
161 kExpectForgedMessage,
174 state_[virtual_key] = (
pressed ? kStateMaskPressed : 0) |
178 SHORT Get(uint32_t virtual_key) {
return state_[virtual_key]; }
181 std::map<uint32_t, SHORT> state_;
184class MockKeyboardManagerDelegate :
public KeyboardManager::WindowDelegate,
185 protected MockMessageQueue {
187 MockKeyboardManagerDelegate(WindowBindingHandlerDelegate* view,
188 MapVirtualKeyToChar map_vk_to_char)
189 : view_(view), map_vk_to_char_(
std::move(map_vk_to_char)) {
190 keyboard_manager_ = std::make_unique<TestKeyboardManager>(
this);
192 virtual ~MockKeyboardManagerDelegate() {}
201 KeyEventCallback
callback)
override {
207 void OnText(
const std::u16string&
text)
override { view_->OnText(
text); }
209 SHORT GetKeyState(
int virtual_key) {
return key_state_.Get(virtual_key); }
211 void InjectKeyboardChanges(std::vector<KeyboardChange> changes) {
213 for (
const KeyboardChange& change : changes) {
214 switch (change.type) {
215 case KeyboardChange::kMessage:
216 PushBack(&change.content.message);
222 for (
const KeyboardChange& change : changes) {
223 switch (change.type) {
224 case KeyboardChange::kMessage:
227 case KeyboardChange::kExpectForgedMessage:
228 forged_message_expectations_.push_back(ForgedMessageExpectation{
229 .message = change.content.expected_forged_message,
232 case KeyboardChange::kKeyStateChange: {
233 const KeyStateChange& state_change = change.content.key_state_change;
234 if (forged_message_expectations_.empty()) {
235 key_state_.Set(state_change.key, state_change.pressed,
236 state_change.toggled_on);
238 forged_message_expectations_.back()
239 .state_changes_afterwards.push_back(state_change);
244 FML_LOG(
FATAL) <<
"Unhandled KeyboardChange type " << change.type;
249 std::list<Win32Message>& RedispatchedMessages() {
250 return redispatched_messages_;
257 UINT wRemoveMsg)
override {
259 wMsgFilterMax, wRemoveMsg);
262 uint32_t Win32MapVkToChar(uint32_t virtual_key)
override {
263 return map_vk_to_char_(virtual_key);
270 LPARAM const lparam)
override {
271 return keyboard_manager_->HandleMessage(
message, wparam, lparam)
279 bool handled = keyboard_manager_->HandleMessage(Msg, wParam, lParam);
280 if (keyboard_manager_->DuringRedispatch()) {
281 redispatched_messages_.push_back(Win32Message{
286 EXPECT_FALSE(handled);
288 EXPECT_FALSE(forged_message_expectations_.empty());
290 forged_message_expectations_.front();
291 forged_message_expectations_.pop_front();
299 for (
const KeyStateChange& change :
301 key_state_.Set(change.key, change.pressed, change.toggled_on);
308 struct ForgedMessageExpectation {
313 WindowBindingHandlerDelegate* view_;
314 std::unique_ptr<TestKeyboardManager> keyboard_manager_;
315 std::list<ForgedMessageExpectation> forged_message_expectations_;
316 MapVirtualKeyToChar map_vk_to_char_;
317 TestKeystate key_state_;
318 std::list<Win32Message> redispatched_messages_;
327 kKeyCallTextMethodCall,
337class TestFlutterWindowsView :
public FlutterWindowsView {
339 TestFlutterWindowsView(FlutterWindowsEngine*
engine,
340 std::unique_ptr<WindowBindingHandler>
window,
342 : on_key_call_(on_key_call),
345 void OnText(
const std::u16string&
text)
override {
346 on_key_call_(KeyCall{
347 .type = KeyCall::kKeyCallOnText,
360 using ResponseHandler =
364 : callback_handler_(RespondValue(
false)),
365 map_virtual_key_layout_(LayoutDefault) {
366 engine_ = GetTestEngine(context);
367 view_ = std::make_unique<TestFlutterWindowsView>(
371 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>(),
372 [
this](KeyCall key_call) { key_calls.push_back(key_call); });
374 EngineModifier modifier{engine_.get()};
375 modifier.SetImplicitView(view_.get());
376 modifier.InitializeKeyboard();
378 window_ = std::make_unique<MockKeyboardManagerDelegate>(
379 view_.get(), [
this](
UINT virtual_key) ->
SHORT {
380 return map_virtual_key_layout_(virtual_key, MAPVK_VK_TO_CHAR);
384 TestFlutterWindowsView& GetView() {
return *view_; }
385 MockKeyboardManagerDelegate& GetWindow() {
return *window_; }
388 void ResetKeyboard() { EngineModifier{engine_.get()}.Restart(); }
391 void Responding(
bool response) { callback_handler_ = RespondValue(response); }
401 callback_handler_ = std::move(handler);
404 void SetLayout(MapVirtualKeyLayout layout) {
405 map_virtual_key_layout_ = layout ==
nullptr ? LayoutDefault : layout;
408 void InjectKeyboardChanges(std::vector<KeyboardChange> changes) {
410 window_->InjectKeyboardChanges(std::move(changes));
414 void InjectPlatformMessage(
const char* channel,
417 rapidjson::Document args_doc;
418 args_doc.Parse(
args);
421 rapidjson::Document message_doc(rapidjson::kObjectType);
422 auto& allocator = message_doc.GetAllocator();
423 message_doc.AddMember(
"method", rapidjson::Value(method, allocator),
425 message_doc.AddMember(
"args", args_doc, allocator);
427 rapidjson::StringBuffer
buffer;
428 rapidjson::Writer<rapidjson::StringBuffer> writer(
buffer);
429 message_doc.Accept(writer);
431 std::unique_ptr<std::vector<uint8_t>>
data =
441 view_->GetEngine()->HandlePlatformMessage(&
message);
446 size_t RedispatchedMessageCountAndClear() {
447 auto& messages = window_->RedispatchedMessages();
448 size_t count = messages.size();
453 void clear_key_calls() {
455 if (key_call.type == KeyCall::kKeyCallOnKey &&
456 key_call.key_event.character !=
nullptr) {
457 delete[] key_call.key_event.character;
466 std::unique_ptr<FlutterWindowsEngine> engine_;
467 std::unique_ptr<TestFlutterWindowsView> view_;
468 std::unique_ptr<MockKeyboardManagerDelegate> window_;
470 MapVirtualKeyLayout map_virtual_key_layout_;
475 std::unique_ptr<FlutterWindowsEngine> GetTestEngine(
476 WindowsTestContext& context) {
477 FlutterWindowsEngineBuilder
builder{context};
479 builder.SetCreateKeyboardHandlerCallbacks(
480 [
this](
int virtual_key) ->
SHORT {
483 return window_ ? window_->GetKeyState(virtual_key) : 0;
486 return map_virtual_key_layout_(
487 virtual_key,
extended ? MAPVK_VK_TO_VSC_EX : MAPVK_VK_TO_VSC);
492 EngineModifier modifier(
engine.get());
494 auto key_response_controller =
495 std::make_shared<MockKeyResponseController>();
496 key_response_controller->SetEmbedderResponse(
501 clone_event.
character =
event->character ==
nullptr
505 .type = KeyCall::kKeyCallOnKey,
506 .key_event = clone_event,
510 key_response_controller->SetTextInputResponse(
512 key_calls](std::unique_ptr<rapidjson::Document> document) {
513 rapidjson::StringBuffer
buffer;
514 rapidjson::Writer<rapidjson::StringBuffer> writer(
buffer);
515 document->Accept(writer);
517 .type = KeyCall::kKeyCallTextMethodCall,
518 .text_method_call =
buffer.GetString(),
540class KeyboardTest :
public WindowsTest {
542 KeyboardTest() =
default;
543 virtual ~KeyboardTest() =
default;
554#define EXPECT_CALL_IS_EVENT(_key_call, _type, _physical, _logical, \
555 _character, _synthesized) \
556 EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnKey); \
557 EXPECT_EVENT_EQUALS(_key_call.key_event, _type, _physical, _logical, \
558 _character, _synthesized);
560#define EXPECT_CALL_IS_TEXT(_key_call, u16_string) \
561 EXPECT_EQ(_key_call.type, KeyCall::kKeyCallOnText); \
562 EXPECT_EQ(_key_call.text, u16_string);
564#define EXPECT_CALL_IS_TEXT_METHOD_CALL(_key_call, json_string) \
565 EXPECT_EQ(_key_call.type, KeyCall::kKeyCallTextMethodCall); \
566 EXPECT_STREQ(_key_call.text_method_call.c_str(), json_string);
575 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
581 EXPECT_EQ(
tester.key_calls.size(), 1);
585 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
588 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
592 EXPECT_EQ(
tester.key_calls.size(), 1);
596 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
599TEST_F(KeyboardTest, LowerCaseAUnhandled) {
606 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
612 EXPECT_EQ(
tester.key_calls.size(), 2);
617 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
620 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
624 EXPECT_EQ(
tester.key_calls.size(), 1);
628 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
638 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
642 EXPECT_EQ(
tester.key_calls.size(), 1);
647 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
650 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
654 EXPECT_EQ(
tester.key_calls.size(), 1);
659 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
662TEST_F(KeyboardTest, ArrowLeftUnhandled) {
669 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
673 EXPECT_EQ(
tester.key_calls.size(), 1);
678 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
681 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
685 EXPECT_EQ(
tester.key_calls.size(), 1);
690 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
693TEST_F(KeyboardTest, ShiftLeftUnhandled) {
700 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
701 KeyStateChange{VK_LSHIFT,
true,
false},
705 EXPECT_EQ(
tester.key_calls.size(), 1);
710 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
713 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
717 EXPECT_EQ(
tester.key_calls.size(), 1);
722 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
725 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
726 KeyStateChange{VK_LSHIFT,
false,
true},
730 EXPECT_EQ(
tester.key_calls.size(), 1);
735 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
738TEST_F(KeyboardTest, ShiftRightUnhandled) {
745 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
746 KeyStateChange{VK_RSHIFT,
true,
false},
750 EXPECT_EQ(
tester.key_calls.size(), 1);
755 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
758 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
759 KeyStateChange{VK_RSHIFT,
false,
true},
763 EXPECT_EQ(
tester.key_calls.size(), 1);
768 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
778 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
779 KeyStateChange{VK_LCONTROL,
true,
false},
783 EXPECT_EQ(
tester.key_calls.size(), 1);
788 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
791 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
792 KeyStateChange{VK_LCONTROL,
false,
true},
796 EXPECT_EQ(
tester.key_calls.size(), 1);
801 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
804TEST_F(KeyboardTest, CtrlRightUnhandled) {
811 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
812 KeyStateChange{VK_RCONTROL,
true,
false},
816 EXPECT_EQ(
tester.key_calls.size(), 1);
821 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
824 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
825 KeyStateChange{VK_RCONTROL,
false,
true},
829 EXPECT_EQ(
tester.key_calls.size(), 1);
834 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
844 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
845 KeyStateChange{VK_LMENU,
true,
false},
849 EXPECT_EQ(
tester.key_calls.size(), 1);
854 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
857 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
858 KeyStateChange{VK_LMENU,
false,
true},
862 EXPECT_EQ(
tester.key_calls.size(), 1);
867 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
877 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
878 KeyStateChange{VK_RMENU,
true,
false},
882 EXPECT_EQ(
tester.key_calls.size(), 1);
888 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
891 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
892 KeyStateChange{VK_RMENU,
false,
true},
896 EXPECT_EQ(
tester.key_calls.size(), 1);
902 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
912 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
913 KeyStateChange{VK_LWIN,
true,
false},
917 EXPECT_EQ(
tester.key_calls.size(), 1);
922 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
925 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
926 KeyStateChange{VK_LWIN,
false,
true},
929 EXPECT_EQ(
tester.key_calls.size(), 1);
934 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
937TEST_F(KeyboardTest, MetaRightUnhandled) {
944 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
945 KeyStateChange{VK_RWIN,
true,
false},
949 EXPECT_EQ(
tester.key_calls.size(), 1);
954 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
957 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
958 KeyStateChange{VK_RWIN,
false,
true},
962 EXPECT_EQ(
tester.key_calls.size(), 1);
967 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
976 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
983 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
989 EXPECT_EQ(
tester.key_calls.size(), 2);
994 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
1000TEST_F(KeyboardTest, RestartClearsKeyboardState) {
1005 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1016 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1022 EXPECT_EQ(
tester.key_calls.size(), 2);
1027 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
1034 tester.Responding(
false);
1039 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1040 KeyStateChange{VK_LSHIFT,
true,
true},
1044 EXPECT_EQ(
tester.key_calls.size(), 1);
1048 tester.clear_key_calls();
1049 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1052 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1058 EXPECT_EQ(
tester.key_calls.size(), 2);
1062 tester.clear_key_calls();
1063 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1066 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1067 KeyStateChange{VK_LSHIFT,
false,
true},
1071 EXPECT_EQ(
tester.key_calls.size(), 1);
1075 tester.clear_key_calls();
1076 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1079 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1083 EXPECT_EQ(
tester.key_calls.size(), 1);
1086 tester.clear_key_calls();
1087 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1094 tester.Responding(
false);
1099 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1100 KeyStateChange{VK_LCONTROL,
true,
true},
1104 EXPECT_EQ(
tester.key_calls.size(), 1);
1108 tester.clear_key_calls();
1109 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1112 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1118 EXPECT_EQ(
tester.key_calls.size(), 1);
1121 tester.clear_key_calls();
1122 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1125 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1129 EXPECT_EQ(
tester.key_calls.size(), 1);
1132 tester.clear_key_calls();
1133 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1136 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1137 KeyStateChange{VK_LCONTROL,
false,
true},
1141 EXPECT_EQ(
tester.key_calls.size(), 1);
1145 tester.clear_key_calls();
1146 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1152 tester.Responding(
false);
1157 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1158 KeyStateChange{VK_LCONTROL,
true,
true},
1162 EXPECT_EQ(
tester.key_calls.size(), 1);
1166 tester.clear_key_calls();
1167 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1170 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1174 EXPECT_EQ(
tester.key_calls.size(), 1);
1177 tester.clear_key_calls();
1178 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1181 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1185 EXPECT_EQ(
tester.key_calls.size(), 1);
1188 tester.clear_key_calls();
1189 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1192 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1193 KeyStateChange{VK_LCONTROL,
false,
true},
1197 EXPECT_EQ(
tester.key_calls.size(), 1);
1201 tester.clear_key_calls();
1202 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1209 tester.Responding(
false);
1211 tester.SetLayout(LayoutFrench);
1214 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1220 EXPECT_EQ(
tester.key_calls.size(), 2);
1224 tester.clear_key_calls();
1225 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1228 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1232 EXPECT_EQ(
tester.key_calls.size(), 1);
1235 tester.clear_key_calls();
1236 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1242 tester.Responding(
false);
1247 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1248 KeyStateChange{VK_LCONTROL,
true,
true},
1251 KeyStateChange{VK_RMENU,
true,
true},
1255 EXPECT_EQ(
tester.key_calls.size(), 2);
1262 tester.clear_key_calls();
1263 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1266 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1272 EXPECT_EQ(
tester.key_calls.size(), 2);
1276 tester.clear_key_calls();
1277 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1280 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1284 EXPECT_EQ(
tester.key_calls.size(), 1);
1287 tester.clear_key_calls();
1288 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1293 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1294 KeyStateChange{VK_LCONTROL,
false,
true},
1295 ExpectForgedMessage{
1298 KeyStateChange{VK_RMENU,
false,
true},
1302 EXPECT_EQ(
tester.key_calls.size(), 2);
1309 tester.clear_key_calls();
1311 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1329 tester.Responding(
false);
1335 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1336 KeyStateChange{VK_LCONTROL,
true,
true},
1339 KeyStateChange{VK_RMENU,
true,
true},
1343 EXPECT_EQ(
tester.key_calls.size(), 2);
1350 tester.clear_key_calls();
1351 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1356 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1357 KeyStateChange{VK_LCONTROL,
false,
true},
1358 ExpectForgedMessage{
1361 KeyStateChange{VK_RMENU,
false,
true},
1364 EXPECT_EQ(
tester.key_calls.size(), 2);
1371 tester.clear_key_calls();
1373 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1377 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1378 KeyStateChange{VK_LCONTROL,
true,
false},
1381 KeyStateChange{VK_RMENU,
true,
true},
1385 EXPECT_EQ(
tester.key_calls.size(), 2);
1392 tester.clear_key_calls();
1393 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1398 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1399 KeyStateChange{VK_LCONTROL,
false,
false},
1400 ExpectForgedMessage{
1403 KeyStateChange{VK_RMENU,
false,
false},
1406 EXPECT_EQ(
tester.key_calls.size(), 2);
1413 tester.clear_key_calls();
1415 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1418 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1421 EXPECT_EQ(
tester.key_calls.size(), 1);
1424 tester.clear_key_calls();
1425 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
1432 tester.Responding(
false);
1434 tester.SetLayout(LayoutFrench);
1437 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1443 EXPECT_EQ(
tester.key_calls.size(), 1);
1447 tester.clear_key_calls();
1448 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1451 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1455 EXPECT_EQ(
tester.key_calls.size(), 1);
1459 tester.clear_key_calls();
1460 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1463 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1469 EXPECT_EQ(
tester.key_calls.size(), 2);
1473 tester.clear_key_calls();
1474 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1477 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1481 EXPECT_EQ(
tester.key_calls.size(), 1);
1484 tester.clear_key_calls();
1485 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1493TEST_F(KeyboardTest, DeadKeyWithoutDeadMaskThatCombines) {
1495 tester.Responding(
false);
1498 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1499 KeyStateChange{VK_LSHIFT,
true,
true},
1503 EXPECT_EQ(
tester.key_calls.size(), 1);
1507 tester.clear_key_calls();
1508 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1511 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1517 EXPECT_EQ(
tester.key_calls.size(), 1);
1520 tester.clear_key_calls();
1521 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1524 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1527 EXPECT_EQ(
tester.key_calls.size(), 1);
1530 tester.clear_key_calls();
1531 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1534 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1535 KeyStateChange{VK_LSHIFT,
false,
true},
1539 EXPECT_EQ(
tester.key_calls.size(), 1);
1543 tester.clear_key_calls();
1544 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1547 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1553 EXPECT_EQ(
tester.key_calls.size(), 2);
1557 tester.clear_key_calls();
1558 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1561 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1565 EXPECT_EQ(
tester.key_calls.size(), 1);
1568 tester.clear_key_calls();
1569 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1574TEST_F(KeyboardTest, DeadKeyThatDoesNotCombine) {
1576 tester.Responding(
false);
1578 tester.SetLayout(LayoutFrench);
1581 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1587 EXPECT_EQ(
tester.key_calls.size(), 1);
1591 tester.clear_key_calls();
1592 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1595 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1599 EXPECT_EQ(
tester.key_calls.size(), 1);
1603 tester.clear_key_calls();
1604 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1607 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1615 EXPECT_EQ(
tester.key_calls.size(), 3);
1620 tester.clear_key_calls();
1626 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1629 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1633 EXPECT_EQ(
tester.key_calls.size(), 1);
1636 tester.clear_key_calls();
1637 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1643TEST_F(KeyboardTest, DeadKeyTwiceThenLetter) {
1645 tester.Responding(
false);
1650 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1656 EXPECT_EQ(
tester.key_calls.size(), 1);
1660 tester.clear_key_calls();
1661 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1664 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1668 EXPECT_EQ(
tester.key_calls.size(), 1);
1672 tester.clear_key_calls();
1673 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1677 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
1679 [&recorded_callbacks](
1682 recorded_callbacks.push_back(
callback);
1685 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1694 EXPECT_EQ(recorded_callbacks.size(), 1);
1695 EXPECT_EQ(
tester.key_calls.size(), 1);
1699 tester.clear_key_calls();
1701 recorded_callbacks.front()(
false);
1702 EXPECT_EQ(
tester.key_calls.size(), 2);
1705 tester.clear_key_calls();
1709 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
1711 tester.Responding(
false);
1714 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1718 EXPECT_EQ(
tester.key_calls.size(), 1);
1722 tester.clear_key_calls();
1723 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1729 tester.Responding(
false);
1735 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1743 const char* st =
tester.key_calls[0].key_event.character;
1745 EXPECT_EQ(
tester.key_calls.size(), 2);
1749 tester.clear_key_calls();
1750 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 3);
1753 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1757 EXPECT_EQ(
tester.key_calls.size(), 1);
1760 tester.clear_key_calls();
1761 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1766 tester.Responding(
false);
1777 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1778 KeyStateChange{VK_LSHIFT,
true,
true}, event1});
1779 EXPECT_EQ(
tester.key_calls.size(), 2);
1782 tester.clear_key_calls();
1783 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1785 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1786 KeyStateChange{VK_LSHIFT,
false,
true}, event2});
1787 EXPECT_EQ(
tester.key_calls.size(), 2);
1790 tester.clear_key_calls();
1791 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1794 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1795 KeyStateChange{VK_RSHIFT,
true,
true}, event1});
1796 EXPECT_EQ(
tester.key_calls.size(), 2);
1800 tester.clear_key_calls();
1801 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1803 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1804 KeyStateChange{VK_RSHIFT,
false,
true}, event2});
1805 EXPECT_EQ(
tester.key_calls.size(), 2);
1809 tester.clear_key_calls();
1810 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1813 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1814 KeyStateChange{VK_LCONTROL,
true,
true}, event1});
1815 EXPECT_EQ(
tester.key_calls.size(), 2);
1819 tester.clear_key_calls();
1820 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1822 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1823 KeyStateChange{VK_LCONTROL,
false,
true}, event2});
1824 EXPECT_EQ(
tester.key_calls.size(), 2);
1828 tester.clear_key_calls();
1829 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1832 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1833 KeyStateChange{VK_RCONTROL,
true,
true}, event1});
1834 EXPECT_EQ(
tester.key_calls.size(), 2);
1838 tester.clear_key_calls();
1839 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1841 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1842 KeyStateChange{VK_RCONTROL,
false,
true}, event2});
1843 EXPECT_EQ(
tester.key_calls.size(), 2);
1847 tester.clear_key_calls();
1848 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1851 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1852 KeyStateChange{VK_LMENU,
true,
true}, event1});
1853 EXPECT_EQ(
tester.key_calls.size(), 2);
1856 tester.clear_key_calls();
1857 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1859 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1860 KeyStateChange{VK_LMENU,
false,
true}, event2});
1861 EXPECT_EQ(
tester.key_calls.size(), 2);
1864 tester.clear_key_calls();
1865 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1868 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1869 KeyStateChange{VK_RMENU,
true,
true}, event1});
1870 EXPECT_EQ(
tester.key_calls.size(), 2);
1873 tester.clear_key_calls();
1874 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1876 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1877 KeyStateChange{VK_RMENU,
false,
true}, event2});
1878 EXPECT_EQ(
tester.key_calls.size(), 2);
1881 tester.clear_key_calls();
1882 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1885 tester.InjectKeyboardChanges(
1886 std::vector<KeyboardChange>{KeyStateChange{VK_LWIN,
true,
true}, event1});
1887 EXPECT_EQ(
tester.key_calls.size(), 2);
1890 tester.clear_key_calls();
1891 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1893 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1894 KeyStateChange{VK_LWIN,
false,
true}, event2});
1895 EXPECT_EQ(
tester.key_calls.size(), 2);
1898 tester.clear_key_calls();
1899 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1902 tester.InjectKeyboardChanges(
1903 std::vector<KeyboardChange>{KeyStateChange{VK_RWIN,
true,
true}, event1});
1904 EXPECT_EQ(
tester.key_calls.size(), 2);
1907 tester.clear_key_calls();
1908 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1910 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1911 KeyStateChange{VK_RWIN,
false,
true}, event2});
1912 EXPECT_EQ(
tester.key_calls.size(), 2);
1915 tester.clear_key_calls();
1916 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1920 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1921 KeyStateChange{VK_CAPITAL,
false,
true}, event1});
1922 EXPECT_EQ(
tester.key_calls.size(), 3);
1927 tester.clear_key_calls();
1928 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1930 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1931 KeyStateChange{VK_CAPITAL,
false,
false}, event2});
1932 EXPECT_EQ(
tester.key_calls.size(), 3);
1937 tester.clear_key_calls();
1938 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1941 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1942 KeyStateChange{VK_SCROLL,
true,
true}, event1});
1943 EXPECT_EQ(
tester.key_calls.size(), 2);
1947 tester.clear_key_calls();
1948 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1950 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1951 KeyStateChange{VK_SCROLL,
true,
false}, event2});
1952 EXPECT_EQ(
tester.key_calls.size(), 3);
1959 tester.clear_key_calls();
1960 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1963 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1964 KeyStateChange{VK_NUMLOCK,
true,
false}, event1});
1969 EXPECT_EQ(
tester.key_calls.size(), 2);
1972 tester.clear_key_calls();
1973 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1975 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1976 KeyStateChange{VK_NUMLOCK,
false,
true}, event2});
1977 EXPECT_EQ(
tester.key_calls.size(), 4);
1984 tester.clear_key_calls();
1985 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
1992TEST_F(KeyboardTest, ImeExtendedEventsAreIgnored) {
1994 tester.Responding(
false);
2002 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2003 KeyStateChange{VK_RCONTROL,
true,
false},
2007 EXPECT_EQ(
tester.key_calls.size(), 1);
2010 tester.clear_key_calls();
2011 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2020TEST_F(KeyboardTest, UpOnlyImeEventsAreCorrectlyHandled) {
2027 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2028 KeyStateChange{VK_LSHIFT,
true,
false},
2033 KeyStateChange{VK_LSHIFT,
false,
true},
2039 EXPECT_EQ(
tester.key_calls.size(), 4);
2050 tester.clear_key_calls();
2062 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2066 [&recorded_callbacks](
2069 recorded_callbacks.push_back(
callback);
2073 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2080 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2086 EXPECT_EQ(
tester.key_calls.size(), 1);
2089 EXPECT_EQ(recorded_callbacks.size(), 1);
2090 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2093 recorded_callbacks.front()(
false);
2095 EXPECT_EQ(
tester.key_calls.size(), 3);
2096 EXPECT_EQ(recorded_callbacks.size(), 2);
2100 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
2103 recorded_callbacks.back()(
false);
2105 EXPECT_EQ(
tester.key_calls.size(), 4);
2107 tester.clear_key_calls();
2108 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
2122TEST_F(KeyboardTest, SlowFrameworkResponseForIdenticalEvents) {
2124 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2128 [&recorded_callbacks](
2131 recorded_callbacks.push_back(
callback);
2135 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2141 EXPECT_EQ(
tester.key_calls.size(), 1);
2144 tester.clear_key_calls();
2145 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2148 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2152 EXPECT_EQ(
tester.key_calls.size(), 0);
2153 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2156 EXPECT_EQ(recorded_callbacks.size(), 1);
2157 recorded_callbacks.front()(
false);
2159 EXPECT_EQ(
tester.key_calls.size(), 2);
2163 tester.clear_key_calls();
2164 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
2167 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2175 EXPECT_EQ(recorded_callbacks.size(), 2);
2176 EXPECT_EQ(
tester.key_calls.size(), 0);
2177 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2181 recorded_callbacks.back()(
false);
2182 EXPECT_EQ(
tester.key_calls.size(), 1);
2185 tester.clear_key_calls();
2186 EXPECT_EQ(recorded_callbacks.size(), 3);
2187 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
2190 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2194 EXPECT_EQ(
tester.key_calls.size(), 0);
2195 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2200 tester.Responding(
false);
2204 tester.InjectPlatformMessage(
2205 "flutter/textinput",
"TextInput.setClient",
2206 R
"|([108, {"inputAction": "TextInputAction.none"}])|");
2209 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2215 EXPECT_EQ(
tester.key_calls.size(), 2);
2221 R
"|("method":"TextInputClient.performAction",)|"
2222 R"|("args":[108,"TextInputAction.none"])|"
2224 tester.clear_key_calls();
2225 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
2228 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2232 EXPECT_EQ(
tester.key_calls.size(), 1);
2235 tester.clear_key_calls();
2236 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
2243 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2249 EXPECT_EQ(
tester.key_calls.size(), 2);
2253 tester.clear_key_calls();
2256 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2260 EXPECT_EQ(
tester.key_calls.size(), 1);
2263 tester.clear_key_calls();
2266TEST_F(KeyboardTest, VietnameseTelexAddDiacriticWithFastResponse) {
2277 tester.Responding(
false);
2282 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2288 EXPECT_EQ(
tester.key_calls.size(), 2);
2292 tester.clear_key_calls();
2293 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
2296 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2300 EXPECT_EQ(
tester.key_calls.size(), 1);
2303 tester.clear_key_calls();
2304 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
2309 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2320 EXPECT_EQ(
tester.key_calls.size(), 3);
2328 tester.clear_key_calls();
2334 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 3);
2337 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2342 EXPECT_EQ(
tester.key_calls.size(), 1);
2345 tester.clear_key_calls();
2346 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2350 bool backspace_response) {
2360 KeyboardTester
tester{context};
2361 tester.Responding(
false);
2366 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2372 EXPECT_EQ(
tester.key_calls.size(), 2);
2376 tester.clear_key_calls();
2377 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 2);
2380 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2384 EXPECT_EQ(
tester.key_calls.size(), 1);
2387 tester.clear_key_calls();
2388 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
2390 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2392 [&recorded_callbacks](
2395 recorded_callbacks.push_back(
callback);
2401 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2417 EXPECT_EQ(
tester.key_calls.size(), 1);
2421 tester.clear_key_calls();
2422 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2424 EXPECT_EQ(recorded_callbacks.size(), 1);
2425 recorded_callbacks[0](backspace_response);
2427 EXPECT_EQ(
tester.key_calls.size(), 1);
2431 tester.clear_key_calls();
2432 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(),
2433 backspace_response ? 0 : 2);
2435 recorded_callbacks[1](
false);
2436 EXPECT_EQ(
tester.key_calls.size(), 1);
2438 tester.clear_key_calls();
2439 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 1);
2441 tester.Responding(
false);
2444 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2449 EXPECT_EQ(
tester.key_calls.size(), 1);
2452 tester.clear_key_calls();
2453 EXPECT_EQ(
tester.RedispatchedMessageCountAndClear(), 0);
2456TEST_F(KeyboardTest, VietnameseTelexAddDiacriticWithSlowFalseResponse) {
2460TEST_F(KeyboardTest, VietnameseTelexAddDiacriticWithSlowTrueResponse) {
2468 tester.Responding(
false);
2470 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2474 tester.clear_key_calls();
static const JsonMessageCodec & GetInstance()
virtual void RedispatchEvent(std::unique_ptr< PendingEvent > event)
std::unique_ptr< std::vector< uint8_t > > EncodeMessage(const T &message) const
std::function< void(const FlutterKeyEvent *, ResponseCallback)> EmbedderCallbackHandler
std::function< void(bool)> ResponseCallback
BOOL Win32PeekMessage(LPMSG lpMsg, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
@ kFlutterKeyEventTypeDown
@ kFlutterKeyEventTypeRepeat
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_LOG(severity)
#define FML_DCHECK(condition)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Dart_NativeFunction function
CallbackHandler callback_handler
std::string text_method_call
FlutterKeyEvent key_event
#define EXPECT_CALL_IS_TEXT(_key_call, u16_string)
#define EXPECT_CALL_IS_TEXT_METHOD_CALL(_key_call, json_string)
enum flutter::testing::@2836::KeyboardChange::Type type
union flutter::testing::@2836::KeyboardChange::@76 content
std::list< KeyStateChange > state_changes_afterwards
std::vector< KeyCall > key_calls
KeyStateChange key_state_change
Win32Message expected_forged_message
#define EXPECT_CALL_IS_EVENT(_key_call, _type, _physical, _logical, _character, _synthesized)
const GrXPFactory * Get(SkBlendMode mode)
SK_API GrDirectContext * GetContext(const SkImage *src)
ObjectPtr Invoke(const Library &lib, const char *name)
constexpr uint64_t kPhysicalEnter
constexpr uint64_t kPhysicalAltRight
constexpr uint64_t kPhysicalKeyW
constexpr uint64_t kPhysicalBackquote
constexpr uint64_t kLogicalDigit6
constexpr uint64_t kLogicalKeyE
constexpr uint64_t kLogicalShiftRight
constexpr uint64_t kPhysicalDigit6
constexpr uint64_t kPhysicalNumLock
constexpr uint64_t kLogicalBackspace
constexpr uint64_t kPhysicalControlLeft
constexpr uint64_t kPhysicalKeyQ
constexpr uint64_t kPhysicalShiftLeft
constexpr uint64_t kLogicalDigit1
constexpr uint64_t kLogicalBracketRight
constexpr uint64_t kLogicalMetaRight
constexpr uint64_t kLogicalControlLeft
constexpr uint64_t kLogicalControlRight
constexpr uint64_t kPhysicalArrowLeft
constexpr uint64_t kPhysicalKeyA
constexpr uint64_t kLogicalEnter
constexpr uint64_t kLogicalMetaLeft
constexpr uint64_t kPhysicalKeyE
constexpr uint64_t kPhysicalMetaRight
constexpr uint64_t kPhysicalCapsLock
constexpr uint64_t kLogicalKeyQ
constexpr uint64_t kLogicalKeyW
constexpr uint64_t kLogicalKeyA
constexpr uint64_t kPhysicalBackspace
constexpr uint64_t kPhysicalDigit1
constexpr uint64_t kLogicalScrollLock
constexpr uint64_t kLogicalAltRight
constexpr uint64_t kPhysicalScrollLock
constexpr uint64_t kLogicalCapsLock
constexpr uint64_t kPhysicalMetaLeft
constexpr uint64_t kPhysicalAltLeft
constexpr uint64_t kLogicalNumLock
constexpr uint64_t kLogicalArrowLeft
constexpr uint64_t kPhysicalBracketLeft
constexpr uint64_t kLogicalAltLeft
constexpr uint64_t kPhysicalControlRight
constexpr uint64_t kLogicalBackquote
constexpr uint64_t kLogicalShiftLeft
constexpr uint64_t kPhysicalShiftRight
constexpr uint64_t kScanCodeKeyA
TEST_F(DisplayListTest, Defaults)
constexpr LRESULT kWmResultZero
constexpr LRESULT kWmResultDefault
constexpr uint64_t kVirtualKeyA
void MockEmbedderApiForKeyboard(EngineModifier &modifier, std::shared_ptr< MockKeyResponseController > response_controller)
constexpr LRESULT kWmResultDontCheck
char * clone_string(const char *string)
void VietnameseTelexAddDiacriticWithSlowResponse(WindowsTestContext &context, bool backspace_response)
constexpr int64_t kImplicitViewId
constexpr int kScanCodeShiftRight
constexpr int kScanCodeShiftLeft
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer