comparison src/testdir/test_gui.vim @ 24998:3b1770226f85 v8.2.3036

patch 8.2.3036: Vim9: builtin function arguments not checked at compile time Commit: https://github.com/vim/vim/commit/7237cab8f1d1a4391372cafdb57f2d97f3b32d05 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Jun 22 19:52:27 2021 +0200 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time Problem: Vim9: builtin function arguments not checked at compile time. Solution: Add more argument type specs. Check arguments to test_setmouse() and test_gui_mouse_event(). (Yegappan Lakshmanan, closes #8425)
author Bram Moolenaar <Bram@vim.org>
date Tue, 22 Jun 2021 20:00:05 +0200
parents 4cb423b9250d
children 496221916885
comparison
equal deleted inserted replaced
24997:6cd844668030 24998:3b1770226f85
880 set mousemodel=extend 880 set mousemodel=extend
881 call test_override('no_query_mouse', 1) 881 call test_override('no_query_mouse', 1)
882 new 882 new
883 call setline(1, ['one two three', 'four five six']) 883 call setline(1, ['one two three', 'four five six'])
884 884
885 " place the cursor using left click 885 " place the cursor using left click in normal mode
886 call cursor(1, 1) 886 call cursor(1, 1)
887 call test_gui_mouse_event(0, 2, 4, 0, 0) 887 call test_gui_mouse_event(0, 2, 4, 0, 0)
888 call test_gui_mouse_event(3, 2, 4, 0, 0) 888 call test_gui_mouse_event(3, 2, 4, 0, 0)
889 call feedkeys("\<Esc>", 'Lx!') 889 call feedkeys("\<Esc>", 'Lx!')
890 call assert_equal([0, 2, 4, 0], getpos('.')) 890 call assert_equal([0, 2, 4, 0], getpos('.'))
1090 call assert_equal([0, 2, 7, 0], getpos('.')) 1090 call assert_equal([0, 2, 7, 0], getpos('.'))
1091 call assert_equal('wo thrfour five sixteen', getline(2)) 1091 call assert_equal('wo thrfour five sixteen', getline(2))
1092 set mouse& 1092 set mouse&
1093 let &guioptions = save_guioptions 1093 let &guioptions = save_guioptions
1094 1094
1095 " Test invalid parameters for test_gui_mouse_event()
1096 call assert_fails('call test_gui_mouse_event("", 1, 2, 3, 4)', 'E474:')
1097 call assert_fails('call test_gui_mouse_event(0, "", 2, 3, 4)', 'E474:')
1098 call assert_fails('call test_gui_mouse_event(0, 1, "", 3, 4)', 'E474:')
1099 call assert_fails('call test_gui_mouse_event(0, 1, 2, "", 4)', 'E474:')
1100 call assert_fails('call test_gui_mouse_event(0, 1, 2, 3, "")', 'E474:')
1101
1095 bw! 1102 bw!
1096 call test_override('no_query_mouse', 0) 1103 call test_override('no_query_mouse', 0)
1097 set mousemodel& 1104 set mousemodel&
1098 endfunc 1105 endfunc
1099 1106
1107 " Test for 'guitablabel' and 'guitabtooltip' options
1108 func TestGuiTabLabel()
1109 call add(g:TabLabels, v:lnum + 100)
1110 let bufnrlist = tabpagebuflist(v:lnum)
1111 return bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
1112 endfunc
1113
1114 func TestGuiTabToolTip()
1115 call add(g:TabToolTips, v:lnum + 200)
1116 let bufnrlist = tabpagebuflist(v:lnum)
1117 return bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
1118 endfunc
1119
1120 func Test_gui_tablabel_tooltip()
1121 %bw!
1122 " Removing the tabline at the end of this test, reduces the window height by
1123 " one. Save and restore it after the test.
1124 let save_lines = &lines
1125 edit one
1126 set modified
1127 tabnew two
1128 set modified
1129 tabnew three
1130 set modified
1131 let g:TabLabels = []
1132 set guitablabel=%{TestGuiTabLabel()}
1133 call test_override('starting', 1)
1134 redrawtabline
1135 call test_override('starting', 0)
1136 call assert_true(index(g:TabLabels, 101) != -1)
1137 call assert_true(index(g:TabLabels, 102) != -1)
1138 call assert_true(index(g:TabLabels, 103) != -1)
1139 set guitablabel&
1140 unlet g:TabLabels
1141
1142 if has('gui_gtk')
1143 " Only on GTK+, the tooltip function is called even if the mouse is not
1144 " on the tabline. on Win32 and Motif, the tooltip function is called only
1145 " when the mouse pointer is over the tabline.
1146 let g:TabToolTips = []
1147 set guitabtooltip=%{TestGuiTabToolTip()}
1148 call test_override('starting', 1)
1149 redrawtabline
1150 call test_override('starting', 0)
1151 call assert_true(index(g:TabToolTips, 201) != -1)
1152 call assert_true(index(g:TabToolTips, 202) != -1)
1153 call assert_true(index(g:TabToolTips, 203) != -1)
1154 set guitabtooltip&
1155 unlet g:TabToolTips
1156 endif
1157 %bw!
1158 let &lines = save_lines
1159 endfunc
1160
1100 " vim: shiftwidth=2 sts=2 expandtab 1161 " vim: shiftwidth=2 sts=2 expandtab