blob: ed0c6c19365f3e7512497848c8da2d836d795b12 [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"])
Bram Moolenaar5600a702022-01-22 15:09:36 +000013 set balloonevalterm balloonexpr=MyBalloonExpr()..s:trailing balloondelay=100
14 let s:trailing = '<' " check that script context is set
Bram Moolenaarc79745a2019-05-20 22:12:34 +020015 func MyBalloonExpr()
Bram Moolenaard1c1c822019-11-09 16:59:14 +010016 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ":\n" .. v:beval_text
Bram Moolenaarc79745a2019-05-20 22:12:34 +020017 endfun
18 redraw
19[CODE]
Bram Moolenaar06bd8242019-05-08 22:55:16 +020020
21func Test_balloon_eval_term()
22 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
23 " the balloon.
Bram Moolenaarc2f50542019-07-05 23:24:56 +020024 let xtra_lines =<< trim [CODE]
25 set updatetime=300
26 au CursorHold * echo 'hold fired'
27 func Trigger()
28 call test_setmouse(2, 6)
29 call feedkeys("\<MouseMove>\<Ignore>", "xt")
30 endfunc
31 [CODE]
32 call writefile(s:common_script + xtra_lines, 'XTest_beval')
Bram Moolenaar2f106582019-05-08 21:59:25 +020033
Bram Moolenaar06bd8242019-05-08 22:55:16 +020034 " Check that the balloon shows up after a mouse move
Bram Moolenaar2f106582019-05-08 21:59:25 +020035 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020036 call TermWait(buf, 50)
Bram Moolenaarc2f50542019-07-05 23:24:56 +020037 call term_sendkeys(buf, 'll')
38 call term_sendkeys(buf, ":call Trigger()\<CR>")
Bram Moolenaar2f106582019-05-08 21:59:25 +020039 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
40
Bram Moolenaarc2f50542019-07-05 23:24:56 +020041 " Make sure the balloon still shows after 'updatetime' passed and CursorHold
42 " was triggered.
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020043 call TermWait(buf, 150)
Bram Moolenaarc2f50542019-07-05 23:24:56 +020044 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01a', {})
45
Bram Moolenaar2f106582019-05-08 21:59:25 +020046 " clean up
47 call StopVimInTerminal(buf)
48 call delete('XTest_beval')
49endfunc
Bram Moolenaar06bd8242019-05-08 22:55:16 +020050
51func Test_balloon_eval_term_visual()
52 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
53 " the balloon.
54 call writefile(s:common_script + [
55 \ 'call test_setmouse(3, 6)',
56 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
57 \ ], 'XTest_beval_visual')
58
59 " Check that the balloon shows up after a mouse move
60 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020061 call TermWait(buf, 50)
Bram Moolenaar06bd8242019-05-08 22:55:16 +020062 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
63
64 " clean up
65 call StopVimInTerminal(buf)
66 call delete('XTest_beval_visual')
67endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020068
69" vim: shiftwidth=2 sts=2 expandtab