xref: /vim-8.2.3635/src/testdir/test_balloon.vim (revision eae1b91f)
1" Tests for 'balloonevalterm'.
2
3" Tests that only work in the terminal.
4if has('balloon_eval_term') && !has('gui_running')
5
6source screendump.vim
7if !CanRunVimInTerminal()
8  finish
9endif
10
11let s:common_script = [
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	\ ]
19
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 + [
24	\ 'call test_setmouse(2, 6)',
25	\ 'call feedkeys("\<MouseMove>\<Ignore>", "xt")',
26	\ ], 'XTest_beval')
27
28  " Check that the balloon shows up after a mouse move
29  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
37
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
55
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
76