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