1
0
forked from aniani/vim

patch 9.0.0849: terminal mouse test is a bit flaky

Problem:    Terminal mouse test is a bit flaky.
Solution:   Add WaitFor() calls. (James McCoy closes #11519)  Tune wait times
            to reduce flakiness.
This commit is contained in:
James McCoy
2022-11-09 23:29:14 +00:00
committed by Bram Moolenaar
parent 76db9e0763
commit 157241e879
2 changed files with 24 additions and 17 deletions

View File

@@ -267,11 +267,11 @@ func Test_terminal_in_popup()
\ ] \ ]
call writefile(lines, 'XtermPopup', 'D') call writefile(lines, 'XtermPopup', 'D')
let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15}) let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
call TermWait(buf, 100) call TermWait(buf, 200)
call term_sendkeys(buf, ":call OpenTerm(0)\<CR>") call term_sendkeys(buf, ":call OpenTerm(0)\<CR>")
call TermWait(buf, 500) call TermWait(buf, 800)
call term_sendkeys(buf, ":\<CR>") call term_sendkeys(buf, ":\<CR>")
call TermWait(buf, 100) call TermWait(buf, 500)
call term_sendkeys(buf, "\<C-W>:echo getwinvar(g:winid, \"&buftype\") win_gettype(g:winid)\<CR>") call term_sendkeys(buf, "\<C-W>:echo getwinvar(g:winid, \"&buftype\") win_gettype(g:winid)\<CR>")
call VerifyScreenDump(buf, 'Test_terminal_popup_1', {}) call VerifyScreenDump(buf, 'Test_terminal_popup_1', {})
@@ -279,9 +279,9 @@ func Test_terminal_in_popup()
call VerifyScreenDump(buf, 'Test_terminal_popup_2', {}) call VerifyScreenDump(buf, 'Test_terminal_popup_2', {})
call term_sendkeys(buf, ":call OpenTerm(1)\<CR>") call term_sendkeys(buf, ":call OpenTerm(1)\<CR>")
call TermWait(buf, 500) call TermWait(buf, 800)
call term_sendkeys(buf, ":set hlsearch\<CR>") call term_sendkeys(buf, ":set hlsearch\<CR>")
call TermWait(buf, 100) call TermWait(buf, 500)
call term_sendkeys(buf, "/edit\<CR>") call term_sendkeys(buf, "/edit\<CR>")
call VerifyScreenDump(buf, 'Test_terminal_popup_3', {}) call VerifyScreenDump(buf, 'Test_terminal_popup_3', {})
@@ -686,6 +686,8 @@ func Test_term_mouse()
call TermWait(buf) call TermWait(buf)
redraw! redraw!
let XbufExists = {-> filereadable('Xbuf')}
" Use the mouse to enter the terminal window " Use the mouse to enter the terminal window
call win_gotoid(prev_win) call win_gotoid(prev_win)
call feedkeys(MouseLeftClickCode(1, 1), 'x') call feedkeys(MouseLeftClickCode(1, 1), 'x')
@@ -698,73 +700,76 @@ func Test_term_mouse()
call test_setmouse(3, 8) call test_setmouse(3, 8)
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>")
call TermWait(buf, 50) call TermWait(buf, 50)
call delete('Xbuf')
call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\<CR>")
call TermWait(buf, 50) call TermWait(buf, 50)
call WaitFor(XbufExists)
let pos = json_decode(readfile('Xbuf')[0]) let pos = json_decode(readfile('Xbuf')[0])
call assert_equal([3, 8], pos[1:2]) call assert_equal([3, 8], pos[1:2])
call delete('Xbuf')
" Test for selecting text using mouse " Test for selecting text using mouse
call delete('Xbuf')
call test_setmouse(2, 11) call test_setmouse(2, 11)
call term_sendkeys(buf, "\<LeftMouse>") call term_sendkeys(buf, "\<LeftMouse>")
call test_setmouse(2, 16) call test_setmouse(2, 16)
call term_sendkeys(buf, "\<LeftRelease>y") call term_sendkeys(buf, "\<LeftRelease>y")
call TermWait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call TermWait(buf, 50) call WaitFor(XbufExists)
call assert_equal('yellow', readfile('Xbuf')[0]) call assert_equal('yellow', readfile('Xbuf')[0])
call delete('Xbuf')
" Test for selecting text using double click " Test for selecting text using double click
call delete('Xbuf')
call test_setmouse(1, 11) call test_setmouse(1, 11)
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>")
call test_setmouse(1, 17) call test_setmouse(1, 17)
call term_sendkeys(buf, "\<LeftRelease>y") call term_sendkeys(buf, "\<LeftRelease>y")
call TermWait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call TermWait(buf, 50) call WaitFor(XbufExists)
call assert_equal('three four', readfile('Xbuf')[0]) call assert_equal('three four', readfile('Xbuf')[0])
call delete('Xbuf')
" Test for selecting a line using triple click " Test for selecting a line using triple click
call delete('Xbuf')
call test_setmouse(3, 2) call test_setmouse(3, 2)
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>y") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>y")
call TermWait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call TermWait(buf, 50) call WaitFor(XbufExists)
call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0]) call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0])
call delete('Xbuf')
" Test for selecting a block using quadruple click " Test for selecting a block using quadruple click
call delete('Xbuf')
call test_setmouse(1, 11) call test_setmouse(1, 11)
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>")
call test_setmouse(3, 13) call test_setmouse(3, 13)
call term_sendkeys(buf, "\<LeftRelease>y") call term_sendkeys(buf, "\<LeftRelease>y")
call TermWait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call TermWait(buf, 50) call WaitFor(XbufExists)
call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0]) call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0])
call delete('Xbuf')
" Test for extending a selection using right click " Test for extending a selection using right click
call delete('Xbuf')
call test_setmouse(2, 9) call test_setmouse(2, 9)
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>")
call test_setmouse(2, 16) call test_setmouse(2, 16)
call term_sendkeys(buf, "\<RightMouse>\<RightRelease>y") call term_sendkeys(buf, "\<RightMouse>\<RightRelease>y")
call TermWait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call TermWait(buf, 50) call WaitFor(XbufExists)
call assert_equal("n yellow", readfile('Xbuf')[0]) call assert_equal("n yellow", readfile('Xbuf')[0])
call delete('Xbuf')
" Test for pasting text using middle click " Test for pasting text using middle click
call delete('Xbuf')
call term_sendkeys(buf, ":let @r='bright '\<CR>") call term_sendkeys(buf, ":let @r='bright '\<CR>")
call test_setmouse(2, 22) call test_setmouse(2, 22)
call term_sendkeys(buf, "\"r\<MiddleMouse>\<MiddleRelease>") call term_sendkeys(buf, "\"r\<MiddleMouse>\<MiddleRelease>")
call TermWait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([getline(2)], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([getline(2)], 'Xbuf')\<CR>")
call TermWait(buf, 50) call WaitFor(XbufExists)
call assert_equal("red bright blue", readfile('Xbuf')[0][-15:]) call assert_equal("red bright blue", readfile('Xbuf')[0][-15:])
call delete('Xbuf')
" cleanup " cleanup
call TermWait(buf) call TermWait(buf)

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
849,
/**/ /**/
848, 848,
/**/ /**/