Mercurial > vim
changeset 10879:1fce74a5a628 v8.0.0329
patch 8.0.0329: xfontset and guifontwide are not tested
commit https://github.com/vim/vim/commit/10434674821939222bf552d15d93e0132d13badc
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 12 19:59:08 2017 +0100
patch 8.0.0329: xfontset and guifontwide are not tested
Problem: Xfontset and guifontwide are not tested.
Solution: Add tests. (Kazunobu Kuriyama)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 12 Feb 2017 20:00:04 +0100 |
parents | cd7433f8778b |
children | 7d9d6a327e18 |
files | src/testdir/test_gui.vim src/version.c |
diffstat | 2 files changed, 144 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -131,6 +131,148 @@ func Test_set_guifont() endif endfunc +func Test_set_guifontset() + let skipped = 0 + + if has('xfontset') + let l:ctype_saved = v:ctype + + " For UTF-8 locales, XCreateFontSet(3) is likely to fail in constructing a + " fontset automatically from one or two simple XLFDs because it requires + " the host system to have a fairly comprehensive collection of fixed-width + " fonts with various sizes and registries/encodings in order to get the + " job done. To make the test meaningful for a wide variety of hosts, we + " confine ourselves to the following locale for which X11 historically has + " the fonts to use with. + language ctype ja_JP.eucJP + + " Since XCreateFontSet(3) is very sensitive to locale, fonts must be + " chosen meticulously. + let l:font_head = '-misc-fixed-medium-r-normal--14' + + let l:font_aw70 = l:font_head . '-130-75-75-c-70' + let l:font_aw140 = l:font_head . '-130-75-75-c-140' + + let l:font_jisx0201 = l:font_aw70 . '-jisx0201.1976-0' + let l:font_jisx0208 = l:font_aw140 . '-jisx0208.1983-0' + + " Full XLFDs + let l:fontset_name = join([ l:font_jisx0208, l:font_jisx0201 ], ',') + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + " XLFDs w/o CharSetRegistry and CharSetEncoding + let l:fontset_name = join([ l:font_aw140, l:font_aw70 ], ',') + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + " Singleton + let l:fontset_name = l:font_head . '-*' + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + " Aliases + let l:fontset_name = 'k14,r14' + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + exec 'language ctype' l:ctype_saved + + else + let skipped = 1 + endif + + if skipped + throw "Skipped: Not supported by this GUI" + endif +endfunc + +func Test_set_guifontwide() + let skipped = 0 + + if has('gui_gtk') + let l:guifont_saved = &guifont + let l:guifontwide_saved = &guifontwide + + let l:fc_match = exepath('fc-match') + if l:fc_match != '' + let &guifont = system('fc-match -f "%{family[0]} %{size}" monospace:size=10') + let l:wide = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=ja') + exec 'set guifontwide=' . fnameescape(l:wide) + call assert_equal(l:wide, &guifontwide) + else + let skipped = 3 + endif + + let &guifontwide = l:guifontwide_saved + let &guifont = l:guifont_saved + + elseif has('gui_athena') || has('gui_motif') + " guifontwide is premised upon the xfontset feature. + if has('xfontset') + let l:encoding_saved = &encoding + let l:guifont_saved = &guifont + let l:guifontset_saved = &guifontset + let l:guifontwide_saved = &guifontwide + + let l:nfont = '-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1' + let l:wfont = '-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1' + + set encoding=utf-8 + + " Case 1: guifontset is empty + set guifontset= + + " Case 1-1: Automatic selection + set guifontwide= + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + " Case 1-2: Manual selection + exec 'set guifontwide=' . l:wfont + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + " Case 2: guifontset is invalid + try + set guifontset=-*-notexist-* + call assert_false(1, "'set guifontset=notexist' should have failed") + catch + call assert_exception('E598') + endtry + " Set it to an invalid value brutally for preparation. + let &guifontset = '-*-notexist-*' + + " Case 2-1: Automatic selection + set guifontwide= + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + " Case 2-2: Manual selection + exec 'set guifontwide=' . l:wfont + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + let &guifontwide = l:guifontwide_saved + let &guifontset = l:guifontset_saved + let &guifont = l:guifont_saved + let &encoding = l:encoding_saved + else + let skipped = 2 + endif + else + let skipped = 1 + endif + + if skipped == 1 + throw "Skipped: Test not implemented yet for this GUI" + elseif skipped == 2 + throw "Skipped: Not supported by this GUI" + elseif skipped == 3 + throw "Skipped: Test not supported by the environment" + endif +endfunc + func Test_getwinpos() call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) call assert_true(getwinposx() >= 0)