blob: 39c2602be6a33d9f6524a6ec1cb16a12c5ad9fd6 [file] [log] [blame]
Bram Moolenaar2f106582019-05-08 21:59:25 +02001" Tests for 'balloonevalterm'.
2
Bram Moolenaarbe0a2592019-05-09 13:50:16 +02003" Tests that only work in the terminal.
4if has('balloon_eval_term') && !has('gui_running')
Bram Moolenaar2f106582019-05-08 21:59:25 +02005
6source screendump.vim
7if !CanRunVimInTerminal()
8 finish
9endif
10
Bram Moolenaarc79745a2019-05-20 22:12:34 +020011let s:common_script =<< [CODE]
12 call setline(1, ["one one one", "two tXo two", "three three three"])
13 set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100
14 func MyBalloonExpr()
15 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text
16 endfun
17 redraw
18[CODE]
Bram Moolenaar06bd8242019-05-08 22:55:16 +020019
20func Test_balloon_eval_term()
21 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
22 " the balloon.
23 call writefile(s:common_script + [
Bram Moolenaar2f106582019-05-08 21:59:25 +020024 \ 'call test_setmouse(2, 6)',
25 \ 'call feedkeys("\<MouseMove>\<Ignore>", "xt")',
26 \ ], 'XTest_beval')
27
Bram Moolenaar06bd8242019-05-08 22:55:16 +020028 " Check that the balloon shows up after a mouse move
Bram Moolenaar2f106582019-05-08 21:59:25 +020029 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
30 call term_wait(buf, 100)
31 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
32
33 " clean up
34 call StopVimInTerminal(buf)
35 call delete('XTest_beval')
36endfunc
Bram Moolenaar06bd8242019-05-08 22:55:16 +020037
38func Test_balloon_eval_term_visual()
39 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
40 " the balloon.
41 call writefile(s:common_script + [
42 \ 'call test_setmouse(3, 6)',
43 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
44 \ ], 'XTest_beval_visual')
45
46 " Check that the balloon shows up after a mouse move
47 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
48 call term_wait(buf, 100)
49 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
50
51 " clean up
52 call StopVimInTerminal(buf)
53 call delete('XTest_beval_visual')
54endfunc
Bram Moolenaarbe0a2592019-05-09 13:50:16 +020055
56endif
57
58" Tests that only work in the GUI
59if has('gui_running')
60
61func Test_balloon_show_gui()
62 let msg = 'this this this this'
63 call balloon_show(msg)
64 call assert_equal(msg, balloon_gettext())
65 sleep 10m
66 call balloon_show('')
67
68 let msg = 'that that'
69 call balloon_show(msg)
70 call assert_equal(msg, balloon_gettext())
71 sleep 10m
72 call balloon_show('')
73endfunc
74
75endif