Skip to content

Commit

Permalink
Test_gui_lowlevel_ctrl_dead_clfex_eq_esc()
Browse files Browse the repository at this point in the history
New low-level keypresses testcase relying on "setkblayout"

reproduces problem which failed prior to 9.0.0087 (vim#10687, vim#10454)
  • Loading branch information
haron13-2019 committed Jul 30, 2022
1 parent d2b807e commit a72161e
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions src/testdir/test_gui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1690,4 +1690,106 @@ func Test_gui_lowlevel_keyevent()
bw!
endfunc

func GetSendMyKeysSrc()

let lines =<< trim END
" help function for low-level keypresses simulation
func SendMyKeys(keylist)
let l:k = ""
let l:t = ""
for key in a:keylist
"echomsg "k[i]=".key
if l:k == ""
let l:k = key
"echomsg "l:k=".l:k
else
let l:t = key
"echomsg "l:t=".l:k
endif
if l:t != ""
if l:t == "du"
"echomsg "k=".l:k.", t=".l:t
call test_gui_event("sendevent", #{event: "keydown", keycode: l:k})
call test_gui_event("sendevent", #{event: "keyup", keycode: l:k})
endif
if l:t == "d"
call test_gui_event("sendevent", #{event: "keydown", keycode: l:k})
endif
if l:t == "u"
call test_gui_event("sendevent", #{event: "keyup", keycode: l:k})
endif
let l:t=""
let l:k=""
endif
endfor
endfunc
END

return lines

endfunc

" test if ctrl+dead circumflex on AZERTY/FR (and on QWERTZ/DE) generates ESC
" (This has failed before 9.0.0087 (#10687, #10454)
func Test_gui_lowlevel_ctrl_dead_clfex_eq_esc()
CheckMSWindows
new

let sendmykeys_src = GetSendMyKeysSrc()

let lines =<< trim END
call test_gui_event("setkblayout", #{kblayout: "DE", keycode: -99})

" <i>
call SendMyKeys([73,"du"])
" <dead>
call SendMyKeys(["68","du","69","du","65","du","68","du"])

" { this should generate "ESC" via new feature "dead circumflex in DE"
" 17 = ctrl; 220 = dead^ on german keyboard
call SendMyKeys([17,"d",220,"du",17,"u"])

" <o>
call SendMyKeys([79,"du"])

" <cicrumflex>
call SendMyKeys(["67","du","73","du","82","du","67","du","85","du",77,"du","70","du","76","du",69,"du",88,"du"])

" <ESC>
call SendMyKeys([27,"du"])

"call WaitFor({-> getline(2) == "circumflex"})

" <shift ':' shift up 'c' 'a' 'l' 'l' space>
call SendMyKeys([16,"d",190,"du",16,"u",67,"du",65,"du",76,"du",76,"du",32,"du"])

" <shift v m i (56 )57 shift up ENTER>
call SendMyKeys([16,"d", 86, "du", 77, "du", 73, "du", 56, "du", 57, "du", 16, "u", 13, "du"])

func VMI()
write
quit
endfunction
END

call writefile(sendmykeys_src + lines, 'Xlines')
"call writefile(lines, 'Xlines')

let prefix = '!'
if has('win32')
let prefix = '!start '
endif
execute prefix .. GetVimCommand() .. ' -g -u NONE Xresult -S Xlines'

call WaitForAssert({-> assert_true(filereadable('Xresult'))})
edit Xresult

call assert_equal("dead" , getline(1))
call assert_equal("circumflex", getline(2))

bw!
call delete('Xresult')
call delete('Xlines')
endfunc

" vim: shiftwidth=2 sts=2 expandtab

0 comments on commit a72161e

Please sign in to comment.