Mercurial > vim
comparison src/testdir/test_termcodes.vim @ 18223:8a86e518fa42 v8.1.2106
patch 8.1.2106: no tests for dragging the mouse beyond the window
Commit: https://github.com/vim/vim/commit/b4367b7fb65f6a88f76ef99f79342341af0b1017
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 1 14:19:07 2019 +0200
patch 8.1.2106: no tests for dragging the mouse beyond the window
Problem: No tests for dragging the mouse beyond the window.
Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/5004)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 01 Oct 2019 14:30:03 +0200 |
parents | 8a2fb21c23c0 |
children | eda5b2cb1dc4 |
comparison
equal
deleted
inserted
replaced
18222:5ccb2d2ca9be | 18223:8a86e518fa42 |
---|---|
164 let row = 1 | 164 let row = 1 |
165 let col = 1 | 165 let col = 1 |
166 call MouseCtrlLeftClick(row, col) | 166 call MouseCtrlLeftClick(row, col) |
167 call MouseLeftRelease(row, col) | 167 call MouseLeftRelease(row, col) |
168 call assert_match('usr_02.txt$', bufname('%'), msg) | 168 call assert_match('usr_02.txt$', bufname('%'), msg) |
169 call assert_equal('*usr_02.txt*', expand('<cWORD>')) | 169 call assert_equal('*usr_02.txt*', expand('<cWORD>'), msg) |
170 | 170 |
171 call MouseCtrlRightClick(row, col) | 171 call MouseCtrlRightClick(row, col) |
172 call MouseRightRelease(row, col) | 172 call MouseRightRelease(row, col) |
173 call assert_match('help.txt$', bufname('%'), msg) | 173 call assert_match('help.txt$', bufname('%'), msg) |
174 call assert_equal('|usr_02.txt|', expand('<cWORD>')) | 174 call assert_equal('|usr_02.txt|', expand('<cWORD>'), msg) |
175 | 175 |
176 helpclose | 176 helpclose |
177 endfor | 177 endfor |
178 | 178 |
179 let &mouse = save_mouse | 179 let &mouse = save_mouse |
262 endfor | 262 endfor |
263 | 263 |
264 let &mouse = save_mouse | 264 let &mouse = save_mouse |
265 let &term = save_term | 265 let &term = save_term |
266 let &ttymouse = save_ttymouse | 266 let &ttymouse = save_ttymouse |
267 bwipe! | |
268 endfunc | |
269 | |
270 " Test that dragging beyond the window (at the bottom and at the top) | |
271 " scrolls window content by the number of of lines beyond the window. | |
272 func Test_term_mouse_drag_beyond_window() | |
273 let save_mouse = &mouse | |
274 let save_term = &term | |
275 let save_ttymouse = &ttymouse | |
276 call test_override('no_query_mouse', 1) | |
277 set mouse=a term=xterm | |
278 let col = 1 | |
279 call setline(1, range(1, 100)) | |
280 | |
281 " Split into 3 windows, and go into the middle window | |
282 " so we test dragging mouse below and above the window. | |
283 2split | |
284 wincmd j | |
285 2split | |
286 | |
287 for ttymouse_val in s:ttymouse_values + s:ttymouse_dec | |
288 let msg = 'ttymouse=' .. ttymouse_val | |
289 exe 'set ttymouse=' .. ttymouse_val | |
290 | |
291 " Line #10 at the top. | |
292 norm! 10zt | |
293 redraw | |
294 call assert_equal(10, winsaveview().topline, msg) | |
295 call assert_equal(2, winheight(0), msg) | |
296 | |
297 let row = 4 | |
298 call MouseLeftClick(row, col) | |
299 call assert_equal(10, winsaveview().topline, msg) | |
300 | |
301 " Drag downwards. We're still in the window so topline should | |
302 " not change yet. | |
303 let row += 1 | |
304 call MouseLeftDrag(row, col) | |
305 call assert_equal(10, winsaveview().topline, msg) | |
306 | |
307 " We now leave the window at the bottom, so the window content should | |
308 " scroll by 1 line, then 2 lines (etc) as we drag further away. | |
309 let row += 1 | |
310 call MouseLeftDrag(row, col) | |
311 call assert_equal(11, winsaveview().topline, msg) | |
312 | |
313 let row += 1 | |
314 call MouseLeftDrag(row, col) | |
315 call assert_equal(13, winsaveview().topline, msg) | |
316 | |
317 " Now drag upwards. | |
318 let row -= 1 | |
319 call MouseLeftDrag(row, col) | |
320 call assert_equal(14, winsaveview().topline, msg) | |
321 | |
322 " We're now back in the window so the topline should not change. | |
323 let row -= 1 | |
324 call MouseLeftDrag(row, col) | |
325 call assert_equal(14, winsaveview().topline, msg) | |
326 | |
327 let row -= 1 | |
328 call MouseLeftDrag(row, col) | |
329 call assert_equal(14, winsaveview().topline, msg) | |
330 | |
331 " We now leave the window at the top so the window content should | |
332 " scroll by 1 line, then 2, then 3 (etc) in the opposite direction. | |
333 let row -= 1 | |
334 call MouseLeftDrag(row, col) | |
335 call assert_equal(13, winsaveview().topline, msg) | |
336 | |
337 let row -= 1 | |
338 call MouseLeftDrag(row, col) | |
339 call assert_equal(11, winsaveview().topline, msg) | |
340 | |
341 let row -= 1 | |
342 call MouseLeftDrag(row, col) | |
343 call assert_equal(8, winsaveview().topline, msg) | |
344 | |
345 call MouseLeftRelease(row, col) | |
346 call assert_equal(8, winsaveview().topline, msg) | |
347 call assert_equal(2, winheight(0), msg) | |
348 endfor | |
349 | |
350 let &mouse = save_mouse | |
351 let &term = save_term | |
352 let &ttymouse = save_ttymouse | |
353 call test_override('no_query_mouse', 0) | |
267 bwipe! | 354 bwipe! |
268 endfunc | 355 endfunc |
269 | 356 |
270 func Test_term_mouse_drag_window_separator() | 357 func Test_term_mouse_drag_window_separator() |
271 let save_mouse = &mouse | 358 let save_mouse = &mouse |