blob: 6f89f2fa968031669003c3300669df927ca6e783 [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 Moolenaar8c5a2782019-08-07 23:07:07 +02004CheckNotGui
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02005CheckFeature balloon_eval_term
Bram Moolenaar2f106582019-05-08 21:59:25 +02006
7source screendump.vim
Bram Moolenaar2f106582019-05-08 21:59:25 +02008
Bram Moolenaare7eb9272019-06-24 00:58:07 +02009let s:common_script =<< trim [CODE]
Bram Moolenaarc79745a2019-05-20 22:12:34 +020010 call setline(1, ["one one one", "two tXo two", "three three three"])
Bram Moolenaar5600a702022-01-22 15:09:36 +000011 set balloonevalterm balloonexpr=MyBalloonExpr()..s:trailing balloondelay=100
12 let s:trailing = '<' " check that script context is set
Bram Moolenaarc79745a2019-05-20 22:12:34 +020013 func MyBalloonExpr()
Bram Moolenaard1c1c822019-11-09 16:59:14 +010014 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ":\n" .. v:beval_text
Bram Moolenaarc79745a2019-05-20 22:12:34 +020015 endfun
16 redraw
17[CODE]
Bram Moolenaar06bd8242019-05-08 22:55:16 +020018
19func Test_balloon_eval_term()
Drew Vogelea67ba72025-05-07 22:05:17 +020020 CheckScreendump
Bram Moolenaar06bd8242019-05-08 22:55:16 +020021 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
22 " the balloon.
Bram Moolenaarc2f50542019-07-05 23:24:56 +020023 let xtra_lines =<< trim [CODE]
24 set updatetime=300
25 au CursorHold * echo 'hold fired'
26 func Trigger()
27 call test_setmouse(2, 6)
28 call feedkeys("\<MouseMove>\<Ignore>", "xt")
29 endfunc
30 [CODE]
Bram Moolenaar34112652022-09-05 21:40:44 +010031 call writefile(s:common_script + xtra_lines, 'XTest_beval', 'D')
Bram Moolenaar2f106582019-05-08 21:59:25 +020032
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})
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020035 call TermWait(buf, 50)
Bram Moolenaarc2f50542019-07-05 23:24:56 +020036 call term_sendkeys(buf, 'll')
37 call term_sendkeys(buf, ":call Trigger()\<CR>")
Yee Cheng Chine70587d2025-02-13 20:55:45 +010038 sleep 150m " Wait for balloon to show up (100ms balloondelay time)
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()
Drew Vogelea67ba72025-05-07 22:05:17 +020051 CheckScreendump
Bram Moolenaar06bd8242019-05-08 22:55:16 +020052 " 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()
Drew Vogelea67ba72025-05-07 22:05:17 +020069 CheckScreendump
zeertzjq883018f2024-06-15 15:37:11 +020070 CheckFeature rightleft
71
72 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
73 " the balloon.
74 let xtra_lines =<< trim [CODE]
75 set rightleft
76 func Trigger()
77 call test_setmouse(2, 50 + 1 - 6)
78 call feedkeys("\<MouseMove>\<Ignore>", "xt")
79 endfunc
80 [CODE]
81 call writefile(s:common_script + xtra_lines, 'XTest_beval_rl', 'D')
82
83 " Check that the balloon shows up after a mouse move
84 let buf = RunVimInTerminal('-S XTest_beval_rl', {'rows': 10, 'cols': 50})
85 call TermWait(buf, 50)
86 call term_sendkeys(buf, 'll')
87 call term_sendkeys(buf, ":call Trigger()\<CR>")
88 call VerifyScreenDump(buf, 'Test_balloon_eval_term_03', {})
89
90 " clean up
91 call StopVimInTerminal(buf)
92endfunc
93
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020094" vim: shiftwidth=2 sts=2 expandtab