46 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
48 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
50 std::move(text_input_manager_ptr));
51 EXPECT_CALL(*text_input_manager, GetComposingString())
53 Return(std::optional<std::u16string>(std::u16string(u
"nihao"))));
54 EXPECT_CALL(*text_input_manager, GetResultString())
56 Return(std::optional<std::u16string>(std::u16string(u
"`}"))));
57 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
59 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"nihao"), 5)).Times(1);
60 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"`}"), 0)).Times(0);
61 EXPECT_CALL(
window, OnComposeCommit()).Times(0);
62 ON_CALL(
window, OnImeComposition)
64 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
67 window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_COMPSTR);
72 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
74 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
76 std::move(text_input_manager_ptr));
77 EXPECT_CALL(*text_input_manager, GetComposingString())
79 Return(std::optional<std::u16string>(std::u16string(u
"다"))));
80 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
82 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"다"), 1)).Times(1);
83 EXPECT_CALL(
window, OnComposeCommit()).Times(0);
84 ON_CALL(
window, OnImeComposition)
86 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
88 window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_COMPSTR);
92 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
94 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
96 std::move(text_input_manager_ptr));
97 EXPECT_CALL(*text_input_manager, GetComposingString())
99 Return(std::optional<std::u16string>(std::u16string(u
"nihao"))));
100 EXPECT_CALL(*text_input_manager, GetResultString())
102 Return(std::optional<std::u16string>(std::u16string(u
"`}"))));
103 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
105 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"nihao"), 0)).Times(0);
106 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"`}"), 2)).Times(1);
107 EXPECT_CALL(
window, OnComposeCommit()).Times(1);
108 ON_CALL(
window, OnImeComposition)
110 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
113 window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
117 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
119 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
121 std::move(text_input_manager_ptr));
127 EXPECT_CALL(*text_input_manager, GetResultString())
129 Return(std::optional<std::u16string>(std::u16string(u
"今日"))));
130 EXPECT_CALL(*text_input_manager, GetComposingString())
132 Return(std::optional<std::u16string>(std::u16string(u
"は"))));
136 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"今日"), 2)).Times(1);
137 EXPECT_CALL(
window, OnComposeCommit()).Times(1);
138 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"は"), 1)).Times(1);
141 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
143 ON_CALL(
window, OnImeComposition)
145 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
149 window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
150 GCS_COMPSTR | GCS_RESULTSTR);
154 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
156 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
158 std::move(text_input_manager_ptr));
159 EXPECT_CALL(*text_input_manager, GetComposingString())
161 Return(std::optional<std::u16string>(std::u16string(u
"nihao"))));
162 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
163 .WillOnce(Return(2));
165 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"nihao"), 2)).Times(1);
166 EXPECT_CALL(
window, OnComposeCommit()).Times(0);
167 ON_CALL(
window, OnImeComposition)
169 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
171 window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
172 GCS_COMPSTR | GCS_CURSORPOS);
176 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
178 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
180 std::move(text_input_manager_ptr));
181 EXPECT_CALL(*text_input_manager, GetComposingString())
183 Return(std::optional<std::u16string>(std::u16string(u
"nihao"))));
184 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
185 .WillOnce(Return(-1));
187 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"nihao"), 5)).Times(1);
188 EXPECT_CALL(
window, OnComposeCommit()).Times(0);
189 ON_CALL(
window, OnImeComposition)
191 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
193 window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
194 GCS_COMPSTR | GCS_CURSORPOS);
198 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
200 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
202 std::move(text_input_manager_ptr));
203 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
""), 0)).Times(1);
204 EXPECT_CALL(
window, OnComposeCommit()).Times(1);
205 ON_CALL(
window, OnImeComposition)
207 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
211 window.InjectWindowMessage(WM_IME_COMPOSITION, 0, 0);
227 const double mouse_x = 10.0;
228 const double mouse_y = 20.0;
234 EXPECT_CALL(
window, OnPointerLeave(mouse_x, mouse_y,
239 window.InjectWindowMessage(WM_MOUSELEAVE, 0, 0);
268 EXPECT_CALL(
window, OnKey(_, _, _, _, _, _, _)).Times(1);
271 EXPECT_CALL(
window, Win32DefWindowProc(_, _, _, _)).Times(0);
274 window.InjectWindowMessage(WM_SYSKEYUP, 16, lparam);
300 std::array<BYTE, 256> keyboard_state;
301 keyboard_state[VK_CONTROL] = -1;
302 SetKeyboardState(keyboard_state.data());
308 EXPECT_CALL(
window, OnKey(65, 30, WM_KEYDOWN, 0,
false,
false, _)).Times(1);
309 EXPECT_CALL(
window, OnText(_)).Times(0);
311 window.InjectWindowMessage(WM_KEYDOWN, 65, lparam);
313 keyboard_state.fill(0);
314 SetKeyboardState(keyboard_state.data());
322 std::function<void(
bool)>
callback) {
327 std::array<BYTE, 256> keyboard_state;
328 keyboard_state[VK_CONTROL] = 1;
329 SetKeyboardState(keyboard_state.data());
333 EXPECT_CALL(
window, OnKey(65, 30, WM_KEYDOWN, 0,
false,
false, _))
335 .WillOnce(respond_false);
336 EXPECT_CALL(
window, OnText(_)).Times(1);
341 window.InjectMessageList(2, messages);
343 keyboard_state.fill(0);
344 SetKeyboardState(keyboard_state.data());
355 UINT32 pointer_id = 123;
356 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
357 auto text_input_manager = std::make_unique<MockTextInputManager>();
359 EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
361 .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE*
type) {
367 std::move(text_input_manager));
369 auto direct_manipulation =
370 std::make_unique<MockDirectManipulationOwner>(&
window);
372 EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
374 window.SetDirectManipulationOwner(std::move(direct_manipulation));
375 window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
380 UINT32 pointer_id = 123;
381 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
382 auto text_input_manager = std::make_unique<MockTextInputManager>();
384 EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
386 .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE*
type) {
392 std::move(text_input_manager));
394 auto direct_manipulation =
395 std::make_unique<MockDirectManipulationOwner>(&
window);
397 EXPECT_CALL(*direct_manipulation, SetContact(Eq(pointer_id))).Times(1);
399 window.SetDirectManipulationOwner(std::move(direct_manipulation));
400 window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
408 UINT32 pointer_id = 123;
409 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
410 auto text_input_manager = std::make_unique<MockTextInputManager>();
412 EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
415 [](UINT32 pointer_id, POINTER_INPUT_TYPE*
type) {
return FALSE; });
418 std::move(text_input_manager));
420 auto direct_manipulation =
421 std::make_unique<MockDirectManipulationOwner>(&
window);
423 EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
425 window.SetDirectManipulationOwner(std::move(direct_manipulation));
426 window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);