blob: 966587c31245117ef27d2bb11f2819a66f999b25 [file] [log] [blame]
Bram Moolenaar2f106582019-05-08 21:59:25 +02001" Tests for 'balloonevalterm'.
2
3if !has('balloon_eval_term') || has('gui_running')
4 finish
5endif
6
7source screendump.vim
8if !CanRunVimInTerminal()
9 finish
10endif
11
Bram Moolenaar06bd8242019-05-08 22:55:16 +020012let s:common_script = [
Bram Moolenaar2f106582019-05-08 21:59:25 +020013 \ 'call setline(1, ["one one one", "two tXo two", "three three three"])',
14 \ 'set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100',
15 \ 'func MyBalloonExpr()',
Bram Moolenaar06bd8242019-05-08 22:55:16 +020016 \ ' return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text',
Bram Moolenaar2f106582019-05-08 21:59:25 +020017 \ 'endfun',
18 \ 'redraw',
Bram Moolenaar06bd8242019-05-08 22:55:16 +020019 \ ]
20
21func Test_balloon_eval_term()
22 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
23 " the balloon.
24 call writefile(s:common_script + [
Bram Moolenaar2f106582019-05-08 21:59:25 +020025 \ 'call test_setmouse(2, 6)',
26 \ 'call feedkeys("\<MouseMove>\<Ignore>", "xt")',
27 \ ], 'XTest_beval')
28
Bram Moolenaar06bd8242019-05-08 22:55:16 +020029 " Check that the balloon shows up after a mouse move
Bram Moolenaar2f106582019-05-08 21:59:25 +020030 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
31 call term_wait(buf, 100)
32 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
33
34 " clean up
35 call StopVimInTerminal(buf)
36 call delete('XTest_beval')
37endfunc
Bram Moolenaar06bd8242019-05-08 22:55:16 +020038
39func Test_balloon_eval_term_visual()
40 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
41 " the balloon.
42 call writefile(s:common_script + [
43 \ 'call test_setmouse(3, 6)',
44 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
45 \ ], 'XTest_beval_visual')
46
47 " Check that the balloon shows up after a mouse move
48 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
49 call term_wait(buf, 100)
50 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
51
52 " clean up
53 call StopVimInTerminal(buf)
54 call delete('XTest_beval_visual')
55endfunc