summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_gui.vim
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-07-23 05:04:16 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-23 05:04:16 +0100
commit81a3ff97e2012bdafc3ece796289f2e11e2754f3 (patch)
tree15226ff00df55bc1927e6ab0bed077e703314be9 /src/testdir/test_gui.vim
parent5154a8880034b7bb94186d37bcecc6ee1a96f732 (diff)
patch 9.0.0058: Win32: cannot test low level eventsv9.0.0058
Problem: Win32: cannot test low level events. Solution: Add "sendevent" to test_gui_event(). (Yegappan Lakshmanan, closes #10679)
Diffstat (limited to 'src/testdir/test_gui.vim')
-rw-r--r--src/testdir/test_gui.vim84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index 2612812b62..1fadd5eaed 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -1606,4 +1606,88 @@ func Test_gui_dialog_file()
call delete('Xlines')
endfunc
+" Test for sending low level key presses
+func SendKeys(keylist)
+ for k in a:keylist
+ call test_gui_event("sendevent", #{event: "keydown", keycode: k})
+ endfor
+ for k in reverse(a:keylist)
+ call test_gui_event("sendevent", #{event: "keyup", keycode: k})
+ endfor
+endfunc
+
+func Test_gui_lowlevel_keyevent()
+ CheckMSWindows
+ new
+
+ " Test for <Ctrl-A> to <Ctrl-Z> keys
+ for kc in range(65, 90)
+ call SendKeys([0x11, kc])
+ let ch = getcharstr()
+ call assert_equal(nr2char(kc - 64), ch)
+ endfor
+
+ " Test for the various Ctrl and Shift key combinations.
+ let keytests = [
+ \ [[0x10, 0x21], "\<S-Pageup>", 2],
+ \ [[0x11, 0x21], "\<C-Pageup>", 4],
+ \ [[0x10, 0x22], "\<S-PageDown>", 2],
+ \ [[0x11, 0x22], "\<C-PageDown>", 4],
+ \ [[0x10, 0x23], "\<S-End>", 0],
+ \ [[0x11, 0x23], "\<C-End>", 0],
+ \ [[0x10, 0x24], "\<S-Home>", 0],
+ \ [[0x11, 0x24], "\<C-Home>", 0],
+ \ [[0x10, 0x25], "\<S-Left>", 0],
+ \ [[0x11, 0x25], "\<C-Left>", 0],
+ \ [[0x10, 0x26], "\<S-Up>", 0],
+ \ [[0x11, 0x26], "\<C-Up>", 4],
+ \ [[0x10, 0x27], "\<S-Right>", 0],
+ \ [[0x11, 0x27], "\<C-Right>", 0],
+ \ [[0x10, 0x28], "\<S-Down>", 0],
+ \ [[0x11, 0x28], "\<C-Down>", 4],
+ \ [[0x11, 0x30], "\<C-0>", 4],
+ \ [[0x11, 0x31], "\<C-1>", 4],
+ \ [[0x11, 0x32], "\<C-2>", 4],
+ \ [[0x11, 0x33], "\<C-3>", 4],
+ \ [[0x11, 0x34], "\<C-4>", 4],
+ \ [[0x11, 0x35], "\<C-5>", 4],
+ \ [[0x11, 0x36], "\<C-^>", 0],
+ \ [[0x11, 0x37], "\<C-7>", 4],
+ \ [[0x11, 0x38], "\<C-8>", 4],
+ \ [[0x11, 0x39], "\<C-9>", 4],
+ \ [[0x11, 0x60], "\<C-0>", 4],
+ \ [[0x11, 0x61], "\<C-1>", 4],
+ \ [[0x11, 0x62], "\<C-2>", 4],
+ \ [[0x11, 0x63], "\<C-3>", 4],
+ \ [[0x11, 0x64], "\<C-4>", 4],
+ \ [[0x11, 0x65], "\<C-5>", 4],
+ \ [[0x11, 0x66], "\<C-6>", 4],
+ \ [[0x11, 0x67], "\<C-7>", 4],
+ \ [[0x11, 0x68], "\<C-8>", 4],
+ \ [[0x11, 0x69], "\<C-9>", 4],
+ \ [[0x11, 0x6A], "\<C-*>", 4],
+ \ [[0x11, 0x6B], "\<C-+>", 4],
+ \ [[0x11, 0x6D], "\<C-->", 4],
+ \ [[0x11, 0x70], "\<C-F1>", 4],
+ \ [[0x11, 0x71], "\<C-F2>", 4],
+ \ [[0x11, 0x72], "\<C-F3>", 4],
+ \ [[0x11, 0x73], "\<C-F4>", 4],
+ \ [[0x11, 0x74], "\<C-F5>", 4],
+ \ [[0x11, 0x75], "\<C-F6>", 4],
+ \ [[0x11, 0x76], "\<C-F7>", 4],
+ \ [[0x11, 0x77], "\<C-F8>", 4],
+ \ [[0x11, 0x78], "\<C-F9>", 4],
+ \ ]
+
+ for [kcodes, kstr, kmod] in keytests
+ call SendKeys(kcodes)
+ let ch = getcharstr()
+ let mod = getcharmod()
+ call assert_equal(kstr, ch, $"key = {kstr}")
+ call assert_equal(kmod, mod)
+ endfor
+
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab