xref: /vim-8.2.3635/src/testdir/test_balloon.vim (revision b46fecd3)
1" Tests for 'balloonevalterm'.
2" A few tests only work in the terminal.
3
4if has('gui_running')
5  throw 'Skipped: only work in the terminal'
6endif
7
8source check.vim
9CheckFeature balloon_eval_term
10
11source screendump.vim
12if !CanRunVimInTerminal()
13  throw 'Skipped: cannot make screendumps'
14endif
15
16let s:common_script =<< [CODE]
17  call setline(1, ["one one one", "two tXo two", "three three three"])
18  set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100
19  func MyBalloonExpr()
20    return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text
21  endfun
22  redraw
23[CODE]
24
25func Test_balloon_eval_term()
26  " Use <Ignore> after <MouseMove> to return from vgetc() without removing
27  " the balloon.
28  call writefile(s:common_script + [
29	\ 'call test_setmouse(2, 6)',
30	\ 'call feedkeys("\<MouseMove>\<Ignore>", "xt")',
31	\ ], 'XTest_beval')
32
33  " Check that the balloon shows up after a mouse move
34  let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
35  call term_wait(buf, 100)
36  call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
37
38  " clean up
39  call StopVimInTerminal(buf)
40  call delete('XTest_beval')
41endfunc
42
43func Test_balloon_eval_term_visual()
44  " Use <Ignore> after <MouseMove> to return from vgetc() without removing
45  " the balloon.
46  call writefile(s:common_script + [
47	\ 'call test_setmouse(3, 6)',
48	\ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
49	\ ], 'XTest_beval_visual')
50
51  " Check that the balloon shows up after a mouse move
52  let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
53  call term_wait(buf, 100)
54  call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
55
56  " clean up
57  call StopVimInTerminal(buf)
58  call delete('XTest_beval_visual')
59endfunc
60