blob: f32b73c0d45899c2d36d890fde8199360a62e3bd [file] [log] [blame]
Bram Moolenaar2f106582019-05-08 21:59:25 +02001" Tests for 'balloonevalterm'.
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02002" A few tests only work in the terminal.
Bram Moolenaar2f106582019-05-08 21:59:25 +02003
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02004source check.vim
Bram Moolenaar8c5a2782019-08-07 23:07:07 +02005CheckNotGui
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02006CheckFeature balloon_eval_term
Bram Moolenaar2f106582019-05-08 21:59:25 +02007
8source screendump.vim
Bram Moolenaar8c5a2782019-08-07 23:07:07 +02009CheckScreendump
Bram Moolenaar2f106582019-05-08 21:59:25 +020010
Bram Moolenaare7eb9272019-06-24 00:58:07 +020011let s:common_script =<< trim [CODE]
Bram Moolenaarc79745a2019-05-20 22:12:34 +020012 call setline(1, ["one one one", "two tXo two", "three three three"])
13 set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100
14 func MyBalloonExpr()
Bram Moolenaard1c1c822019-11-09 16:59:14 +010015 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ":\n" .. v:beval_text
Bram Moolenaarc79745a2019-05-20 22:12:34 +020016 endfun
17 redraw
18[CODE]
Bram Moolenaar06bd8242019-05-08 22:55:16 +020019
20func Test_balloon_eval_term()
21 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
22 " the balloon.
Bram Moolenaarc2f50542019-07-05 23:24:56 +020023 let xtra_lines =<< trim [CODE]
24 set updatetime=300
25 au CursorHold * echo 'hold fired'
26 func Trigger()
27 call test_setmouse(2, 6)
28 call feedkeys("\<MouseMove>\<Ignore>", "xt")
29 endfunc
30 [CODE]
31 call writefile(s:common_script + xtra_lines, 'XTest_beval')
Bram Moolenaar2f106582019-05-08 21:59:25 +020032
Bram Moolenaar06bd8242019-05-08 22:55:16 +020033 " Check that the balloon shows up after a mouse move
Bram Moolenaar2f106582019-05-08 21:59:25 +020034 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
35 call term_wait(buf, 100)
Bram Moolenaarc2f50542019-07-05 23:24:56 +020036 call term_sendkeys(buf, 'll')
37 call term_sendkeys(buf, ":call Trigger()\<CR>")
Bram Moolenaar2f106582019-05-08 21:59:25 +020038 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
39
Bram Moolenaarc2f50542019-07-05 23:24:56 +020040 " Make sure the balloon still shows after 'updatetime' passed and CursorHold
41 " was triggered.
42 call term_wait(buf, 300)
43 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01a', {})
44
Bram Moolenaar2f106582019-05-08 21:59:25 +020045 " clean up
46 call StopVimInTerminal(buf)
47 call delete('XTest_beval')
48endfunc
Bram Moolenaar06bd8242019-05-08 22:55:16 +020049
50func Test_balloon_eval_term_visual()
51 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
52 " the balloon.
53 call writefile(s:common_script + [
54 \ 'call test_setmouse(3, 6)',
55 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
56 \ ], 'XTest_beval_visual')
57
58 " Check that the balloon shows up after a mouse move
59 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
60 call term_wait(buf, 100)
61 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
62
63 " clean up
64 call StopVimInTerminal(buf)
65 call delete('XTest_beval_visual')
66endfunc