xref: /vim-8.2.3635/src/testdir/test_balloon.vim (revision a7c4e747)
1" Tests for 'balloonevalterm'.
2" A few tests only work in the terminal.
3
4source check.vim
5CheckNotGui
6CheckFeature balloon_eval_term
7
8source screendump.vim
9CheckScreendump
10
11let s:common_script =<< trim [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 .. ":\n" .. v:beval_text
16  endfun
17  redraw
18[CODE]
19
20func Test_balloon_eval_term()
21  " Use <Ignore> after <MouseMove> to return from vgetc() without removing
22  " the balloon.
23  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]
31  call writefile(s:common_script + xtra_lines, '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 TermWait(buf, 50)
36  call term_sendkeys(buf, 'll')
37  call term_sendkeys(buf, ":call Trigger()\<CR>")
38  call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
39
40  " Make sure the balloon still shows after 'updatetime' passed and CursorHold
41  " was triggered.
42  call TermWait(buf, 150)
43  call VerifyScreenDump(buf, 'Test_balloon_eval_term_01a', {})
44
45  " clean up
46  call StopVimInTerminal(buf)
47  call delete('XTest_beval')
48endfunc
49
50func Test_balloon_eval_term_visual()
51  " Use <Ignore> after <MouseMove> to return from vgetc() without removing
52  " the balloon.
53  call writefile(s:common_script + [
54	\ 'call test_setmouse(3, 6)',
55	\ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
56	\ ], 'XTest_beval_visual')
57
58  " Check that the balloon shows up after a mouse move
59  let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
60  call TermWait(buf, 50)
61  call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
62
63  " clean up
64  call StopVimInTerminal(buf)
65  call delete('XTest_beval_visual')
66endfunc
67
68" vim: shiftwidth=2 sts=2 expandtab
69