blob: b3c680e1116a1e3673b384e7db3bdb1d6b2f0ce1 [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.
28 call writefile(s:common_script + [
Bram Moolenaar2f106582019-05-08 21:59:25 +020029 \ 'call test_setmouse(2, 6)',
30 \ 'call feedkeys("\<MouseMove>\<Ignore>", "xt")',
31 \ ], 'XTest_beval')
32
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)
36 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
37
38 " clean up
39 call StopVimInTerminal(buf)
40 call delete('XTest_beval')
41endfunc
Bram Moolenaar06bd8242019-05-08 22:55:16 +020042
43func Test_balloon_eval_term_visual()
44 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
45 " the balloon.
46 call writefile(s:common_script + [
47 \ 'call test_setmouse(3, 6)',
48 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
49 \ ], 'XTest_beval_visual')
50
51 " Check that the balloon shows up after a mouse move
52 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
53 call term_wait(buf, 100)
54 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
55
56 " clean up
57 call StopVimInTerminal(buf)
58 call delete('XTest_beval_visual')
59endfunc