blob: 4e392a285685cfaa9a6870f342ff901e54e825b9 [file] [log] [blame]
Christopher Plewright20b795e2022-12-20 20:01:58 +00001" Test MS-Windows console event handling.
2
3source check.vim
4CheckMSWindows
5" The mswin events should also work in gui
6
7source mouse.vim
8
9" Helper function for sending a sequence of low level key presses
10" The modifer key(s) can be included as normal key presses in the sequence
11func SendKeys(keylist)
12 for k in a:keylist
13 call test_mswin_event("key", #{event: "keydown", keycode: k})
14 endfor
15 for k in reverse(copy(a:keylist))
16 call test_mswin_event("key", #{event: "keyup", keycode: k})
17 endfor
18endfunc
19
20" Send an individual key press
21" the modifers for the key press can be specified in the modifiers arg.
22func SendKey(key, modifiers)
23 let args = { }
24 let args.keycode = a:key
25 let args.modifiers = a:modifiers
26 let args.event = "keydown"
27 call test_mswin_event("key", args)
28 let args.event = "keyup"
29 call test_mswin_event("key", args)
30 unlet args
31endfunc
32
33" Test MS-Windows console key events
34func Test_mswin_key_event()
35 CheckMSWindows
36 new
37
38 " flush out any garbage left in the buffer
39 while getchar(0)
40 endwhile
41
42 let VK = #{
43 \ SPACE : 0x20,
44 \ SHIFT : 0x10,
45 \ LSHIFT : 0xA0,
46 \ RSHIFT : 0xA1,
47 \ CONTROL : 0x11,
48 \ LCONTROL : 0xA2,
49 \ RCONTROL : 0xA3,
50 \ MENU : 0x12,
51 \ ALT : 0x12,
52 \ LMENU : 0xA4,
53 \ LALT : 0xA4,
54 \ RMENU : 0xA5,
55 \ RALT : 0xA5,
56 \ OEM_1 : 0xBA,
57 \ OEM_2 : 0xBF,
58 \ OEM_3 : 0xC0,
59 \ OEM_4 : 0xDB,
60 \ OEM_5 : 0xDC,
61 \ OEM_6 : 0xDD,
62 \ OEM_7 : 0xDE,
63 \ OEM_PLUS : 0xBB,
64 \ OEM_COMMA : 0xBC,
65 \ OEM_MINUS : 0xBD,
66 \ OEM_PERIOD : 0xBE,
67 \ PRIOR : 0x21,
68 \ NEXT : 0x22,
69 \ END : 0x23,
70 \ HOME : 0x24,
71 \ LEFT : 0x25,
72 \ UP : 0x26,
73 \ RIGHT : 0x27,
74 \ DOWN : 0x28,
75 \ KEY_0 : 0x30,
76 \ KEY_1 : 0x31,
77 \ KEY_2 : 0x32,
78 \ KEY_3 : 0x33,
79 \ KEY_4 : 0x34,
80 \ KEY_5 : 0x35,
81 \ KEY_6 : 0x36,
82 \ KEY_7 : 0x37,
83 \ KEY_8 : 0x38,
84 \ KEY_9 : 0x39,
85 \ NUMPAD0 : 0x60,
86 \ NUMPAD1 : 0x61,
87 \ NUMPAD2 : 0x62,
88 \ NUMPAD3 : 0x63,
89 \ NUMPAD4 : 0x64,
90 \ NUMPAD5 : 0x65,
91 \ NUMPAD6 : 0x66,
92 \ NUMPAD7 : 0x67,
93 \ NUMPAD8 : 0x68,
94 \ NUMPAD9 : 0x69,
95 \ MULTIPLY : 0x6A,
96 \ ADD : 0x6B,
97 \ SUBTRACT : 0x6D,
98 \ F1 : 0x70,
99 \ F2 : 0x71,
100 \ F3 : 0x72,
101 \ F4 : 0x73,
102 \ F5 : 0x74,
103 \ F6 : 0x75,
104 \ F7 : 0x76,
105 \ F8 : 0x77,
106 \ F9 : 0x78,
107 \ F10 : 0x79,
108 \ F11 : 0x7A,
109 \ F12 : 0x7B,
110 \ KEY_A : 0x41,
111 \ KEY_B : 0x42,
112 \ KEY_C : 0x43,
113 \ KEY_D : 0x44,
114 \ KEY_E : 0x45,
115 \ KEY_F : 0x46,
116 \ KEY_G : 0x47,
117 \ KEY_H : 0x48,
118 \ KEY_I : 0x49,
119 \ KEY_J : 0x4A,
120 \ KEY_K : 0x4B,
121 \ KEY_L : 0x4C,
122 \ KEY_M : 0x4D,
123 \ KEY_N : 0x4E,
124 \ KEY_O : 0x4F,
125 \ KEY_P : 0x50,
126 \ KEY_Q : 0x51,
127 \ KEY_R : 0x52,
128 \ KEY_S : 0x53,
129 \ KEY_T : 0x54,
130 \ KEY_U : 0x55,
131 \ KEY_V : 0x56,
132 \ KEY_W : 0x57,
133 \ KEY_X : 0x58,
134 \ KEY_Y : 0x59,
135 \ KEY_Z : 0x5A
136 \ }
137
138 let vim_MOD_MASK_SHIFT = 0x02
139 let vim_MOD_MASK_CTRL = 0x04
140 let vim_MOD_MASK_ALT = 0x08
141
142 let vim_key_modifiers = [
143 \ ["", 0, []],
144 \ ["S-", 2, [VK.SHIFT]],
145 \ ["C-", 4, [VK.CONTROL]],
146 \ ["C-S-", 6, [VK.CONTROL, VK.SHIFT]],
147 \ ["A-", 8, [VK.MENU]],
148 \ ["A-S-", 10, [VK.MENU, VK.SHIFT]],
149 \ ["A-C-", 12, [VK.MENU, VK.CONTROL]],
150 \ ["A-C-S-", 14, [VK.MENU, VK.CONTROL, VK.SHIFT]],
151 \]
152
153 " Some punctuation characters
154 " Assuming Standard US PC Keyboard layout
155 let test_punctuation_keys = [
156 \ [[VK.SPACE], ' '],
157 \ [[VK.OEM_1], ';'],
158 \ [[VK.OEM_2], '/'],
159 \ [[VK.OEM_3], '`'],
160 \ [[VK.OEM_4], '['],
161 \ [[VK.OEM_5], '\'],
162 \ [[VK.OEM_6], ']'],
163 \ [[VK.OEM_7], ''''],
164 \ [[VK.OEM_PLUS], '='],
165 \ [[VK.OEM_COMMA], ','],
166 \ [[VK.OEM_MINUS], '-'],
167 \ [[VK.OEM_PERIOD], '.'],
168 \ [[VK.SHIFT, VK.OEM_1], ':'],
169 \ [[VK.SHIFT, VK.OEM_2], '?'],
170 \ [[VK.SHIFT, VK.OEM_3], '~'],
171 \ [[VK.SHIFT, VK.OEM_4], '{'],
172 \ [[VK.SHIFT, VK.OEM_5], '|'],
173 \ [[VK.SHIFT, VK.OEM_6], '}'],
174 \ [[VK.SHIFT, VK.OEM_7], '"'],
175 \ [[VK.SHIFT, VK.OEM_PLUS], '+'],
176 \ [[VK.SHIFT, VK.OEM_COMMA], '<'],
177 \ [[VK.SHIFT, VK.OEM_MINUS], '_'],
178 \ [[VK.SHIFT, VK.OEM_PERIOD], '>'],
179 \ [[VK.SHIFT, VK.KEY_1], '!'],
180 \ [[VK.SHIFT, VK.KEY_2], '@'],
181 \ [[VK.SHIFT, VK.KEY_3], '#'],
182 \ [[VK.SHIFT, VK.KEY_4], '$'],
183 \ [[VK.SHIFT, VK.KEY_5], '%'],
184 \ [[VK.SHIFT, VK.KEY_6], '^'],
185 \ [[VK.SHIFT, VK.KEY_7], '&'],
186 \ [[VK.SHIFT, VK.KEY_8], '*'],
187 \ [[VK.SHIFT, VK.KEY_9], '('],
188 \ [[VK.SHIFT, VK.KEY_0], ')'],
189 \ [[VK.LSHIFT, VK.KEY_9], '('],
190 \ [[VK.RSHIFT, VK.KEY_0], ')']
191 \ ]
192
193 for [kcodes, kstr] in test_punctuation_keys
194 call SendKeys(kcodes)
195 let ch = getcharstr(0)
196 call assert_equal($"{kstr}", $"{ch}")
197 let mod_mask = getcharmod()
198 " the mod_mask is zero when no modifiers are used
199 " and when the virtual termcap maps shift the character
200 call assert_equal(0, mod_mask, $"key = {kstr}")
201 endfor
202
203 " flush out any garbage left in the buffer
204 while getchar(0)
205 endwhile
206
207 for [kcodes, kstr] in test_punctuation_keys
208 let modifiers = 0
209 let key = kcodes[0]
210
211 for key in kcodes
212 if index([VK.SHIFT, VK.LSHIFT, VK.RSHIFT], key) >= 0
213 let modifiers = modifiers + vim_MOD_MASK_SHIFT
214 endif
215 if index([VK.CONTROL, VK.LCONTROL, VK.RCONTROL], key) >= 0
216 let modifiers = modifiers + vim_MOD_MASK_CTRL
217 endif
218 if index([VK.ALT, VK.LALT, VK.RALT], key) >= 0
219 let modifiers = modifiers + vim_MOD_MASK_ALT
220 endif
221 endfor
222
223 call SendKey(key, modifiers)
224 let ch = getcharstr(0)
225 call assert_equal($"{kstr}", $"{ch}")
226 let mod_mask = getcharmod()
227 " workaround for the virtual termcap maps changing the character instead
228 " of sending Shift
229 if index([VK.SHIFT, VK.LSHIFT, VK.RSHIFT], kcodes[0]) >= 0
230 let modifiers = modifiers - vim_MOD_MASK_SHIFT
231 endif
232 call assert_equal(modifiers, mod_mask, $"key = {kstr}")
233 endfor
234
235 " flush out any garbage left in the buffer
236 while getchar(0)
237 endwhile
238
239" Test keyboard codes for digits
240" (0x30 - 0x39) : VK_0 - VK_9 are the same as ASCII '0' - '9'
241 for kc in range(48, 57)
242 call SendKeys([kc])
243 let ch = getcharstr(0)
244 call assert_equal(nr2char(kc), ch)
245 call SendKey(kc, 0)
246 let ch = getcharstr(0)
247 call assert_equal(nr2char(kc), ch)
248 endfor
249
250" Test keyboard codes for Alt-0 to Alt-9
251" Expect +128 from the digit char codes
252 for modkey in [VK.ALT, VK.LALT, VK.RALT]
253 for kc in range(48, 57)
254 call SendKeys([modkey, kc])
255 let ch = getchar(0)
256 call assert_equal(kc+128, ch)
257 call SendKey(kc, vim_MOD_MASK_ALT)
258 let ch = getchar(0)
259 call assert_equal(kc+128, ch)
260 endfor
261 endfor
262
263" Test for lowercase 'a' to 'z', VK codes 65(0x41) - 90(0x5A)
264" Note: VK_A-VK_Z virtual key codes coincide with uppercase ASCII codes A-Z.
265" eg VK_A is 65, and the ASCII character code for uppercase 'A' is also 65.
266" Caution: these are interpreted as lowercase when Shift is NOT pressed.
267" eg, sending VK_A (65) 'A' Key code without shift modifier, will produce ASCII
268" char 'a' (91) as the output. The ASCII codes for the lowercase letters are
269" numbered 32 higher than their uppercase versions.
270 for kc in range(65, 90)
271 call SendKeys([kc])
272 let ch = getcharstr(0)
273 call assert_equal(nr2char(kc + 32), ch)
274 call SendKey(kc, 0)
275 let ch = getcharstr(0)
276 call assert_equal(nr2char(kc + 32), ch)
277 endfor
278
279" Test for Uppercase 'A' - 'Z' keys
280" ie. with VK_SHIFT, expect the keycode = character code.
281 for kc in range(65, 90)
282 call SendKeys([VK.SHIFT, kc])
283 let ch = getcharstr(0)
284 call assert_equal(nr2char(kc), ch)
285 call SendKey(kc, vim_MOD_MASK_SHIFT)
286 let ch = getcharstr(0)
287 call assert_equal(nr2char(kc), ch)
288 endfor
289
290 " Test for <Ctrl-A> to <Ctrl-Z> keys
291 " Same as for lowercase, except with Ctrl Key
292 " Expect the unicode characters 0x01 to 0x1A
293 for modkey in [VK.CONTROL, VK.LCONTROL, VK.RCONTROL]
294 for kc in range(65, 90)
295 call SendKeys([modkey, kc])
296 let ch = getcharstr(0)
297 call assert_equal(nr2char(kc - 64), ch)
298 call SendKey(kc, vim_MOD_MASK_CTRL)
299 let ch = getcharstr(0)
300 call assert_equal(nr2char(kc - 64), ch)
301 endfor
302 endfor
303
304 if !has("gui_running")
305 " Test for <Alt-A> to <Alt-Z> keys
306 " Expect the unicode characters 0xE1 to 0xFA
307 " ie. 160 higher than the lowercase equivalent
308 for kc in range(65, 90)
309 call SendKeys([VK.LMENU, kc])
310 let ch = getchar(0)
311 call assert_equal(kc+160, ch)
312 call SendKey(kc, vim_MOD_MASK_ALT)
313 let ch = getchar(0)
314 call assert_equal(kc+160, ch)
315 endfor
316 endif
317
318 if !has("gui_running")
319 " Test for Function Keys 'F1' to 'F12'
320 for n in range(1, 12)
321 let kstr = $"F{n}"
322 let keycode = eval('"\<' .. kstr .. '>"')
323 call SendKeys([111+n])
324 let ch = getcharstr(0)
325 call assert_equal(keycode, $"{ch}", $"key = <{kstr}>")
326 endfor
327 endif
328
329 bw!
330endfunc
331
332" Test MS-Windows console mouse events
333func Test_mswin_mouse_event()
334 CheckMSWindows
335 new
336
337 set mousemodel=extend
338 call test_override('no_query_mouse', 1)
339 call WaitForResponses()
340
341 let msg = ''
342
343 call setline(1, ['one two three', 'four five six'])
344
345 " Test mouse movement
346 " by default, no mouse move events are generated
347 " this setting enables it to generate move events
348 set mousemev
349
350 if !has('gui_running')
351 " console version needs a button pressed,
352 " otherwise it ignores mouse movements.
353 call MouseLeftClick(2, 3)
354 endif
355 call MSWinMouseEvent(0x700, 8, 13, 0, 0, 0)
356 if has('gui_running')
357 call feedkeys("\<Esc>", 'Lx!')
358 endif
359 let pos = getmousepos()
360 call assert_equal(8, pos.screenrow)
361 call assert_equal(13, pos.screencol)
362
363 if !has('gui_running')
364 call MouseLeftClick(2, 3)
365 call MSWinMouseEvent(0x700, 6, 4, 1, 0, 0)
366 let pos = getmousepos()
367 call assert_equal(6, pos.screenrow)
368 call assert_equal(4, pos.screencol)
369 endif
370
371 " test cells vs pixels
372 if has('gui_running')
373 let args = { }
374 let args.row = 9
375 let args.col = 7
376 let args.move = 1
377 let args.cell = 1
378 call test_mswin_event("mouse", args)
379 call feedkeys("\<Esc>", 'Lx!')
380 let pos = getmousepos()
381 call assert_equal(9, pos.screenrow)
382 call assert_equal(7, pos.screencol)
383
384 let args.cell = 0
385 call test_mswin_event("mouse", args)
386 call feedkeys("\<Esc>", 'Lx!')
387 let pos = getmousepos()
388 call assert_equal(1, pos.screenrow)
389 call assert_equal(1, pos.screencol)
390
391 unlet args
392 endif
393
394 " finish testing mouse movement
395 set mousemev&
396
397 " place the cursor using left click and release in normal mode
398 call MouseLeftClick(2, 4)
399 call MouseLeftRelease(2, 4)
400 if has('gui_running')
401 call feedkeys("\<Esc>", 'Lx!')
402 endif
403 call assert_equal([0, 2, 4, 0], getpos('.'))
404
405 " select and yank a word
406 let @" = ''
407 call MouseLeftClick(1, 9)
408 let args = #{button: 0, row: 1, col: 9, multiclick: 1, modifiers: 0}
409 call test_mswin_event('mouse', args)
410 call MouseLeftRelease(1, 9)
411 call feedkeys("y", 'Lx!')
412 call assert_equal('three', @")
413
414 " create visual selection using right click
415 let @" = ''
416
417 call MouseLeftClick(2 ,6)
418 call MouseLeftRelease(2, 6)
419 call MouseRightClick(2, 13)
420 call MouseRightRelease(2, 13)
421 call feedkeys("y", 'Lx!')
422 call assert_equal('five six', @")
423
424 " paste using middle mouse button
425 let @* = 'abc '
426 call feedkeys('""', 'Lx!')
427 call MouseMiddleClick(1, 9)
428 call MouseMiddleRelease(1, 9)
429 if has('gui_running')
430 call feedkeys("\<Esc>", 'Lx!')
431 endif
432 call assert_equal(['one two abc three', 'four five six'], getline(1, '$'))
433
434 " test mouse scrolling (aka touchpad scrolling.)
435 %d _
436 set scrolloff=0
437 call setline(1, range(1, 100))
438
439 " Scroll Down
440 call MouseWheelDown(2, 1)
441 call MouseWheelDown(2, 1)
442 call MouseWheelDown(2, 1)
443 call feedkeys("H", 'Lx!')
444 call assert_equal(10, line('.'))
445
446 " Scroll Up
447 call MouseWheelUp(2, 1)
448 call MouseWheelUp(2, 1)
449 call feedkeys("H", 'Lx!')
450 call assert_equal(4, line('.'))
451
452 " Shift Scroll Down
453 call MouseShiftWheelDown(2, 1)
454 call feedkeys("H", 'Lx!')
455 " should scroll from where it is (4) + visible buffer height - cmdheight
456 let shift_scroll_height = line('w$') - line('w0') - &cmdheight
457 call assert_equal(4 + shift_scroll_height, line('.'))
458
459 " Shift Scroll Up
460 call MouseShiftWheelUp(2, 1)
461 call feedkeys("H", 'Lx!')
462 call assert_equal(4, line('.'))
463
464 if !has('gui_running')
465 " Shift Scroll Down (using MOD)
466 call MSWinMouseEvent(0x100, 2, 1, 0, 0, 0x04)
467 call feedkeys("H", 'Lx!')
468 " should scroll from where it is (4) + visible buffer height - cmdheight
469 let shift_scroll_height = line('w$') - line('w0') - &cmdheight
470 call assert_equal(4 + shift_scroll_height, line('.'))
471
472 " Shift Scroll Up (using MOD)
473 call MSWinMouseEvent(0x200, 2, 1, 0, 0, 0x04)
474 call feedkeys("H", 'Lx!')
475 call assert_equal(4, line('.'))
476 endif
477
478 set scrolloff&
479
480 %d _
481 set nowrap
482 " make the buffer 500 wide.
483 call setline(1, range(10)->join('')->repeat(50))
484 " Scroll Right
485 call MouseWheelRight(1, 5)
486 call MouseWheelRight(1, 10)
487 call MouseWheelRight(1, 15)
488 call feedkeys('g0', 'Lx!')
489 call assert_equal(19, col('.'))
490
491 " Scroll Left
492 call MouseWheelLeft(1, 15)
493 call MouseWheelLeft(1, 10)
494 call feedkeys('g0', 'Lx!')
495 call assert_equal(7, col('.'))
496
497 " Shift Scroll Right
498 call MouseShiftWheelRight(1, 10)
499 call feedkeys('g0', 'Lx!')
500 " should scroll from where it is (7) + window width
501 call assert_equal(7 + winwidth(0), col('.'))
502
503 " Shift Scroll Left
504 call MouseShiftWheelLeft(1, 50)
505 call feedkeys('g0', 'Lx!')
506 call assert_equal(7, col('.'))
507 set wrap&
508
509 %d _
510 call setline(1, repeat([repeat('a', 60)], 10))
511
512 " record various mouse events
513 let mouseEventNames = [
514 \ 'LeftMouse', 'LeftRelease', '2-LeftMouse', '3-LeftMouse',
515 \ 'S-LeftMouse', 'A-LeftMouse', 'C-LeftMouse', 'MiddleMouse',
516 \ 'MiddleRelease', '2-MiddleMouse', '3-MiddleMouse',
517 \ 'S-MiddleMouse', 'A-MiddleMouse', 'C-MiddleMouse',
518 \ 'RightMouse', 'RightRelease', '2-RightMouse',
519 \ '3-RightMouse', 'S-RightMouse', 'A-RightMouse', 'C-RightMouse',
520 \ ]
521 let mouseEventCodes = map(copy(mouseEventNames), "'<' .. v:val .. '>'")
522 let g:events = []
523 for e in mouseEventCodes
524 exe 'nnoremap ' .. e .. ' <Cmd>call add(g:events, "' ..
525 \ substitute(e, '[<>]', '', 'g') .. '")<CR>'
526 endfor
527
528 " Test various mouse buttons
529 "(0 - Left, 1 - Middle, 2 - Right,
530 " 0x300 - MOUSE_X1/FROM_LEFT_3RD_BUTTON,
531 " 0x400 - MOUSE_X2/FROM_LEFT_4TH_BUTTON)
532 for button in [0, 1, 2, 0x300, 0x400]
533 " Single click
534 let args = #{button: button, row: 2, col: 5, multiclick: 0, modifiers: 0}
535 call test_mswin_event('mouse', args)
536 let args.button = 3
537 call test_mswin_event('mouse', args)
538
539 " Double Click
540 let args.button = button
541 call test_mswin_event('mouse', args)
542 let args.multiclick = 1
543 call test_mswin_event('mouse', args)
544 let args.button = 3
545 let args.multiclick = 0
546 call test_mswin_event('mouse', args)
547
548 " Triple Click
549 let args.button = button
550 call test_mswin_event('mouse', args)
551 let args.multiclick = 1
552 call test_mswin_event('mouse', args)
553 call test_mswin_event('mouse', args)
554 let args.button = 3
555 let args.multiclick = 0
556 call test_mswin_event('mouse', args)
557
558 " Shift click
559 let args = #{button: button, row: 3, col: 7, multiclick: 0, modifiers: 4}
560 call test_mswin_event('mouse', args)
561 let args.button = 3
562 call test_mswin_event('mouse', args)
563
564 " Alt click
565 let args.button = button
566 let args.modifiers = 8
567 call test_mswin_event('mouse', args)
568 let args.button = 3
569 call test_mswin_event('mouse', args)
570
571 " Ctrl click
572 let args.button = button
573 let args.modifiers = 16
574 call test_mswin_event('mouse', args)
575 let args.button = 3
576 call test_mswin_event('mouse', args)
577
578 call feedkeys("\<Esc>", 'Lx!')
579 endfor
580
581 if has('gui_running')
582 call assert_equal(['LeftMouse', 'LeftRelease', 'LeftMouse',
583 \ '2-LeftMouse', 'LeftMouse', '2-LeftMouse', '3-LeftMouse',
584 \ 'S-LeftMouse', 'A-LeftMouse', 'C-LeftMouse', 'MiddleMouse',
585 \ 'MiddleRelease', 'MiddleMouse', '2-MiddleMouse', 'MiddleMouse',
586 \ '2-MiddleMouse', '3-MiddleMouse', 'S-MiddleMouse', 'A-MiddleMouse',
587 \ 'C-MiddleMouse', 'RightMouse', 'RightRelease', 'RightMouse',
588 \ '2-RightMouse', 'RightMouse', '2-RightMouse', '3-RightMouse',
589 \ 'S-RightMouse', 'A-RightMouse', 'C-RightMouse'],
590 \ g:events)
591 else
592 call assert_equal(['MiddleRelease', 'LeftMouse', '2-LeftMouse',
593 \ '3-LeftMouse', 'S-LeftMouse', 'MiddleMouse', '2-MiddleMouse',
594 \ '3-MiddleMouse', 'MiddleMouse', 'S-MiddleMouse', 'RightMouse',
595 \ '2-RightMouse', '3-RightMouse'],
596 \ g:events)
597 endif
598
599 for e in mouseEventCodes
600 exe 'nunmap ' .. e
601 endfor
602
603 bw!
604 call test_override('no_query_mouse', 0)
605 set mousemodel&
606endfunc
607
608
609" Test MS-Windows test_mswin_event error handling
610func Test_mswin_event_error_handling()
611
612 let args = #{button: 0xfff, row: 2, col: 4, move: 0, multiclick: 0, modifiers: 0}
613 if !has('gui_running')
614 call assert_fails("call test_mswin_event('mouse', args)",'E475:')
615 endif
616 let args = #{button: 0, row: 2, col: 4, move: 0, multiclick: 0, modifiers: 0}
617 call assert_fails("call test_mswin_event('a1b2c3', args)", 'E475:')
618 call assert_fails("call test_mswin_event(test_null_string(), {})", 'E475:')
619
620 call assert_fails("call test_mswin_event([], args)", 'E1174:')
621 call assert_fails("call test_mswin_event('abc', [])", 'E1206:')
622
623 call assert_false(test_mswin_event('mouse', test_null_dict()))
624 let args = #{row: 2, col: 4, multiclick: 0, modifiers: 0}
625 call assert_false(test_mswin_event('mouse', args))
626 let args = #{button: 0, col: 4, multiclick: 0, modifiers: 0}
627 call assert_false(test_mswin_event('mouse', args))
628 let args = #{button: 0, row: 2, multiclick: 0, modifiers: 0}
629 call assert_false(test_mswin_event('mouse', args))
630 let args = #{button: 0, row: 2, col: 4, modifiers: 0}
631 call assert_false(test_mswin_event('mouse', args))
632 let args = #{button: 0, row: 2, col: 4, multiclick: 0}
633 call assert_false(test_mswin_event('mouse', args))
634
635 call assert_false(test_mswin_event('key', test_null_dict()))
636 call assert_fails("call test_mswin_event('key', [])", 'E1206:')
637 call assert_fails("call test_mswin_event('key', {'event': 'keydown', 'keycode': 0x0})", 'E1291:')
638 call assert_fails("call test_mswin_event('key', {'event': 'keydown', 'keycode': [15]})", 'E745:')
639 call assert_fails("call test_mswin_event('key', {'event': 'keys', 'keycode': 0x41})", 'E475:')
640 call assert_fails("call test_mswin_event('key', {'keycode': 0x41})", 'E417:')
641 call assert_fails("call test_mswin_event('key', {'event': 'keydown'})", 'E1291:')
642
643 call assert_fails("sandbox call test_mswin_event('key', {'event': 'keydown', 'keycode': 61 })", 'E48:')
644
645 " flush out any garbage left in the buffer.
646 while getchar(0)
647 endwhile
648endfunc
649
650
651" vim: shiftwidth=2 sts=2 expandtab