blob: c5c771680362a70f59ebf83ac67691153d53b09c [file] [log] [blame]
Bram Moolenaar877e9572016-08-04 20:05:50 +02001" Tests specifically for the GUI
2
3if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
4 finish
5endif
6
Bram Moolenaar13c724f2017-02-05 20:54:26 +01007let s:x11_based_gui = has('gui_athena') || has('gui_motif')
8 \ || has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
9
Bram Moolenaar877e9572016-08-04 20:05:50 +020010" For KDE set a font, empty 'guifont' may cause a hang.
11func SetUp()
12 if has("gui_kde")
13 set guifont=Courier\ 10\ Pitch/8/-1/5/50/0/0/0/0/0
14 endif
Bram Moolenaar50fa8dd2016-08-09 22:58:21 +020015
Bram Moolenaarf1ab9c12017-02-01 12:32:58 +010016 " Gnome insists on creating $HOME/.gnome2/, set $HOME to avoid changing the
17 " actual home directory. But avoid triggering fontconfig by setting the
18 " cache directory. Only needed for Unix.
19 if $XDG_CACHE_HOME == '' && exists('g:tester_HOME')
Bram Moolenaar56e6bd72017-02-01 12:08:47 +010020 let $XDG_CACHE_HOME = g:tester_HOME . '/.cache'
21 endif
Bram Moolenaar50fa8dd2016-08-09 22:58:21 +020022 call mkdir('Xhome')
23 let $HOME = fnamemodify('Xhome', ':p')
24endfunc
25
26func TearDown()
27 call delete('Xhome', 'rf')
Bram Moolenaar877e9572016-08-04 20:05:50 +020028endfunc
29
30" Test for resetting "secure" flag after GUI has started.
31" Must be run first.
32func Test_1_set_secure()
33 set exrc secure
34 gui -f
35 call assert_equal(1, has('gui_running'))
36endfunc
37
Bram Moolenaar13c724f2017-02-05 20:54:26 +010038func Test_getwinpos()
39 call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
40 call assert_true(getwinposx() >= 0)
41 call assert_true(getwinposy() >= 0)
42endfunction
43
Bram Moolenaar877e9572016-08-04 20:05:50 +020044func Test_shell_command()
45 new
Bram Moolenaar9d5b8762016-08-04 21:21:13 +020046 r !echo hello
47 call assert_equal('hello', substitute(getline(2), '\W', '', 'g'))
Bram Moolenaar877e9572016-08-04 20:05:50 +020048 bwipe!
Bram Moolenaar877e9572016-08-04 20:05:50 +020049endfunc
Bram Moolenaar13c724f2017-02-05 20:54:26 +010050
51func Test_windowid_variable()
52 if s:x11_based_gui || has('win32')
53 call assert_true(v:windowid > 0)
54 else
55 call assert_equal(0, v:windowid)
56 endif
57endfunction