Bram Moolenaar | 2f10658 | 2019-05-08 21:59:25 +0200 | [diff] [blame] | 1 | " Tests for 'balloonevalterm'. |
| 2 | |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 3 | if !has('balloon_eval_term') |
| 4 | throw 'Skipped: balloon_eval_term feature missing' |
| 5 | endif |
| 6 | |
| 7 | " A few tests only work in the terminal. |
| 8 | if !has('gui_running') |
Bram Moolenaar | 2f10658 | 2019-05-08 21:59:25 +0200 | [diff] [blame] | 9 | |
| 10 | source screendump.vim |
| 11 | if !CanRunVimInTerminal() |
Bram Moolenaar | 5d30ff1 | 2019-06-06 16:12:12 +0200 | [diff] [blame] | 12 | throw 'Skipped: cannot make screendumps' |
Bram Moolenaar | 2f10658 | 2019-05-08 21:59:25 +0200 | [diff] [blame] | 13 | endif |
| 14 | |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 15 | let 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] |
Bram Moolenaar | 06bd824 | 2019-05-08 22:55:16 +0200 | [diff] [blame] | 23 | |
| 24 | func Test_balloon_eval_term() |
| 25 | " Use <Ignore> after <MouseMove> to return from vgetc() without removing |
| 26 | " the balloon. |
| 27 | call writefile(s:common_script + [ |
Bram Moolenaar | 2f10658 | 2019-05-08 21:59:25 +0200 | [diff] [blame] | 28 | \ 'call test_setmouse(2, 6)', |
| 29 | \ 'call feedkeys("\<MouseMove>\<Ignore>", "xt")', |
| 30 | \ ], 'XTest_beval') |
| 31 | |
Bram Moolenaar | 06bd824 | 2019-05-08 22:55:16 +0200 | [diff] [blame] | 32 | " Check that the balloon shows up after a mouse move |
Bram Moolenaar | 2f10658 | 2019-05-08 21:59:25 +0200 | [diff] [blame] | 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') |
| 40 | endfunc |
Bram Moolenaar | 06bd824 | 2019-05-08 22:55:16 +0200 | [diff] [blame] | 41 | |
| 42 | func 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') |
| 58 | endfunc |
Bram Moolenaar | be0a259 | 2019-05-09 13:50:16 +0200 | [diff] [blame] | 59 | |
| 60 | endif |
| 61 | |
| 62 | " Tests that only work in the GUI |
| 63 | if has('gui_running') |
| 64 | |
| 65 | func 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('') |
| 77 | endfunc |
| 78 | |
| 79 | endif |