blob: 1a9e2258d75cd440ec9dba8be1e97ae996c62d2f [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 Moolenaar2f106582019-05-08 21:59:25 +02009
Bram Moolenaare7eb9272019-06-24 00:58:07 +020010let s:common_script =<< trim [CODE]
Bram Moolenaarc79745a2019-05-20 22:12:34 +020011 call setline(1, ["one one one", "two tXo two", "three three three"])
Bram Moolenaar5600a702022-01-22 15:09:36 +000012 set balloonevalterm balloonexpr=MyBalloonExpr()..s:trailing balloondelay=100
13 let s:trailing = '<' " check that script context is set
Bram Moolenaarc79745a2019-05-20 22:12:34 +020014 func MyBalloonExpr()
Bram Moolenaard1c1c822019-11-09 16:59:14 +010015 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ":\n" .. v:beval_text
Bram Moolenaarc79745a2019-05-20 22:12:34 +020016 endfun
17 redraw
18[CODE]
Bram Moolenaar06bd8242019-05-08 22:55:16 +020019
20func Test_balloon_eval_term()
Drew Vogelea67ba72025-05-07 22:05:17 +020021 CheckScreendump
Bram Moolenaar06bd8242019-05-08 22:55:16 +020022 " 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()
Drew Vogelea67ba72025-05-07 22:05:17 +020052 CheckScreendump
Bram Moolenaar06bd8242019-05-08 22:55:16 +020053 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
54 " the balloon.
55 call writefile(s:common_script + [
56 \ 'call test_setmouse(3, 6)',
57 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
Bram Moolenaar34112652022-09-05 21:40:44 +010058 \ ], 'XTest_beval_visual', 'D')
Bram Moolenaar06bd8242019-05-08 22:55:16 +020059
60 " Check that the balloon shows up after a mouse move
61 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020062 call TermWait(buf, 50)
Bram Moolenaar06bd8242019-05-08 22:55:16 +020063 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
64
65 " clean up
66 call StopVimInTerminal(buf)
Bram Moolenaar06bd8242019-05-08 22:55:16 +020067endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020068
zeertzjq883018f2024-06-15 15:37:11 +020069func Test_balloon_eval_term_rightleft()
Drew Vogelea67ba72025-05-07 22:05:17 +020070 CheckScreendump
zeertzjq883018f2024-06-15 15:37:11 +020071 CheckFeature rightleft
72
73 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
74 " the balloon.
75 let xtra_lines =<< trim [CODE]
76 set rightleft
77 func Trigger()
78 call test_setmouse(2, 50 + 1 - 6)
79 call feedkeys("\<MouseMove>\<Ignore>", "xt")
80 endfunc
81 [CODE]
82 call writefile(s:common_script + xtra_lines, 'XTest_beval_rl', 'D')
83
84 " Check that the balloon shows up after a mouse move
85 let buf = RunVimInTerminal('-S XTest_beval_rl', {'rows': 10, 'cols': 50})
86 call TermWait(buf, 50)
87 call term_sendkeys(buf, 'll')
88 call term_sendkeys(buf, ":call Trigger()\<CR>")
89 call VerifyScreenDump(buf, 'Test_balloon_eval_term_03', {})
90
91 " clean up
92 call StopVimInTerminal(buf)
93endfunc
94
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020095" vim: shiftwidth=2 sts=2 expandtab