blob: 3db37a76b0c85614332a4ddc9aa4f7b1308c13e1 [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>")
Yee Cheng Chine70587d2025-02-13 20:55:45 +010039 sleep 150m " Wait for balloon to show up (100ms balloondelay time)
Bram Moolenaar2f106582019-05-08 21:59:25 +020040 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
41
Bram Moolenaarc2f50542019-07-05 23:24:56 +020042 " Make sure the balloon still shows after 'updatetime' passed and CursorHold
43 " was triggered.
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020044 call TermWait(buf, 150)
Bram Moolenaarc2f50542019-07-05 23:24:56 +020045 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01a', {})
46
Bram Moolenaar2f106582019-05-08 21:59:25 +020047 " clean up
48 call StopVimInTerminal(buf)
Bram Moolenaar2f106582019-05-08 21:59:25 +020049endfunc
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")',
Bram Moolenaar34112652022-09-05 21:40:44 +010057 \ ], 'XTest_beval_visual', 'D')
Bram Moolenaar06bd8242019-05-08 22:55:16 +020058
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)
Bram Moolenaar06bd8242019-05-08 22:55:16 +020066endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020067
zeertzjq883018f2024-06-15 15:37:11 +020068func Test_balloon_eval_term_rightleft()
69 CheckFeature rightleft
70
71 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
72 " the balloon.
73 let xtra_lines =<< trim [CODE]
74 set rightleft
75 func Trigger()
76 call test_setmouse(2, 50 + 1 - 6)
77 call feedkeys("\<MouseMove>\<Ignore>", "xt")
78 endfunc
79 [CODE]
80 call writefile(s:common_script + xtra_lines, 'XTest_beval_rl', 'D')
81
82 " Check that the balloon shows up after a mouse move
83 let buf = RunVimInTerminal('-S XTest_beval_rl', {'rows': 10, 'cols': 50})
84 call TermWait(buf, 50)
85 call term_sendkeys(buf, 'll')
86 call term_sendkeys(buf, ":call Trigger()\<CR>")
87 call VerifyScreenDump(buf, 'Test_balloon_eval_term_03', {})
88
89 " clean up
90 call StopVimInTerminal(buf)
91endfunc
92
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020093" vim: shiftwidth=2 sts=2 expandtab