comparison src/testdir/test_gui.vim @ 30021:9735b6186254 v9.0.0348

patch 9.0.0348: MS-Windows: GUI mouse move event test is flaky Commit: https://github.com/vim/vim/commit/36eb14fa3e729434cbb6f9078b4b330ae4f864f9 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 1 14:38:01 2022 +0100 patch 9.0.0348: MS-Windows: GUI mouse move event test is flaky Problem: MS-Windows: GUI mouse move event test is flaky. Solution: Wait for a little while for the first move event.
author Bram Moolenaar <Bram@vim.org>
date Thu, 01 Sep 2022 15:45:03 +0200
parents b8abb8908801
children 13b02c1ea0f7
comparison
equal deleted inserted replaced
30020:1dea7176b667 30021:9735b6186254
1210 set mousemodel& 1210 set mousemodel&
1211 endfunc 1211 endfunc
1212 1212
1213 " Move the mouse to the top-left in preparation for mouse events 1213 " Move the mouse to the top-left in preparation for mouse events
1214 func PrepareForMouseEvent(args) 1214 func PrepareForMouseEvent(args)
1215 call extend(a:args, #{row: 1, col:1}) 1215 call extend(a:args, #{row: 1, col: 1})
1216 call test_gui_event('mouse', a:args) 1216 call test_gui_event('mouse', a:args)
1217 let g:eventlist = []
1217 call feedkeys('', 'Lx!') 1218 call feedkeys('', 'Lx!')
1218 " on MS-Windows the event may have a slight delay 1219
1219 if has('win32') 1220 " Wait a bit for the event. I may not come if the mouse didn't move, wait up
1220 sleep 20m 1221 " to 100 msec.
1221 endif 1222 for n in range(10)
1223 if len(g:eventlist) > 0
1224 break
1225 endif
1226 sleep 10m
1227 endfor
1228 let g:eventlist = []
1222 endfunc 1229 endfunc
1223 1230
1224 func MouseWasMoved() 1231 func MouseWasMoved()
1225 let pos = getmousepos() 1232 let pos = getmousepos()
1226 call add(g:eventlist, #{row: pos.screenrow, col: pos.screencol}) 1233 call add(g:eventlist, #{row: pos.screenrow, col: pos.screencol})
1227 endfunc 1234 endfunc
1228 1235
1229 func Test_gui_mouse_move_event() 1236 func Test_gui_mouse_move_event()
1230 let args = #{move: 1, button: 0, multiclick: 0, modifiers: 0} 1237 let args = #{move: 1, button: 0, multiclick: 0, modifiers: 0}
1231 1238
1232 " by default, does not generate mouse move events 1239 " by default, no mouse move events are generated
1233 set mousemev& 1240 set mousemev&
1234 call assert_false(&mousemev) 1241 call assert_false(&mousemev)
1235 1242
1236 let g:eventlist = [] 1243 let g:eventlist = []
1237 nnoremap <special> <silent> <MouseMove> :call MouseWasMoved()<CR> 1244 nnoremap <special> <silent> <MouseMove> :call MouseWasMoved()<CR>
1238 1245
1239 " start at mouse pos (1,1), clear counter 1246 " start at mouse pos (1,1), clear counter
1240 call PrepareForMouseEvent(args) 1247 call PrepareForMouseEvent(args)
1241 let g:eventlist = []
1242 1248
1243 call extend(args, #{row: 3, col: 30, cell: v:true}) 1249 call extend(args, #{row: 3, col: 30, cell: v:true})
1244 call test_gui_event('mouse', args) 1250 call test_gui_event('mouse', args)
1245 call feedkeys('', 'Lx!') 1251 call feedkeys('', 'Lx!')
1246 1252
1247 call extend(args, #{row: 10, col: 30, cell: v:true}) 1253 call extend(args, #{row: 10, col: 30, cell: v:true})
1248 call test_gui_event('mouse', args) 1254 call test_gui_event('mouse', args)
1249 call feedkeys('', 'Lx!') 1255 call feedkeys('', 'Lx!')
1250 1256
1251 " no events since mousemev off 1257 " no events since 'mousemev' is off
1252 call assert_equal([], g:eventlist) 1258 call assert_equal([], g:eventlist)
1253 1259
1254 " turn on mouse events and try the same thing 1260 " turn on mouse events and try the same thing
1255 set mousemev 1261 set mousemev
1256 call PrepareForMouseEvent(args) 1262 call PrepareForMouseEvent(args)
1257 let g:eventlist = []
1258 1263
1259 call extend(args, #{row: 3, col: 30, cell: v:true}) 1264 call extend(args, #{row: 3, col: 30, cell: v:true})
1260 call test_gui_event('mouse', args) 1265 call test_gui_event('mouse', args)
1261 call feedkeys('', 'Lx!') 1266 call feedkeys('', 'Lx!')
1262 1267
1272 call assert_equal([#{row: 4, col: 31}, #{row: 11, col: 31}], g:eventlist) 1277 call assert_equal([#{row: 4, col: 31}, #{row: 11, col: 31}], g:eventlist)
1273 1278
1274 " wiggle the mouse around within a screen cell, shouldn't trigger events 1279 " wiggle the mouse around within a screen cell, shouldn't trigger events
1275 call extend(args, #{cell: v:false}) 1280 call extend(args, #{cell: v:false})
1276 call PrepareForMouseEvent(args) 1281 call PrepareForMouseEvent(args)
1277 let g:eventlist = []
1278 1282
1279 call extend(args, #{row: 1, col: 2, cell: v:false}) 1283 call extend(args, #{row: 1, col: 2, cell: v:false})
1280 call test_gui_event('mouse', args) 1284 call test_gui_event('mouse', args)
1281 call feedkeys('', 'Lx!') 1285 call feedkeys('', 'Lx!')
1282 1286