comparison src/testdir/test_gui.vim @ 29432:339fe2968690 v9.0.0058

patch 9.0.0058: Win32: cannot test low level events Commit: https://github.com/vim/vim/commit/81a3ff97e2012bdafc3ece796289f2e11e2754f3 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Jul 23 05:04:16 2022 +0100 patch 9.0.0058: Win32: cannot test low level events Problem: Win32: cannot test low level events. Solution: Add "sendevent" to test_gui_event(). (Yegappan Lakshmanan, closes #10679)
author Bram Moolenaar <Bram@vim.org>
date Sat, 23 Jul 2022 06:15:07 +0200
parents 8175cd4c8fdd
children 6d44e5e9e0ce
comparison
equal deleted inserted replaced
29431:6d6fa84d617c 29432:339fe2968690
1604 call delete('Xdialog') 1604 call delete('Xdialog')
1605 call delete('Xfile') 1605 call delete('Xfile')
1606 call delete('Xlines') 1606 call delete('Xlines')
1607 endfunc 1607 endfunc
1608 1608
1609 " Test for sending low level key presses
1610 func SendKeys(keylist)
1611 for k in a:keylist
1612 call test_gui_event("sendevent", #{event: "keydown", keycode: k})
1613 endfor
1614 for k in reverse(a:keylist)
1615 call test_gui_event("sendevent", #{event: "keyup", keycode: k})
1616 endfor
1617 endfunc
1618
1619 func Test_gui_lowlevel_keyevent()
1620 CheckMSWindows
1621 new
1622
1623 " Test for <Ctrl-A> to <Ctrl-Z> keys
1624 for kc in range(65, 90)
1625 call SendKeys([0x11, kc])
1626 let ch = getcharstr()
1627 call assert_equal(nr2char(kc - 64), ch)
1628 endfor
1629
1630 " Test for the various Ctrl and Shift key combinations.
1631 let keytests = [
1632 \ [[0x10, 0x21], "\<S-Pageup>", 2],
1633 \ [[0x11, 0x21], "\<C-Pageup>", 4],
1634 \ [[0x10, 0x22], "\<S-PageDown>", 2],
1635 \ [[0x11, 0x22], "\<C-PageDown>", 4],
1636 \ [[0x10, 0x23], "\<S-End>", 0],
1637 \ [[0x11, 0x23], "\<C-End>", 0],
1638 \ [[0x10, 0x24], "\<S-Home>", 0],
1639 \ [[0x11, 0x24], "\<C-Home>", 0],
1640 \ [[0x10, 0x25], "\<S-Left>", 0],
1641 \ [[0x11, 0x25], "\<C-Left>", 0],
1642 \ [[0x10, 0x26], "\<S-Up>", 0],
1643 \ [[0x11, 0x26], "\<C-Up>", 4],
1644 \ [[0x10, 0x27], "\<S-Right>", 0],
1645 \ [[0x11, 0x27], "\<C-Right>", 0],
1646 \ [[0x10, 0x28], "\<S-Down>", 0],
1647 \ [[0x11, 0x28], "\<C-Down>", 4],
1648 \ [[0x11, 0x30], "\<C-0>", 4],
1649 \ [[0x11, 0x31], "\<C-1>", 4],
1650 \ [[0x11, 0x32], "\<C-2>", 4],
1651 \ [[0x11, 0x33], "\<C-3>", 4],
1652 \ [[0x11, 0x34], "\<C-4>", 4],
1653 \ [[0x11, 0x35], "\<C-5>", 4],
1654 \ [[0x11, 0x36], "\<C-^>", 0],
1655 \ [[0x11, 0x37], "\<C-7>", 4],
1656 \ [[0x11, 0x38], "\<C-8>", 4],
1657 \ [[0x11, 0x39], "\<C-9>", 4],
1658 \ [[0x11, 0x60], "\<C-0>", 4],
1659 \ [[0x11, 0x61], "\<C-1>", 4],
1660 \ [[0x11, 0x62], "\<C-2>", 4],
1661 \ [[0x11, 0x63], "\<C-3>", 4],
1662 \ [[0x11, 0x64], "\<C-4>", 4],
1663 \ [[0x11, 0x65], "\<C-5>", 4],
1664 \ [[0x11, 0x66], "\<C-6>", 4],
1665 \ [[0x11, 0x67], "\<C-7>", 4],
1666 \ [[0x11, 0x68], "\<C-8>", 4],
1667 \ [[0x11, 0x69], "\<C-9>", 4],
1668 \ [[0x11, 0x6A], "\<C-*>", 4],
1669 \ [[0x11, 0x6B], "\<C-+>", 4],
1670 \ [[0x11, 0x6D], "\<C-->", 4],
1671 \ [[0x11, 0x70], "\<C-F1>", 4],
1672 \ [[0x11, 0x71], "\<C-F2>", 4],
1673 \ [[0x11, 0x72], "\<C-F3>", 4],
1674 \ [[0x11, 0x73], "\<C-F4>", 4],
1675 \ [[0x11, 0x74], "\<C-F5>", 4],
1676 \ [[0x11, 0x75], "\<C-F6>", 4],
1677 \ [[0x11, 0x76], "\<C-F7>", 4],
1678 \ [[0x11, 0x77], "\<C-F8>", 4],
1679 \ [[0x11, 0x78], "\<C-F9>", 4],
1680 \ ]
1681
1682 for [kcodes, kstr, kmod] in keytests
1683 call SendKeys(kcodes)
1684 let ch = getcharstr()
1685 let mod = getcharmod()
1686 call assert_equal(kstr, ch, $"key = {kstr}")
1687 call assert_equal(kmod, mod)
1688 endfor
1689
1690 bw!
1691 endfunc
1692
1609 " vim: shiftwidth=2 sts=2 expandtab 1693 " vim: shiftwidth=2 sts=2 expandtab