blob: 80d58319681d28539e9a7618c930e91bc1f2a8ff [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]
Bram Moolenaar34112652022-09-05 21:40:44 +010032 call writefile(s:common_script + xtra_lines, 'XTest_beval', 'D')
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)
Bram Moolenaar2f106582019-05-08 21:59:25 +020048endfunc
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")',
Bram Moolenaar34112652022-09-05 21:40:44 +010056 \ ], 'XTest_beval_visual', 'D')
Bram Moolenaar06bd8242019-05-08 22:55:16 +020057
58 " Check that the balloon shows up after a mouse move
59 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020060 call TermWait(buf, 50)
Bram Moolenaar06bd8242019-05-08 22:55:16 +020061 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
62
63 " clean up
64 call StopVimInTerminal(buf)
Bram Moolenaar06bd8242019-05-08 22:55:16 +020065endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020066
zeertzjq883018f2024-06-15 15:37:11 +020067func Test_balloon_eval_term_rightleft()
68 CheckFeature rightleft
69
70 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
71 " the balloon.
72 let xtra_lines =<< trim [CODE]
73 set rightleft
74 func Trigger()
75 call test_setmouse(2, 50 + 1 - 6)
76 call feedkeys("\<MouseMove>\<Ignore>", "xt")
77 endfunc
78 [CODE]
79 call writefile(s:common_script + xtra_lines, 'XTest_beval_rl', 'D')
80
81 " Check that the balloon shows up after a mouse move
82 let buf = RunVimInTerminal('-S XTest_beval_rl', {'rows': 10, 'cols': 50})
83 call TermWait(buf, 50)
84 call term_sendkeys(buf, 'll')
85 call term_sendkeys(buf, ":call Trigger()\<CR>")
86 call VerifyScreenDump(buf, 'Test_balloon_eval_term_03', {})
87
88 " clean up
89 call StopVimInTerminal(buf)
90endfunc
91
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020092" vim: shiftwidth=2 sts=2 expandtab