Mercurial > vim
comparison src/testdir/test_gui.vim @ 10944:4e2cdce4576c v8.0.0361
patch 8.0.0361: GUI initialisation is not sufficiently tested
commit https://github.com/vim/vim/commit/8be2fbb6705dfb41d06d688701803d206c968404
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 23 19:32:47 2017 +0100
patch 8.0.0361: GUI initialisation is not sufficiently tested
Problem: GUI initialisation is not sufficiently tested.
Solution: Add the gui_init test. (Kazuki Kuriyama)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 23 Feb 2017 19:45:04 +0100 |
parents | 310834b0256a |
children | 488cda29455b |
comparison
equal
deleted
inserted
replaced
10943:02654bf3c3f6 | 10944:4e2cdce4576c |
---|---|
2 | 2 |
3 if !has('gui') || ($DISPLAY == "" && !has('gui_running')) | 3 if !has('gui') || ($DISPLAY == "" && !has('gui_running')) |
4 finish | 4 finish |
5 endif | 5 endif |
6 | 6 |
7 let s:x11_based_gui = has('gui_athena') || has('gui_motif') | 7 source setup_gui.vim |
8 \ || has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') | 8 |
9 | 9 func Setup() |
10 " Reasons for 'skipped'. | 10 call GUISetUpCommon() |
11 let s:not_supported = "Skipped: Feature/Option not supported by this GUI: " | |
12 let s:not_implemented = "Skipped: Test not implemented yet for this GUI" | |
13 let s:not_hosted = "Skipped: Test not hosted by the system/environment" | |
14 | |
15 " For KDE set a font, empty 'guifont' may cause a hang. | |
16 func SetUp() | |
17 if has("gui_kde") | |
18 set guifont=Courier\ 10\ Pitch/8/-1/5/50/0/0/0/0/0 | |
19 endif | |
20 | |
21 " Gnome insists on creating $HOME/.gnome2/, set $HOME to avoid changing the | |
22 " actual home directory. But avoid triggering fontconfig by setting the | |
23 " cache directory. Only needed for Unix. | |
24 if $XDG_CACHE_HOME == '' && exists('g:tester_HOME') | |
25 let $XDG_CACHE_HOME = g:tester_HOME . '/.cache' | |
26 endif | |
27 call mkdir('Xhome') | |
28 let $HOME = fnamemodify('Xhome', ':p') | |
29 endfunc | 11 endfunc |
30 | 12 |
31 func TearDown() | 13 func TearDown() |
32 call delete('Xhome', 'rf') | 14 call GUITearDownCommon() |
33 endfunc | 15 endfunc |
34 | 16 |
35 " Test for resetting "secure" flag after GUI has started. | 17 " Test for resetting "secure" flag after GUI has started. |
36 " Must be run first. | 18 " Must be run first. |
37 func Test_1_set_secure() | 19 func Test_1_set_secure() |
41 endfunc | 23 endfunc |
42 | 24 |
43 func Test_getfontname_with_arg() | 25 func Test_getfontname_with_arg() |
44 let skipped = '' | 26 let skipped = '' |
45 | 27 |
46 if !s:x11_based_gui | 28 if !g:x11_based_gui |
47 let skipped = s:not_implemented | 29 let skipped = g:not_implemented |
48 elseif has('gui_athena') || has('gui_motif') | 30 elseif has('gui_athena') || has('gui_motif') |
49 " Invalid font name. The result should be an empty string. | 31 " Invalid font name. The result should be an empty string. |
50 call assert_equal('', getfontname('notexist')) | 32 call assert_equal('', getfontname('notexist')) |
51 | 33 |
52 " Valid font name. This is usually the real name of 7x13 by default. | 34 " Valid font name. This is usually the real name of 7x13 by default. |
70 func Test_getfontname_without_arg() | 52 func Test_getfontname_without_arg() |
71 let skipped = '' | 53 let skipped = '' |
72 | 54 |
73 let fname = getfontname() | 55 let fname = getfontname() |
74 | 56 |
75 if !s:x11_based_gui | 57 if !g:x11_based_gui |
76 let skipped = s:not_implemented | 58 let skipped = g:not_implemented |
77 elseif has('gui_kde') | 59 elseif has('gui_kde') |
78 " 'expected' is the value specified by SetUp() above. | 60 " 'expected' is the value specified by SetUp() above. |
79 call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname) | 61 call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname) |
80 elseif has('gui_athena') || has('gui_motif') | 62 elseif has('gui_athena') || has('gui_motif') |
81 " 'expected' is DFLT_FONT of gui_x11.c. | 63 " 'expected' is DFLT_FONT of gui_x11.c. |
98 " Prevent 'guifontset' from canceling 'guifont'. | 80 " Prevent 'guifontset' from canceling 'guifont'. |
99 let guifontset_saved = &guifontset | 81 let guifontset_saved = &guifontset |
100 set guifontset= | 82 set guifontset= |
101 endif | 83 endif |
102 | 84 |
103 if !s:x11_based_gui | 85 if !g:x11_based_gui |
104 let skipped = s:not_implemented | 86 let skipped = g:not_implemented |
105 elseif has('gui_athena') || has('gui_motif') | 87 elseif has('gui_athena') || has('gui_motif') |
106 " Non-empty font list with invalid font names. | 88 " Non-empty font list with invalid font names. |
107 " | 89 " |
108 " This test is twofold: (1) It checks if the command fails as expected | 90 " This test is twofold: (1) It checks if the command fails as expected |
109 " when there are no loadable fonts found in the list. (2) It checks if | 91 " when there are no loadable fonts found in the list. (2) It checks if |
151 | 133 |
152 func Test_set_guifontset() | 134 func Test_set_guifontset() |
153 let skipped = '' | 135 let skipped = '' |
154 | 136 |
155 if !has('xfontset') | 137 if !has('xfontset') |
156 let skipped = s:not_supported . 'xfontset' | 138 let skipped = g:not_supported . 'xfontset' |
157 else | 139 else |
158 let ctype_saved = v:ctype | 140 let ctype_saved = v:ctype |
159 | 141 |
160 " First, since XCreateFontSet(3) is very sensitive to locale, fonts must | 142 " First, since XCreateFontSet(3) is very sensitive to locale, fonts must |
161 " be chosen meticulously. | 143 " be chosen meticulously. |
200 endif | 182 endif |
201 endfor | 183 endfor |
202 | 184 |
203 " Third, give a set of tests if it is found feasible. | 185 " Third, give a set of tests if it is found feasible. |
204 if !feasible | 186 if !feasible |
205 let skipped = s:not_hosted | 187 let skipped = g:not_hosted |
206 else | 188 else |
207 " N.B. 'v:ctype' has already been set to an appropriate value in the | 189 " N.B. 'v:ctype' has already been set to an appropriate value in the |
208 " previous loop. | 190 " previous loop. |
209 for fontset in fontsets | 191 for fontset in fontsets |
210 exec 'set guifontset=' . fontset | 192 exec 'set guifontset=' . fontset |
222 endfunc | 204 endfunc |
223 | 205 |
224 func Test_set_guifontwide() | 206 func Test_set_guifontwide() |
225 let skipped = '' | 207 let skipped = '' |
226 | 208 |
227 if !s:x11_based_gui | 209 if !g:x11_based_gui |
228 let skipped = s:not_implemented | 210 let skipped = g:not_implemented |
229 elseif has('gui_gtk') | 211 elseif has('gui_gtk') |
230 let guifont_saved = &guifont | 212 let guifont_saved = &guifont |
231 let guifontwide_saved = &guifontwide | 213 let guifontwide_saved = &guifontwide |
232 | 214 |
233 let fc_match = exepath('fc-match') | 215 let fc_match = exepath('fc-match') |
234 if empty(fc_match) | 216 if empty(fc_match) |
235 let skipped = s:not_hosted | 217 let skipped = g:not_hosted |
236 else | 218 else |
237 let &guifont = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=en') | 219 let &guifont = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=en') |
238 let wide = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=ja') | 220 let wide = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=ja') |
239 exec 'set guifontwide=' . fnameescape(wide) | 221 exec 'set guifontwide=' . fnameescape(wide) |
240 call assert_equal(wide, &guifontwide) | 222 call assert_equal(wide, &guifontwide) |
244 let &guifont = guifont_saved | 226 let &guifont = guifont_saved |
245 | 227 |
246 elseif has('gui_athena') || has('gui_motif') | 228 elseif has('gui_athena') || has('gui_motif') |
247 " guifontwide is premised upon the xfontset feature. | 229 " guifontwide is premised upon the xfontset feature. |
248 if !has('xfontset') | 230 if !has('xfontset') |
249 let skipped = s:not_supported . 'xfontset' | 231 let skipped = g:not_supported . 'xfontset' |
250 else | 232 else |
251 let encoding_saved = &encoding | 233 let encoding_saved = &encoding |
252 let guifont_saved = &guifont | 234 let guifont_saved = &guifont |
253 let guifontset_saved = &guifontset | 235 let guifontset_saved = &guifontset |
254 let guifontwide_saved = &guifontwide | 236 let guifontwide_saved = &guifontwide |
301 if !empty(skipped) | 283 if !empty(skipped) |
302 throw skipped | 284 throw skipped |
303 endif | 285 endif |
304 endfunc | 286 endfunc |
305 | 287 |
288 func Test_set_guiheadroom() | |
289 let skipped = '' | |
290 | |
291 if !g:x11_based_gui | |
292 let skipped = g:not_supported . 'guiheadroom' | |
293 else | |
294 " Since this script is to be read together with '-U NONE', the default | |
295 " value must be preserved. | |
296 call assert_equal(50, &guiheadroom) | |
297 endif | |
298 | |
299 if !empty(skipped) | |
300 throw skipped | |
301 endif | |
302 endfunc | |
303 | |
306 func Test_getwinpos() | 304 func Test_getwinpos() |
307 call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) | 305 call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) |
308 call assert_true(getwinposx() >= 0) | 306 call assert_true(getwinposx() >= 0) |
309 call assert_true(getwinposy() >= 0) | 307 call assert_true(getwinposy() >= 0) |
310 endfunc | 308 endfunc |
315 call assert_equal('hello', substitute(getline(2), '\W', '', 'g')) | 313 call assert_equal('hello', substitute(getline(2), '\W', '', 'g')) |
316 bwipe! | 314 bwipe! |
317 endfunc | 315 endfunc |
318 | 316 |
319 func Test_windowid_variable() | 317 func Test_windowid_variable() |
320 if s:x11_based_gui || has('win32') | 318 if g:x11_based_gui || has('win32') |
321 call assert_true(v:windowid > 0) | 319 call assert_true(v:windowid > 0) |
322 else | 320 else |
323 call assert_equal(0, v:windowid) | 321 call assert_equal(0, v:windowid) |
324 endif | 322 endif |
325 endfunc | 323 endfunc |