Skip to content

Commit 43dded8

Browse files
committed
patch 8.0.0317: no test for setting 'guifont'
Problem: No test for setting 'guifont'. Solution: Add a test for X11 GUIs. (Kazunobu Kuriyama)
1 parent dad7309 commit 43dded8

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/testdir/test_gui.vim

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,65 @@ func Test_getfontname_without_arg()
7272
endif
7373
endfunc
7474

75+
func Test_set_guifont()
76+
let l:guifont_saved = &guifont
77+
if has('xfontset')
78+
" Prevent 'guifontset' from canceling 'guifont'.
79+
let l:guifontset_saved = &guifontset
80+
set guifontset=
81+
endif
82+
83+
let skipped = 0
84+
if has('gui_athena') || has('gui_motif')
85+
" Non-empty font list with invalid font names.
86+
"
87+
" This test is twofold: (1) It checks if the command fails as expected
88+
" when there are no loadable fonts found in the list. (2) It checks if
89+
" 'guifont' remains the same after the command loads none of the fonts
90+
" listed.
91+
let l:flist = &guifont
92+
call assert_fails('set guifont=-notexist1-*,-notexist2-*')
93+
call assert_equal(l:flist, &guifont)
94+
95+
" Non-empty font list with a valid font name. Should pick up the first
96+
" valid font.
97+
set guifont=-notexist1-*,fixed,-notexist2-*
98+
call assert_equal('fixed', getfontname())
99+
100+
" Empty list. Should fallback to the built-in default.
101+
set guifont=
102+
call assert_equal('7x13', getfontname())
103+
104+
elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
105+
" For GTK, what we refer to as 'font names' in our manual are actually
106+
" 'initial font patterns'. A valid font which matches the 'canonical font
107+
" pattern' constructed from a given 'initial pattern' is to be looked up
108+
" and loaded. That explains why the GTK GUIs appear to accept 'invalid
109+
" font names'.
110+
"
111+
" Non-empty list. Should always pick up the first element, no matter how
112+
" strange it is, as explained above.
113+
set guifont=(´・ω・`)\ 12,Courier\ 12
114+
call assert_equal('(´・ω・`) 12', getfontname())
115+
116+
" Empty list. Should fallback to the built-in default.
117+
set guifont=
118+
call assert_equal('Monospace 10', getfontname())
119+
120+
else
121+
let skipped = 1
122+
endif
123+
124+
if has('xfontset')
125+
let &guifontset = l:guifontset_saved
126+
endif
127+
let &guifont = l:guifont_saved
128+
129+
if skipped
130+
throw "Skipped: Test not implemented yet for this GUI"
131+
endif
132+
endfunc
133+
75134
func Test_getwinpos()
76135
call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
77136
call assert_true(getwinposx() >= 0)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
317,
767769
/**/
768770
316,
769771
/**/

0 commit comments

Comments
 (0)