1" Tests for 'balloonevalterm'. 2" A few tests only work in the terminal. 3 4if has('gui_running') 5 throw 'Skipped: only work in the terminal' 6endif 7 8source check.vim 9CheckFeature balloon_eval_term 10 11source screendump.vim 12if !CanRunVimInTerminal() 13 throw 'Skipped: cannot make screendumps' 14endif 15 16let s:common_script =<< trim [CODE] 17 call setline(1, ["one one one", "two tXo two", "three three three"]) 18 set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100 19 func MyBalloonExpr() 20 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text 21 endfun 22 redraw 23[CODE] 24 25func Test_balloon_eval_term() 26 " Use <Ignore> after <MouseMove> to return from vgetc() without removing 27 " the balloon. 28 let xtra_lines =<< trim [CODE] 29 set updatetime=300 30 au CursorHold * echo 'hold fired' 31 func Trigger() 32 call test_setmouse(2, 6) 33 call feedkeys("\<MouseMove>\<Ignore>", "xt") 34 endfunc 35 [CODE] 36 call writefile(s:common_script + xtra_lines, 'XTest_beval') 37 38 " Check that the balloon shows up after a mouse move 39 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50}) 40 call term_wait(buf, 100) 41 call term_sendkeys(buf, 'll') 42 call term_sendkeys(buf, ":call Trigger()\<CR>") 43 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {}) 44 45 " Make sure the balloon still shows after 'updatetime' passed and CursorHold 46 " was triggered. 47 call term_wait(buf, 300) 48 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01a', {}) 49 50 " clean up 51 call StopVimInTerminal(buf) 52 call delete('XTest_beval') 53endfunc 54 55func Test_balloon_eval_term_visual() 56 " Use <Ignore> after <MouseMove> to return from vgetc() without removing 57 " the balloon. 58 call writefile(s:common_script + [ 59 \ 'call test_setmouse(3, 6)', 60 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")', 61 \ ], 'XTest_beval_visual') 62 63 " Check that the balloon shows up after a mouse move 64 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50}) 65 call term_wait(buf, 100) 66 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {}) 67 68 " clean up 69 call StopVimInTerminal(buf) 70 call delete('XTest_beval_visual') 71endfunc 72