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())
58 .WillRepeatedly(Return((
int)0));
60 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"nihao"), 0)).Times(1);
61 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"`}"), 0)).Times(0);
62 EXPECT_CALL(
window, OnComposeCommit()).Times(0);
63 ON_CALL(
window, OnImeComposition)
65 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
68 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
"nihao"))));
80 EXPECT_CALL(*text_input_manager, GetResultString())
82 Return(std::optional<std::u16string>(std::u16string(u
"`}"))));
83 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
84 .WillRepeatedly(Return((
int)0));
86 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"nihao"), 0)).Times(0);
87 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"`}"), 0)).Times(1);
88 EXPECT_CALL(
window, OnComposeCommit()).Times(1);
89 ON_CALL(
window, OnImeComposition)
91 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
94 window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
98 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
100 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
102 std::move(text_input_manager_ptr));
108 EXPECT_CALL(*text_input_manager, GetResultString())
110 Return(std::optional<std::u16string>(std::u16string(u
"今日"))));
111 EXPECT_CALL(*text_input_manager, GetComposingString())
113 Return(std::optional<std::u16string>(std::u16string(u
"は"))));
117 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"今日"), 0)).Times(1);
118 EXPECT_CALL(
window, OnComposeCommit()).Times(1);
119 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
"は"), 0)).Times(1);
122 EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
123 .WillRepeatedly(Return((
int)0));
125 ON_CALL(
window, OnImeComposition)
127 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
131 window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
132 GCS_COMPSTR | GCS_RESULTSTR);
136 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
138 std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
140 std::move(text_input_manager_ptr));
141 EXPECT_CALL(
window, OnComposeChange(std::u16string(u
""), 0)).Times(1);
142 EXPECT_CALL(
window, OnComposeCommit()).Times(1);
143 ON_CALL(
window, OnImeComposition)
145 EXPECT_CALL(
window, OnImeComposition(_, _, _)).Times(1);
149 window.InjectWindowMessage(WM_IME_COMPOSITION, 0, 0);
165 const double mouse_x = 10.0;
166 const double mouse_y = 20.0;
168 EXPECT_CALL(
window, OnPointerMove(mouse_x, mouse_y,
171 EXPECT_CALL(
window, OnPointerLeave(mouse_x, mouse_y,
176 window.InjectWindowMessage(WM_MOUSELEAVE, 0, 0);
205 EXPECT_CALL(
window, OnKey(_, _, _, _, _, _, _)).Times(1);
208 EXPECT_CALL(
window, Win32DefWindowProc(_, _, _, _)).Times(0);
211 window.InjectWindowMessage(WM_SYSKEYUP, 16, lparam);
237 std::array<BYTE, 256> keyboard_state;
238 keyboard_state[VK_CONTROL] = -1;
239 SetKeyboardState(keyboard_state.data());
245 EXPECT_CALL(
window, OnKey(65, 30, WM_KEYDOWN, 0,
false,
false, _)).Times(1);
246 EXPECT_CALL(
window, OnText(_)).Times(0);
248 window.InjectWindowMessage(WM_KEYDOWN, 65, lparam);
250 keyboard_state.fill(0);
251 SetKeyboardState(keyboard_state.data());
259 std::function<void(
bool)>
callback) {
264 std::array<BYTE, 256> keyboard_state;
265 keyboard_state[VK_CONTROL] = 1;
266 SetKeyboardState(keyboard_state.data());
270 EXPECT_CALL(
window, OnKey(65, 30, WM_KEYDOWN, 0,
false,
false, _))
272 .WillOnce(respond_false);
273 EXPECT_CALL(
window, OnText(_)).Times(1);
278 window.InjectMessageList(2, messages);
280 keyboard_state.fill(0);
281 SetKeyboardState(keyboard_state.data());
292 UINT32 pointer_id = 123;
293 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
294 auto text_input_manager = std::make_unique<MockTextInputManager>();
296 EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
298 .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE*
type) {
304 std::move(text_input_manager));
306 auto direct_manipulation =
307 std::make_unique<MockDirectManipulationOwner>(&
window);
309 EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
311 window.SetDirectManipulationOwner(std::move(direct_manipulation));
312 window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
317 UINT32 pointer_id = 123;
318 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
319 auto text_input_manager = std::make_unique<MockTextInputManager>();
321 EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
323 .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE*
type) {
329 std::move(text_input_manager));
331 auto direct_manipulation =
332 std::make_unique<MockDirectManipulationOwner>(&
window);
334 EXPECT_CALL(*direct_manipulation, SetContact(Eq(pointer_id))).Times(1);
336 window.SetDirectManipulationOwner(std::move(direct_manipulation));
337 window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
345 UINT32 pointer_id = 123;
346 auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
347 auto text_input_manager = std::make_unique<MockTextInputManager>();
349 EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
352 [](UINT32 pointer_id, POINTER_INPUT_TYPE*
type) {
return FALSE; });
355 std::move(text_input_manager));
357 auto direct_manipulation =
358 std::make_unique<MockDirectManipulationOwner>(&
window);
360 EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
362 window.SetDirectManipulationOwner(std::move(direct_manipulation));
363 window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);