@@ -30,6 +30,18 @@ func Test_balloon_show()
3030 endif
3131endfunc
3232
33+ func Test_colorscheme ()
34+ let colorscheme_saved = exists (' g:colors_name' ) ? g: colors_name : ' default'
35+
36+ colorscheme torte
37+ redraw !
38+ sleep 200 m
39+ call assert_equal (' dark' , &background )
40+
41+ exec ' colorscheme' colorscheme_saved
42+ redraw !
43+ endfunc
44+
3345func Test_getfontname_with_arg ()
3446 let skipped = ' '
3547
@@ -40,8 +52,8 @@ func Test_getfontname_with_arg()
4052 call assert_equal (' ' , getfontname (' notexist' ))
4153
4254 " 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'
44- call assert_equal (fname, getfontname (fname))
55+ let fname = ' -Misc-Fixed-Medium-R-Normal --13-120-75-75-C -70-ISO8859 -1'
56+ call assert_match (fname, getfontname (fname))
4557
4658 elseif has (' gui_gtk2' ) || has (' gui_gnome' ) || has (' gui_gtk3' )
4759 " Invalid font name. The result should be the name plus the default size.
@@ -68,8 +80,9 @@ func Test_getfontname_without_arg()
6880 " 'expected' is the value specified by SetUp() above.
6981 call assert_equal (' Courier 10 Pitch/8/-1/5/50/0/0/0/0/0' , fname)
7082 elseif has (' gui_athena' ) || has (' gui_motif' )
71- " 'expected' is DFLT_FONT of gui_x11.c.
72- call assert_equal (' 7x13' , fname)
83+ " 'expected' is DFLT_FONT of gui_x11.c or its real name.
84+ let pat = ' \(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)'
85+ call assert_match (pat, fname)
7386 elseif has (' gui_gtk2' ) || has (' gui_gnome' ) || has (' gui_gtk3' )
7487 " 'expected' is DEFAULT_FONT of gui_gtk_x11.c.
7588 call assert_equal (' Monospace 10' , fname)
@@ -80,6 +93,12 @@ func Test_getfontname_without_arg()
8093 endif
8194endfunc
8295
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 )
100+ endfunc
101+
83102func Test_quoteplus ()
84103 let skipped = ' '
85104
@@ -125,6 +144,18 @@ func Test_quoteplus()
125144 endif
126145endfunc
127146
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
157+ endfunc
158+
128159func Test_set_balloondelay ()
129160 if ! exists (' +balloondelay' )
130161 return
@@ -248,6 +279,46 @@ func Test_set_balloonexpr()
248279 let &balloonexpr = balloonexpr_saved
249280endfunc
250281
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+
251322func Test_set_guifont ()
252323 let skipped = ' '
253324
@@ -274,11 +345,13 @@ func Test_set_guifont()
274345 " Non-empty font list with a valid font name. Should pick up the first
275346 " valid font.
276347 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 ())
278350
279351 " Empty list. Should fallback to the built-in default.
280352 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 ())
282355
283356 elseif has (' gui_gtk2' ) || has (' gui_gnome' ) || has (' gui_gtk3' )
284357 " For GTK, what we refer to as 'font names' in our manual are actually
@@ -477,10 +550,120 @@ func Test_set_guiheadroom()
477550 endif
478551endfunc
479552
480- func Test_getwinpos ()
481- call assert_match (' Window position: X \d\+, Y \d\+' , execute (' winpos' ))
482- call assert_true (getwinposx () >= 0 )
483- call assert_true (getwinposy () >= 0 )
553+ func Test_set_guioptions ()
554+ let guioptions_saved = &guioptions
555+ let duration = ' 200m'
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
484667endfunc
485668
486669func Test_shell_command ()
@@ -490,6 +673,19 @@ func Test_shell_command()
490673 bwipe!
491674endfunc
492675
676+ func Test_syntax_colortest ()
677+ runtime syntax /colortest.vim
678+ redraw !
679+ sleep 200 m
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+
493689func Test_windowid_variable ()
494690 if g: x11_based_gui || has (' win32' )
495691 call assert_true (v: windowid > 0 )
0 commit comments