Mercurial > vim
annotate src/testdir/test_gui.vim @ 10847:881194ae47a1 v8.0.0313
patch 8.0.0313: not enough testing for GUI functionality
commit https://github.com/vim/vim/commit/6f785749db766205616fcf8438f43d1859d8f5e4
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 6 22:11:55 2017 +0100
patch 8.0.0313: not enough testing for GUI functionality
Problem: Not enough testing for GUI functionality.
Solution: Add tests for the GUI font. (Kazunobu Kuriyama)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 06 Feb 2017 22:15:03 +0100 |
parents | 5c0415a8b96e |
children | 0beffabed338 |
rev | line source |
---|---|
9756
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests specifically for the GUI |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 if !has('gui') || ($DISPLAY == "" && !has('gui_running')) |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 finish |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 endif |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
10841
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
7 let s:x11_based_gui = has('gui_athena') || has('gui_motif') |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
8 \ || has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
9 |
9756
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 " For KDE set a font, empty 'guifont' may cause a hang. |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 func SetUp() |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 if has("gui_kde") |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 set guifont=Courier\ 10\ Pitch/8/-1/5/50/0/0/0/0/0 |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 endif |
9830
6049c1f01391
commit https://github.com/vim/vim/commit/50fa8dd00c241fa0786fe92ecc02fee4e5d28e06
Christian Brabandt <cb@256bit.org>
parents:
9760
diff
changeset
|
15 |
10777
80b286d6d38d
patch 8.0.0278: GUI test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10775
diff
changeset
|
16 " Gnome insists on creating $HOME/.gnome2/, set $HOME to avoid changing the |
80b286d6d38d
patch 8.0.0278: GUI test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10775
diff
changeset
|
17 " actual home directory. But avoid triggering fontconfig by setting the |
80b286d6d38d
patch 8.0.0278: GUI test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10775
diff
changeset
|
18 " cache directory. Only needed for Unix. |
80b286d6d38d
patch 8.0.0278: GUI test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10775
diff
changeset
|
19 if $XDG_CACHE_HOME == '' && exists('g:tester_HOME') |
10775
d08655e2633a
patch 8.0.0277: the GUI test may trigger fontconfig and take a long time
Christian Brabandt <cb@256bit.org>
parents:
9830
diff
changeset
|
20 let $XDG_CACHE_HOME = g:tester_HOME . '/.cache' |
d08655e2633a
patch 8.0.0277: the GUI test may trigger fontconfig and take a long time
Christian Brabandt <cb@256bit.org>
parents:
9830
diff
changeset
|
21 endif |
9830
6049c1f01391
commit https://github.com/vim/vim/commit/50fa8dd00c241fa0786fe92ecc02fee4e5d28e06
Christian Brabandt <cb@256bit.org>
parents:
9760
diff
changeset
|
22 call mkdir('Xhome') |
6049c1f01391
commit https://github.com/vim/vim/commit/50fa8dd00c241fa0786fe92ecc02fee4e5d28e06
Christian Brabandt <cb@256bit.org>
parents:
9760
diff
changeset
|
23 let $HOME = fnamemodify('Xhome', ':p') |
6049c1f01391
commit https://github.com/vim/vim/commit/50fa8dd00c241fa0786fe92ecc02fee4e5d28e06
Christian Brabandt <cb@256bit.org>
parents:
9760
diff
changeset
|
24 endfunc |
6049c1f01391
commit https://github.com/vim/vim/commit/50fa8dd00c241fa0786fe92ecc02fee4e5d28e06
Christian Brabandt <cb@256bit.org>
parents:
9760
diff
changeset
|
25 |
6049c1f01391
commit https://github.com/vim/vim/commit/50fa8dd00c241fa0786fe92ecc02fee4e5d28e06
Christian Brabandt <cb@256bit.org>
parents:
9760
diff
changeset
|
26 func TearDown() |
6049c1f01391
commit https://github.com/vim/vim/commit/50fa8dd00c241fa0786fe92ecc02fee4e5d28e06
Christian Brabandt <cb@256bit.org>
parents:
9760
diff
changeset
|
27 call delete('Xhome', 'rf') |
9756
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 endfunc |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 " Test for resetting "secure" flag after GUI has started. |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 " Must be run first. |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 func Test_1_set_secure() |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 set exrc secure |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 gui -f |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call assert_equal(1, has('gui_running')) |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 endfunc |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
10847
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
38 func Test_getfontname_with_arg() |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
39 if has('gui_athena') || has('gui_motif') |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
40 " Invalid font name. The result should be an empty string. |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
41 call assert_equal('', getfontname('notexist')) |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
42 |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
43 " Valid font name. This is usually the real name of 7x13 by default. |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
44 let l:fname = '-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO10646-1' |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
45 call assert_equal(l:fname, getfontname(l:fname)) |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
46 |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
47 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
48 " Invalid font name. The result should be the name plus the default size. |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
49 call assert_equal('notexist 10', getfontname('notexist')) |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
50 |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
51 " Valid font name. This is usually the real name of Monospace by default. |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
52 let l:fname = 'Bitstream Vera Sans Mono 12' |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
53 call assert_equal(l:fname, getfontname(l:fname)) |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
54 else |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
55 throw "Skipped: Matched font name unpredictable to test on this GUI" |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
56 endif |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
57 endfunc |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
58 |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
59 func Test_getfontname_without_arg() |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
60 let l:fname = getfontname() |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
61 if has('gui_kde') |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
62 " 'expected' is the value specified by SetUp() above. |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
63 call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', l:fname) |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
64 elseif has('gui_athena') || has('gui_motif') |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
65 " 'expected' is DFLT_FONT of gui_x11.c. |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
66 call assert_equal('7x13', l:fname) |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
67 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
68 " 'expected' is DEFAULT_FONT of gui_gtk_x11.c. |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
69 call assert_equal('Monospace 10', l:fname) |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
70 else |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
71 throw "Skipped: Default font name unpredictable to test on this GUI" |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
72 endif |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
73 endfunc |
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
74 |
10841
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
75 func Test_getwinpos() |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
76 call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
77 call assert_true(getwinposx() >= 0) |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
78 call assert_true(getwinposy() >= 0) |
10847
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
79 endfunc |
10841
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
80 |
9756
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 func Test_shell_command() |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 new |
9760
96667173293d
commit https://github.com/vim/vim/commit/9d5b876d458e242b8b5e44da10c5cdc6bbb7f57c
Christian Brabandt <cb@256bit.org>
parents:
9756
diff
changeset
|
83 r !echo hello |
96667173293d
commit https://github.com/vim/vim/commit/9d5b876d458e242b8b5e44da10c5cdc6bbb7f57c
Christian Brabandt <cb@256bit.org>
parents:
9756
diff
changeset
|
84 call assert_equal('hello', substitute(getline(2), '\W', '', 'g')) |
9756
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 bwipe! |
00d753ea19a9
commit https://github.com/vim/vim/commit/877e95779869c5426102aa491f67d99904c8534c
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 endfunc |
10841
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
87 |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
88 func Test_windowid_variable() |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
89 if s:x11_based_gui || has('win32') |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
90 call assert_true(v:windowid > 0) |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
91 else |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
92 call assert_equal(0, v:windowid) |
5c0415a8b96e
patch 8.0.0310: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10777
diff
changeset
|
93 endif |
10847
881194ae47a1
patch 8.0.0313: not enough testing for GUI functionality
Christian Brabandt <cb@256bit.org>
parents:
10841
diff
changeset
|
94 endfunc |