blob: 796cb23f673798edf7e8806931fb29ad604d8d6f [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 +02004if has('gui_running')
5 throw 'Skipped: only work in the terminal'
Bram Moolenaar9c0cec62019-06-06 13:38:15 +02006endif
7
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02008source check.vim
9CheckFeature balloon_eval_term
Bram Moolenaar2f106582019-05-08 21:59:25 +020010
11source screendump.vim
12if !CanRunVimInTerminal()
Bram Moolenaar5d30ff12019-06-06 16:12:12 +020013 throw 'Skipped: cannot make screendumps'
Bram Moolenaar2f106582019-05-08 21:59:25 +020014endif
15
Bram Moolenaare7eb9272019-06-24 00:58:07 +020016let s:common_script =<< trim [CODE]
Bram Moolenaarc79745a2019-05-20 22:12:34 +020017 call setline(1, ["one one one", "two tXo two", "three three three"])
18 set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100
19 func MyBalloonExpr()
20 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text
21 endfun
22 redraw
23[CODE]
Bram Moolenaar06bd8242019-05-08 22:55:16 +020024
25func Test_balloon_eval_term()
26 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
27 " the balloon.
Bram Moolenaarc2f50542019-07-05 23:24:56 +020028 let xtra_lines =<< trim [CODE]
29 set updatetime=300
30 au CursorHold * echo 'hold fired'
31 func Trigger()
32 call test_setmouse(2, 6)
33 call feedkeys("\<MouseMove>\<Ignore>", "xt")
34 endfunc
35 [CODE]
36 call writefile(s:common_script + xtra_lines, 'XTest_beval')
Bram Moolenaar2f106582019-05-08 21:59:25 +020037
Bram Moolenaar06bd8242019-05-08 22:55:16 +020038 " Check that the balloon shows up after a mouse move
Bram Moolenaar2f106582019-05-08 21:59:25 +020039 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
40 call term_wait(buf, 100)
Bram Moolenaarc2f50542019-07-05 23:24:56 +020041 call term_sendkeys(buf, 'll')
42 call term_sendkeys(buf, ":call Trigger()\<CR>")
Bram Moolenaar2f106582019-05-08 21:59:25 +020043 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
44
Bram Moolenaarc2f50542019-07-05 23:24:56 +020045 " Make sure the balloon still shows after 'updatetime' passed and CursorHold
46 " was triggered.
47 call term_wait(buf, 300)
48 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01a', {})
49
Bram Moolenaar2f106582019-05-08 21:59:25 +020050 " clean up
51 call StopVimInTerminal(buf)
52 call delete('XTest_beval')
53endfunc
Bram Moolenaar06bd8242019-05-08 22:55:16 +020054
55func Test_balloon_eval_term_visual()
56 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
57 " the balloon.
58 call writefile(s:common_script + [
59 \ 'call test_setmouse(3, 6)',
60 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
61 \ ], 'XTest_beval_visual')
62
63 " Check that the balloon shows up after a mouse move
64 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
65 call term_wait(buf, 100)
66 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
67
68 " clean up
69 call StopVimInTerminal(buf)
70 call delete('XTest_beval_visual')
71endfunc