comparison src/testdir/test_gui.vim @ 11119:d8a550329a97 v8.0.0447

patch 8.0.0447: getting font name does not work on X11 commit https://github.com/vim/vim/commit/8774845ce1a7def122ea07c057a79417f3be3d17 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 12 17:10:33 2017 +0100 patch 8.0.0447: getting font name does not work on X11 Problem: Getting font name does not work on X11. Solution: Implement gui_mch_get_fontname() for X11. Add more GUI tests. (Kazunobu Kuriyama)
author Christian Brabandt <cb@256bit.org>
date Sun, 12 Mar 2017 17:15:04 +0100
parents 975f54a391ec
children 1c4ebbae41d2
comparison
equal deleted inserted replaced
11118:9204ebc311d4 11119:d8a550329a97
28 " This won't do anything but must not crash either. 28 " This won't do anything but must not crash either.
29 call balloon_show('hi!') 29 call balloon_show('hi!')
30 endif 30 endif
31 endfunc 31 endfunc
32 32
33 func Test_colorscheme()
34 let colorscheme_saved = exists('g:colors_name') ? g:colors_name : 'default'
35
36 colorscheme torte
37 redraw!
38 sleep 200m
39 call assert_equal('dark', &background)
40
41 exec 'colorscheme' colorscheme_saved
42 redraw!
43 endfunc
44
33 func Test_getfontname_with_arg() 45 func Test_getfontname_with_arg()
34 let skipped = '' 46 let skipped = ''
35 47
36 if !g:x11_based_gui 48 if !g:x11_based_gui
37 let skipped = g:not_implemented 49 let skipped = g:not_implemented
38 elseif has('gui_athena') || has('gui_motif') 50 elseif has('gui_athena') || has('gui_motif')
39 " Invalid font name. The result should be an empty string. 51 " Invalid font name. The result should be an empty string.
40 call assert_equal('', getfontname('notexist')) 52 call assert_equal('', getfontname('notexist'))
41 53
42 " Valid font name. This is usually the real name of 7x13 by default. 54 " Valid font name. This is usually the real name of 7x13 by default.
43 let fname = '-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-1' 55 let fname = '-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1'
44 call assert_equal(fname, getfontname(fname)) 56 call assert_match(fname, getfontname(fname))
45 57
46 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') 58 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
47 " Invalid font name. The result should be the name plus the default size. 59 " Invalid font name. The result should be the name plus the default size.
48 call assert_equal('notexist 10', getfontname('notexist')) 60 call assert_equal('notexist 10', getfontname('notexist'))
49 61
66 let skipped = g:not_implemented 78 let skipped = g:not_implemented
67 elseif has('gui_kde') 79 elseif has('gui_kde')
68 " 'expected' is the value specified by SetUp() above. 80 " 'expected' is the value specified by SetUp() above.
69 call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname) 81 call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname)
70 elseif has('gui_athena') || has('gui_motif') 82 elseif has('gui_athena') || has('gui_motif')
71 " 'expected' is DFLT_FONT of gui_x11.c. 83 " 'expected' is DFLT_FONT of gui_x11.c or its real name.
72 call assert_equal('7x13', fname) 84 let pat = '\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)'
85 call assert_match(pat, fname)
73 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') 86 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
74 " 'expected' is DEFAULT_FONT of gui_gtk_x11.c. 87 " 'expected' is DEFAULT_FONT of gui_gtk_x11.c.
75 call assert_equal('Monospace 10', fname) 88 call assert_equal('Monospace 10', fname)
76 endif 89 endif
77 90
78 if !empty(skipped) 91 if !empty(skipped)
79 throw skipped 92 throw skipped
80 endif 93 endif
94 endfunc
95
96 func Test_getwinpos()
97 call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
98 call assert_true(getwinposx() >= 0)
99 call assert_true(getwinposy() >= 0)
81 endfunc 100 endfunc
82 101
83 func Test_quoteplus() 102 func Test_quoteplus()
84 let skipped = '' 103 let skipped = ''
85 104
121 endif 140 endif
122 141
123 if !empty(skipped) 142 if !empty(skipped)
124 throw skipped 143 throw skipped
125 endif 144 endif
145 endfunc
146
147 func Test_set_background()
148 let background_saved = &background
149
150 set background&
151 call assert_equal('light', &background)
152
153 set background=dark
154 call assert_equal('dark', &background)
155
156 let &background = background_saved
126 endfunc 157 endfunc
127 158
128 func Test_set_balloondelay() 159 func Test_set_balloondelay()
129 if !exists('+balloondelay') 160 if !exists('+balloondelay')
130 return 161 return
246 endif 277 endif
247 278
248 let &balloonexpr = balloonexpr_saved 279 let &balloonexpr = balloonexpr_saved
249 endfunc 280 endfunc
250 281
282 " Invalid arguments are tested with test_options in conjunction with segfaults
283 " caused by them (Patch 8.0.0357, 24922ec233).
284 func Test_set_guicursor()
285 let guicursor_saved = &guicursor
286
287 let default = [
288 \ "n-v-c:block-Cursor/lCursor",
289 \ "ve:ver35-Cursor",
290 \ "o:hor50-Cursor",
291 \ "i-ci:ver25-Cursor/lCursor",
292 \ "r-cr:hor20-Cursor/lCursor",
293 \ "sm:block-Cursor-blinkwait175-blinkoff150-blinkon175"
294 \ ]
295
296 " Default Value
297 set guicursor&
298 call assert_equal(join(default, ','), &guicursor)
299
300 " Argument List Example 1
301 let opt_list = copy(default)
302 let opt_list[0] = "n-c-v:block-nCursor"
303 exec "set guicursor=" . join(opt_list, ',')
304 call assert_equal(join(opt_list, ','), &guicursor)
305 unlet opt_list
306
307 " Argument List Example 2
308 let opt_list = copy(default)
309 let opt_list[3] = "i-ci:ver30-iCursor-blinkwait300-blinkon200-blinkoff150"
310 exec "set guicursor=" . join(opt_list, ',')
311 call assert_equal(join(opt_list, ','), &guicursor)
312 unlet opt_list
313
314 " 'a' Mode
315 set guicursor&
316 let &guicursor .= ',a:blinkon0'
317 call assert_equal(join(default, ',') . ",a:blinkon0", &guicursor)
318
319 let &guicursor = guicursor_saved
320 endfunc
321
251 func Test_set_guifont() 322 func Test_set_guifont()
252 let skipped = '' 323 let skipped = ''
253 324
254 let guifont_saved = &guifont 325 let guifont_saved = &guifont
255 if has('xfontset') 326 if has('xfontset')
272 call assert_equal(flist, &guifont) 343 call assert_equal(flist, &guifont)
273 344
274 " Non-empty font list with a valid font name. Should pick up the first 345 " Non-empty font list with a valid font name. Should pick up the first
275 " valid font. 346 " valid font.
276 set guifont=-notexist1-*,fixed,-notexist2-* 347 set guifont=-notexist1-*,fixed,-notexist2-*
277 call assert_equal('fixed', getfontname()) 348 let pat = '\(fixed\)\|\(\c-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO8859-1\)'
349 call assert_match(pat, getfontname())
278 350
279 " Empty list. Should fallback to the built-in default. 351 " Empty list. Should fallback to the built-in default.
280 set guifont= 352 set guifont=
281 call assert_equal('7x13', getfontname()) 353 let pat = '\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)'
354 call assert_match(pat, getfontname())
282 355
283 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') 356 elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
284 " For GTK, what we refer to as 'font names' in our manual are actually 357 " For GTK, what we refer to as 'font names' in our manual are actually
285 " 'initial font patterns'. A valid font which matches the 'canonical font 358 " 'initial font patterns'. A valid font which matches the 'canonical font
286 " pattern' constructed from a given 'initial pattern' is to be looked up 359 " pattern' constructed from a given 'initial pattern' is to be looked up
475 if !empty(skipped) 548 if !empty(skipped)
476 throw skipped 549 throw skipped
477 endif 550 endif
478 endfunc 551 endfunc
479 552
480 func Test_getwinpos() 553 func Test_set_guioptions()
481 call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) 554 let guioptions_saved = &guioptions
482 call assert_true(getwinposx() >= 0) 555 let duration = '200m'
483 call assert_true(getwinposy() >= 0) 556
557 if has('win32')
558 " Default Value
559 set guioptions&
560 call assert_equal('egmrLtT', &guioptions)
561
562 else
563 " Default Value
564 set guioptions&
565 call assert_equal('aegimrLtT', &guioptions)
566
567 " To activate scrollbars of type 'L' or 'R'.
568 wincmd v
569 redraw!
570
571 " Remove all default GUI ornaments
572 set guioptions-=T
573 exec 'sleep' . duration
574 call assert_equal('aegimrLt', &guioptions)
575 set guioptions-=t
576 exec 'sleep' . duration
577 call assert_equal('aegimrL', &guioptions)
578 set guioptions-=L
579 exec 'sleep' . duration
580 call assert_equal('aegimr', &guioptions)
581 set guioptions-=r
582 exec 'sleep' . duration
583 call assert_equal('aegim', &guioptions)
584 set guioptions-=m
585 exec 'sleep' . duration
586 call assert_equal('aegi', &guioptions)
587
588 " Try non-default GUI ornaments
589 set guioptions+=l
590 exec 'sleep' . duration
591 call assert_equal('aegil', &guioptions)
592 set guioptions-=l
593 exec 'sleep' . duration
594 call assert_equal('aegi', &guioptions)
595
596 set guioptions+=R
597 exec 'sleep' . duration
598 call assert_equal('aegiR', &guioptions)
599 set guioptions-=R
600 exec 'sleep' . duration
601 call assert_equal('aegi', &guioptions)
602
603 set guioptions+=b
604 exec 'sleep' . duration
605 call assert_equal('aegib', &guioptions)
606 set guioptions+=h
607 exec 'sleep' . duration
608 call assert_equal('aegibh', &guioptions)
609 set guioptions-=h
610 exec 'sleep' . duration
611 call assert_equal('aegib', &guioptions)
612 set guioptions-=b
613 exec 'sleep' . duration
614 call assert_equal('aegi', &guioptions)
615
616 set guioptions+=v
617 exec 'sleep' . duration
618 call assert_equal('aegiv', &guioptions)
619 set guioptions-=v
620 exec 'sleep' . duration
621 call assert_equal('aegi', &guioptions)
622
623 if has('gui_motif')
624 set guioptions+=F
625 exec 'sleep' . duration
626 call assert_equal('aegiF', &guioptions)
627 set guioptions-=F
628 exec 'sleep' . duration
629 call assert_equal('aegi', &guioptions)
630 endif
631
632 " Restore GUI ornaments to the default state.
633 set guioptions+=m
634 exec 'sleep' . duration
635 call assert_equal('aegim', &guioptions)
636 set guioptions+=r
637 exec 'sleep' . duration
638 call assert_equal('aegimr', &guioptions)
639 set guioptions+=L
640 exec 'sleep' . duration
641 call assert_equal('aegimrL', &guioptions)
642 set guioptions+=t
643 exec 'sleep' . duration
644 call assert_equal('aegimrLt', &guioptions)
645 set guioptions+=T
646 exec 'sleep' . duration
647 call assert_equal("aegimrLtT", &guioptions)
648
649 wincmd o
650 redraw!
651 endif
652
653 let &guioptions = guioptions_saved
654 endfunc
655
656 func Test_set_guipty()
657 let guipty_saved = &guipty
658
659 " Default Value
660 set guipty&
661 call assert_equal(1, &guipty)
662
663 set noguipty
664 call assert_equal(0, &guipty)
665
666 let &guipty = guipty_saved
484 endfunc 667 endfunc
485 668
486 func Test_shell_command() 669 func Test_shell_command()
487 new 670 new
488 r !echo hello 671 r !echo hello
489 call assert_equal('hello', substitute(getline(2), '\W', '', 'g')) 672 call assert_equal('hello', substitute(getline(2), '\W', '', 'g'))
490 bwipe! 673 bwipe!
491 endfunc 674 endfunc
492 675
676 func Test_syntax_colortest()
677 runtime syntax/colortest.vim
678 redraw!
679 sleep 200m
680 bwipe!
681 endfunc
682
683 func Test_set_term()
684 " It's enough to check the current value since setting 'term' to anything
685 " other than builtin_gui makes no sense at all.
686 call assert_equal('builtin_gui', &term)
687 endfunc
688
493 func Test_windowid_variable() 689 func Test_windowid_variable()
494 if g:x11_based_gui || has('win32') 690 if g:x11_based_gui || has('win32')
495 call assert_true(v:windowid > 0) 691 call assert_true(v:windowid > 0)
496 else 692 else
497 call assert_equal(0, v:windowid) 693 call assert_equal(0, v:windowid)