diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-02-12 19:59:08 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-02-12 19:59:08 +0100 |
commit | 10434674821939222bf552d15d93e0132d13badc (patch) | |
tree | a511d4b24efafb78e8f5bc40a441d637087dcbd0 | |
parent | 23a5558cfd860401aa694f0302d621887440f031 (diff) |
patch 8.0.0329: xfontset and guifontwide are not testedv8.0.0329
Problem: Xfontset and guifontwide are not tested.
Solution: Add tests. (Kazunobu Kuriyama)
-rw-r--r-- | src/testdir/test_gui.vim | 142 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 144 insertions, 0 deletions
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 283b0ccb89..49bc02658f 100644 --- 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) diff --git a/src/version.c b/src/version.c index 08d377d0c2..9073c07dc8 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 329, +/**/ 328, /**/ 327, |