annotate src/testdir/test_balloon.vim @ 16720:9c90cf08cfa8 v8.1.1362

patch 8.1.1362: code and data in tests can be hard to read commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 20 22:12:34 2019 +0200 patch 8.1.1362: code and data in tests can be hard to read Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 May 2019 22:15:06 +0200
parents ff3c99bd1038
children ebdf6cd89910
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for 'balloonevalterm'.
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
3 " Tests that only work in the terminal.
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
4 if has('balloon_eval_term') && !has('gui_running')
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 source screendump.vim
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 if !CanRunVimInTerminal()
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 finish
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 endif
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
11 let s:common_script =<< [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
12 call setline(1, ["one one one", "two tXo two", "three three three"])
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
13 set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
14 func MyBalloonExpr()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
15 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
16 endfun
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
17 redraw
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
18 [CODE]
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
19
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
20 func Test_balloon_eval_term()
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
21 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
22 " the balloon.
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
23 call writefile(s:common_script + [
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 \ 'call test_setmouse(2, 6)',
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 \ 'call feedkeys("\<MouseMove>\<Ignore>", "xt")',
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 \ ], 'XTest_beval')
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
28 " Check that the balloon shows up after a mouse move
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 call term_wait(buf, 100)
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 " clean up
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call StopVimInTerminal(buf)
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 call delete('XTest_beval')
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 endfunc
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
37
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
38 func Test_balloon_eval_term_visual()
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
39 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
40 " the balloon.
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
41 call writefile(s:common_script + [
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
42 \ 'call test_setmouse(3, 6)',
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
43 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
44 \ ], 'XTest_beval_visual')
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
45
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
46 " Check that the balloon shows up after a mouse move
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
47 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
48 call term_wait(buf, 100)
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
49 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
50
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
51 " clean up
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
52 call StopVimInTerminal(buf)
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
53 call delete('XTest_beval_visual')
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
54 endfunc
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
55
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
56 endif
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
57
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
58 " Tests that only work in the GUI
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
59 if has('gui_running')
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
60
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
61 func Test_balloon_show_gui()
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
62 let msg = 'this this this this'
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
63 call balloon_show(msg)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
64 call assert_equal(msg, balloon_gettext())
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
65 sleep 10m
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
66 call balloon_show('')
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
67
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
68 let msg = 'that that'
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
69 call balloon_show(msg)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
70 call assert_equal(msg, balloon_gettext())
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
71 sleep 10m
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
72 call balloon_show('')
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
73 endfunc
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
74
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16598
diff changeset
75 endif