Skip to content

Commit 240309c

Browse files
committed
patch 8.2.2604: GUI-specific command line arguments not tested
Problem: GUI-specific command line arguments not tested. Solution: Add tests for several arguments. (Dominique Pellé, closes #7962)
1 parent 77b10ff commit 240309c

2 files changed

Lines changed: 146 additions & 14 deletions

File tree

src/testdir/test_startup.vim

Lines changed: 144 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ func Test_pack_in_rtp_when_plugins_run()
109109
endfunc
110110

111111
func Test_help_arg()
112-
if !has('unix') && has('gui_running')
113-
throw 'Skipped: does not work with gvim on MS-Windows'
114-
endif
112+
CheckNotMSWindows
113+
115114
if RunVim([], [], '--help >Xtestout')
116115
let lines = readfile('Xtestout')
117116
call assert_true(len(lines) > 20)
@@ -408,6 +407,134 @@ func Test_A_F_H_arg()
408407
call delete('Xtestout')
409408
endfunc
410409

410+
" Test the --echo-wid argument (for GTK GUI only).
411+
func Test_echo_wid()
412+
CheckCanRunGui
413+
CheckFeature gui_gtk
414+
415+
if RunVim([], [], '-g --echo-wid -cq >Xtest_echo_wid')
416+
let lines = readfile('Xtest_echo_wid')
417+
call assert_equal(1, len(lines))
418+
call assert_match('^WID: \d\+$', lines[0])
419+
endif
420+
421+
call delete('Xtest_echo_wid')
422+
endfunction
423+
424+
" Test the -reverse and +reverse arguments (for GUI only).
425+
func Test_reverse()
426+
CheckCanRunGui
427+
CheckNotMSWindows
428+
429+
let after =<< trim [CODE]
430+
call writefile([&background], "Xtest_reverse")
431+
qall
432+
[CODE]
433+
if RunVim([], after, '-f -g -reverse')
434+
let lines = readfile('Xtest_reverse')
435+
call assert_equal(['dark'], lines)
436+
endif
437+
if RunVim([], after, '-f -g +reverse')
438+
let lines = readfile('Xtest_reverse')
439+
call assert_equal(['light'], lines)
440+
endif
441+
442+
call delete('Xtest_reverse')
443+
endfunc
444+
445+
" Test the -background and -foreground arguments (for GUI only).
446+
func Test_background_foreground()
447+
CheckCanRunGui
448+
CheckNotMSWindows
449+
450+
" Is there a better way to check the effect of -background & -foreground
451+
" other than merely looking at &background (dark or light)?
452+
let after =<< trim [CODE]
453+
call writefile([&background], "Xtest_fg_bg")
454+
qall
455+
[CODE]
456+
if RunVim([], after, '-f -g -background darkred -foreground yellow')
457+
let lines = readfile('Xtest_fg_bg')
458+
call assert_equal(['dark'], lines)
459+
endif
460+
if RunVim([], after, '-f -g -background ivory -foreground darkgreen')
461+
let lines = readfile('Xtest_fg_bg')
462+
call assert_equal(['light'], lines)
463+
endif
464+
465+
call delete('Xtest_fg_bg')
466+
endfunc
467+
468+
" Test the -font argument (for GUI only).
469+
func Test_font()
470+
CheckCanRunGui
471+
CheckNotMSWindows
472+
473+
if has('gui_gtk')
474+
let font = 'Courier 14'
475+
elseif has('gui_motif') || has('gui_athena')
476+
let font = '-misc-fixed-bold-*'
477+
else
478+
throw 'Skipped: test does not set a valid font for this GUI'
479+
endif
480+
481+
let after =<< trim [CODE]
482+
call writefile([&guifont], "Xtest_font")
483+
qall
484+
[CODE]
485+
486+
if RunVim([], after, '--nofork -g -font "' .. font .. '"')
487+
let lines = readfile('Xtest_font')
488+
call assert_equal([font], lines)
489+
endif
490+
491+
call delete('Xtest_font')
492+
endfunc
493+
494+
" Test the -geometry argument (for GUI only).
495+
func Test_geometry()
496+
CheckCanRunGui
497+
CheckNotMSWindows
498+
499+
if has('gui_motif') || has('gui_athena')
500+
" FIXME: With GUI Athena or Motif, the value of getwinposx(),
501+
" getwinposy() and getwinpos() do not match exactly the
502+
" value given in -geometry. Why?
503+
" So only check &columns and &lines for those GUIs.
504+
let after =<< trim [CODE]
505+
call writefile([&columns, &lines], "Xtest_geometry")
506+
qall
507+
[CODE]
508+
if RunVim([], after, '-f -g -geometry 31x13+41+43')
509+
let lines = readfile('Xtest_geometry')
510+
call assert_equal(['31', '13'], lines)
511+
endif
512+
else
513+
let after =<< trim [CODE]
514+
call writefile([&columns, &lines, getwinposx(), getwinposy(), string(getwinpos())], "Xtest_geometry")
515+
qall
516+
[CODE]
517+
if RunVim([], after, '-f -g -geometry 31x13+41+43')
518+
let lines = readfile('Xtest_geometry')
519+
call assert_equal(['31', '13', '41', '43', '[41, 43]'], lines)
520+
endif
521+
endif
522+
523+
call delete('Xtest_geometry')
524+
endfunc
525+
526+
" Test the -iconic argument (for GUI only).
527+
func Test_iconic()
528+
CheckCanRunGui
529+
CheckNotMSWindows
530+
531+
call RunVim([], [], '-f -g -iconic -cq')
532+
533+
" TODO: currently only start vim iconified, but does not
534+
" check that vim is iconified. How could this be checked?
535+
endfunc
536+
537+
411538
func Test_invalid_args()
412539
" must be able to get the output of Vim.
413540
CheckUnix
@@ -1042,16 +1169,11 @@ func Test_progname()
10421169
\ 'vimdiff', 'gvimdiff']
10431170

