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