" Tests specifically for the GUI
source shared.vim
source check.vim
CheckCanRunGui
source setup_gui.vim
func Setup()
call GUISetUpCommon()
endfunc
func TearDown()
call GUITearDownCommon()
endfunc
" Test for resetting "secure" flag after GUI has started.
" Must be run first, since it starts the GUI on Unix.
func Test_1_set_secure()
set exrc secure
gui -f
call assert_equal(1, has('gui_running'))
endfunc
" As for non-GUI, a balloon_show() test was already added with patch 8.0.0401
func Test_balloon_show()
CheckFeature balloon_eval
" This won't do anything but must not crash either.
call balloon_show('hi!')
endfunc
func Test_colorscheme()
call assert_equal('16777216', &t_Co)
let colorscheme_saved = exists('g:colors_name') ? g:colors_name : 'default'
let g:color_count = 0
augroup TestColors
au!
au ColorScheme * let g:color_count += 1| let g:after_colors = g:color_count
au ColorSchemePre * let g:color_count += 1 |let g:before_colors = g:color_count
augroup END
colorscheme torte
redraw!
call assert_equal('dark', &background)
call assert_equal(1, g:before_colors)
call assert_equal(2, g:after_colors)
call assert_equal("\ntorte", execute('colorscheme'))
let a = substitute(execute('hi Search'), "\n\\s\\+", ' ', 'g')
call assert_match("\nSearch xxx term=reverse ctermfg=0 ctermbg=12 gui=bold guifg=Black guibg=Red", a)
call assert_fails('colorscheme does_not_exist', 'E185:')
exec 'colorscheme' colorscheme_saved
augroup TestColors
au!
augroup END
unlet g:color_count g:after_colors g:before_colors
redraw!
endfunc
func Test_getfontname_with_arg()
let skipped = ''
if !g:x11_based_gui
let skipped = g:not_implemented
elseif has('gui_athena') || has('gui_motif')
" Invalid font name. The result should be an empty string.
call assert_equal('', getfontname('notexist'))
" Valid font name. This is usually the real name of 7x13 by default.
let fname = '-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1'
call assert_match(fname, getfontname(fname))
elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
" Invalid font name. The result should be the name plus the default size.
call assert_equal('notexist 10', getfontname('notexist'))
call assert_equal('', getfontname('*'))
" Valid font name. This is usually the real name of Monospace by default.
let fname = 'Bitstream Vera Sans Mono 12'
call assert_equal(fname, getfontname(fname))
endif
if !empty(skipped)
throw skipped
endif
endfunc
func Test_getfontname_without_arg()
let skipped = ''
let fname = getfontname()
if !g:x11_based_gui
let skipped = g:not_implemented
elseif has('gui_kde')
" 'expected' is the value specified by SetUp() above.
call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname)
elseif has('gui_athena') || has('gui_motif')
" 'expected' is DFLT_FONT of gui_x11.c or its real name.
let pat = '\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)'
call assert_match(pat, fname)
elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
" 'expected' is DEFAULT_FONT of gui_gtk_x11.c.
call assert_equal('Monospace 10', fname)
endif
if !empty(skipped)
throw skipped
endif
endfunc
func Test_getwinpos()
call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
call assert_true(getwinposx() >= 0)
call assert_true(getwinposy() >= 0)
call assert_equal([getwinposx(), getwinposy()], getwinpos())
endfunc
func Test_quoteplus()
let g:test_is_flaky = 1
let skipped = ''
if !g:x11_based_gui
let skipped = g:not_supported . 'quoteplus'
else
let quoteplus_saved = @+
let test_call = 'Can you hear me?'
let test_response = 'Yes, I can.'
let vim_exe = GetVimCommand()
let testee = 'VIMRUNTIME=' . $VIMRUNTIME . '; export VIMRUNTIME;'
\ . vim_exe . ' --noplugin --not-a-term -c ''%s'''
" Ignore the "failed to create input context" error.
let cmd = 'call test_ignore_error("E285") | '
\ . 'gui -f | '
\ . 'call feedkeys("'
\ . '\"+p'
\ . ':s/' . test_call . '/' . test_response . '/\<CR>'
\ . '\"+yis'
\ . ':q!\<CR>", "tx")'
let run_vimtest = printf(testee, cmd)
" Set the quoteplus register to test_call, and another gvim will launched.
" Then, it first tries to paste the content of its own quotedplus register