10441171
for progname in prognames
1045-
if empty($DISPLAY)
1046-
if progname =~# 'g'
1047-
" Can't run gvim, gview (etc.) if $DISPLAY is not setup.
1048-
continue
1049-
endif
1050-
if has('gui') && (progname ==# 'evim' || progname ==# 'eview')
1051-
" evim or eview will start the GUI if there is gui support.
1052-
" So don't try to start them either if $DISPLAY is not setup.
1053-
continue
1054-
endif
1172+
let run_with_gui = (progname =~# 'g') || (has('gui') && (progname ==# 'evim' || progname ==# 'eview'))
1173+
1174+
if empty($DISPLAY) && run_with_gui
1175+
" Can't run gvim, gview (etc.) if $DISPLAY is not setup.
1176+
continue
10551177
endif
10561178

10571179
exe 'silent !ln -s -f ' ..exepath(GetVimProg()) .. ' Xprogname/' .. progname
@@ -1066,7 +1188,15 @@ func Test_progname()
10661188
if progname =~# 'g' && !has('gui')
10671189
call assert_equal("E25: GUI cannot be used: Not enabled at compile time\n", stdout_stderr, progname)
10681190
else
1069-
call assert_equal('', stdout_stderr, progname)
1191+
" GUI motif can output some warnings like this:
1192+
" Warning:
1193+
" Name: subMenu
1194+
" Class: XmCascadeButton
1195+
" Illegal mnemonic character; Could not convert X KEYSYM to a keycode
1196+
" So don't check that stderr is empty with GUI Motif.
1197+
if run_with_gui && !has('gui_motif')
1198+
call assert_equal('', stdout_stderr, progname)
1199+
endif
10701200
call assert_equal(expectations[progname], readfile('Xprogname_out'), progname)
10711201
endif
10721202

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2604,
753755
/**/
754756
2603,
755757
/**/

0 commit comments

Comments
 (0)