annotate src/testdir/screendump.vim @ 13331:1ba4f926247c v8.0.1540

patch 8.0.1540: popup menu positioning fails with longer string commit https://github.com/vim/vim/commit/2b10bcbfc1c025bf7e6358326ee70105e7d30e96 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 24 21:25:44 2018 +0100 patch 8.0.1540: popup menu positioning fails with longer string Problem: Popup menu positioning fails with longer string. Solution: Only align with right side of window when width is less than 'pumwidth' (closes #2661)
author Christian Brabandt <cb@256bit.org>
date Sat, 24 Feb 2018 21:30:05 +0100
parents 424321d6eea7
children eb960e9c75c8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Functions shared by tests making screen dumps.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Only load this script once.
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
4 if exists('*CanRunVimInTerminal')
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 finish
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endif
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
8 " Need to be able to run terminal Vim with 256 colors. On MS-Windows the
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
9 " console only has 16 colors and the GUI can't run in a terminal.
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
10 if !has('terminal') || has('win32')
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
11 func CanRunVimInTerminal()
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
12 return 0
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
13 endfunc
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
14 finish
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
15 endif
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
16
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
17 func CanRunVimInTerminal()
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
18 return 1
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
19 endfunc
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
20
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 source shared.vim
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 " Run Vim with "arguments" in a new terminal window.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 " By default uses a size of 20 lines and 75 columns.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 " Returns the buffer number of the terminal.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 "
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 " Options is a dictionary (not used yet).
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 func RunVimInTerminal(arguments, options)
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 " Make a horizontal and vertical split, so that we can get exactly the right
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 " size terminal window. Works only when we currently have one window.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal(1, winnr('$'))
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 split
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 vsplit
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
13322
0dc2e4998a15 patch 8.0.1535: C syntax test still fails when using gvim
Christian Brabandt <cb@256bit.org>
parents: 13320
diff changeset
35 " Always do this with 256 colors and a light background.
0dc2e4998a15 patch 8.0.1535: C syntax test still fails when using gvim
Christian Brabandt <cb@256bit.org>
parents: 13320
diff changeset
36 set t_Co=256 background=light
0dc2e4998a15 patch 8.0.1535: C syntax test still fails when using gvim
Christian Brabandt <cb@256bit.org>
parents: 13320
diff changeset
37 hi Normal ctermfg=NONE ctermbg=NONE
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 let cmd = GetVimCommandClean()
13320
a90063ec1cd6 patch 8.0.1534: C syntax test fails when using gvim
Christian Brabandt <cb@256bit.org>
parents: 13304
diff changeset
40 " Add -v to have gvim run in the terminal (if possible)
a90063ec1cd6 patch 8.0.1534: C syntax test fails when using gvim
Christian Brabandt <cb@256bit.org>
parents: 13304
diff changeset
41 let cmd .= ' -v ' . a:arguments
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 let buf = term_start(cmd, {'curwin': 1, 'term_rows': 20, 'term_cols': 75})
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal([20, 75], term_getsize(buf))
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 return buf
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 endfunc
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 " Stop a Vim running in terminal buffer "buf".
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 func StopVimInTerminal(buf)
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_equal("running", term_getstatus(a:buf))
13331
1ba4f926247c patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents: 13329
diff changeset
51 call term_sendkeys(a:buf, "\<Esc>\<Esc>:qa!\<cr>")
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call WaitFor('term_getstatus(' . a:buf . ') == "finished"')
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 only!
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 endfunc
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 " Verify that Vim running in terminal buffer "buf" matches the screen dump.
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
57 " "options" is passed to term_dumpwrite().
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 " The file name used is "dumps/{filename}.dump".
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 " Will wait for up to a second for the screen dump to match.
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
60 func VerifyScreenDump(buf, filename, options)
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 let reference = 'dumps/' . a:filename . '.dump'
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 let testfile = a:filename . '.dump.failed'
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 let i = 0
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 while 1
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call delete(testfile)
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
67 call term_dumpwrite(a:buf, testfile, a:options)
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 if readfile(reference) == readfile(testfile)
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call delete(testfile)
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 break
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 endif
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 if i == 100
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 " Leave the test file around for inspection.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call assert_report('See dump file difference: call term_dumpdiff("' . testfile . '", "' . reference . '")')
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 break
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 endif
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 sleep 10m
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 let i += 1
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 endwhile
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 endfunc