0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.1.1178: when mouse click tests fails value of 'ttytype' is unknown

Problem:    When mouse click tests fails value of 'ttytype' is unknown.
Solution:   Add a message to the assert.
This commit is contained in:
Bram Moolenaar
2019-04-17 16:27:02 +02:00
parent 1a4dce7cad
commit 4945219b99
2 changed files with 47 additions and 37 deletions

View File

@@ -51,14 +51,15 @@ func Test_xterm_mouse_click()
call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer']) call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer'])
for ttymouse_val in ['xterm', 'sgr'] for ttymouse_val in ['xterm', 'sgr']
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
go go
call assert_equal([0, 1, 1, 0], getpos('.')) call assert_equal([0, 1, 1, 0], getpos('.'), msg)
let row = 2 let row = 2
let col = 6 let col = 6
call MouseLeftClick(row, col) call MouseLeftClick(row, col)
call MouseLeftRelease(row, col) call MouseLeftRelease(row, col)
call assert_equal([0, 2, 6, 0], getpos('.')) call assert_equal([0, 2, 6, 0], getpos('.'), msg)
endfor endfor
let &mouse = save_mouse let &mouse = save_mouse
@@ -76,26 +77,27 @@ func Test_xterm_mouse_wheel()
call setline(1, range(1, 100)) call setline(1, range(1, 100))
for ttymouse_val in ['xterm', 'sgr'] for ttymouse_val in ['xterm', 'sgr']
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
go go
call assert_equal(1, line('w0')) call assert_equal(1, line('w0'), msg)
call assert_equal([0, 1, 1, 0], getpos('.')) call assert_equal([0, 1, 1, 0], getpos('.'), msg)
call MouseWheelDown(1, 1) call MouseWheelDown(1, 1)
call assert_equal(4, line('w0')) call assert_equal(4, line('w0'), msg)
call assert_equal([0, 4, 1, 0], getpos('.')) call assert_equal([0, 4, 1, 0], getpos('.'), msg)
call MouseWheelDown(1, 1) call MouseWheelDown(1, 1)
call assert_equal(7, line('w0')) call assert_equal(7, line('w0'), msg)
call assert_equal([0, 7, 1, 0], getpos('.')) call assert_equal([0, 7, 1, 0], getpos('.'), msg)
call MouseWheelUp(1, 1) call MouseWheelUp(1, 1)
call assert_equal(4, line('w0')) call assert_equal(4, line('w0'), msg)
call assert_equal([0, 7, 1, 0], getpos('.')) call assert_equal([0, 7, 1, 0], getpos('.'), msg)
call MouseWheelUp(1, 1) call MouseWheelUp(1, 1)
call assert_equal(1, line('w0')) call assert_equal(1, line('w0'), msg)
call assert_equal([0, 7, 1, 0], getpos('.')) call assert_equal([0, 7, 1, 0], getpos('.'), msg)
endfor endfor
let &mouse = save_mouse let &mouse = save_mouse
@@ -111,6 +113,7 @@ func Test_xterm_mouse_drag_window_separator()
set mouse=a term=xterm set mouse=a term=xterm
for ttymouse_val in ['xterm', 'sgr'] for ttymouse_val in ['xterm', 'sgr']
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
" Split horizontally and test dragging the horizontal window separator. " Split horizontally and test dragging the horizontal window separator.
@@ -124,12 +127,12 @@ func Test_xterm_mouse_drag_window_separator()
call MouseLeftClick(row, col) call MouseLeftClick(row, col)
let row -= 1 let row -= 1
call MouseLeftDrag(row, col) call MouseLeftDrag(row, col)
call assert_equal(rowseparator - 1, winheight(0) + 1) call assert_equal(rowseparator - 1, winheight(0) + 1, msg)
let row += 1 let row += 1
call MouseLeftDrag(row, col) call MouseLeftDrag(row, col)
call assert_equal(rowseparator, winheight(0) + 1) call assert_equal(rowseparator, winheight(0) + 1, msg)
call MouseLeftRelease(row, col) call MouseLeftRelease(row, col)
call assert_equal(rowseparator, winheight(0) + 1) call assert_equal(rowseparator, winheight(0) + 1, msg)
endif endif
bwipe! bwipe!
@@ -144,12 +147,12 @@ func Test_xterm_mouse_drag_window_separator()
call MouseLeftClick(row, col) call MouseLeftClick(row, col)
let col -= 1 let col -= 1
call MouseLeftDrag(row, col) call MouseLeftDrag(row, col)
call assert_equal(colseparator - 1, winwidth(0) + 1) call assert_equal(colseparator - 1, winwidth(0) + 1, msg)
let col += 1 let col += 1
call MouseLeftDrag(row, col) call MouseLeftDrag(row, col)
call assert_equal(colseparator, winwidth(0) + 1) call assert_equal(colseparator, winwidth(0) + 1, msg)
call MouseLeftRelease(row, col) call MouseLeftRelease(row, col)
call assert_equal(colseparator, winwidth(0) + 1) call assert_equal(colseparator, winwidth(0) + 1, msg)
endif endif
bwipe! bwipe!
endfor endfor
@@ -167,9 +170,10 @@ func Test_xterm_mouse_drag_statusline()
set mouse=a term=xterm laststatus=2 set mouse=a term=xterm laststatus=2
for ttymouse_val in ['xterm', 'sgr'] for ttymouse_val in ['xterm', 'sgr']
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
call assert_equal(1, &cmdheight) call assert_equal(1, &cmdheight, msg)
let rowstatusline = winheight(0) + 1 let rowstatusline = winheight(0) + 1
let row = rowstatusline let row = rowstatusline
let col = 1 let col = 1
@@ -182,15 +186,15 @@ func Test_xterm_mouse_drag_statusline()
call MouseLeftClick(row, col) call MouseLeftClick(row, col)
let row -= 1 let row -= 1
call MouseLeftDrag(row, col) call MouseLeftDrag(row, col)
call assert_equal(2, &cmdheight) call assert_equal(2, &cmdheight, msg)
call assert_equal(rowstatusline - 1, winheight(0) + 1) call assert_equal(rowstatusline - 1, winheight(0) + 1, msg)
let row += 1 let row += 1
call MouseLeftDrag(row, col) call MouseLeftDrag(row, col)
call assert_equal(1, &cmdheight) call assert_equal(1, &cmdheight, msg)
call assert_equal(rowstatusline, winheight(0) + 1) call assert_equal(rowstatusline, winheight(0) + 1, msg)
call MouseLeftRelease(row, col) call MouseLeftRelease(row, col)
call assert_equal(1, &cmdheight) call assert_equal(1, &cmdheight, msg)
call assert_equal(rowstatusline, winheight(0) + 1) call assert_equal(rowstatusline, winheight(0) + 1, msg)
endfor endfor
let &mouse = save_mouse let &mouse = save_mouse
@@ -207,6 +211,7 @@ func Test_xterm_mouse_click_tab()
let row = 1 let row = 1
for ttymouse_val in ['xterm', 'sgr'] for ttymouse_val in ['xterm', 'sgr']
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
e Xfoo e Xfoo
tabnew Xbar tabnew Xbar
@@ -215,7 +220,7 @@ func Test_xterm_mouse_click_tab()
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
\ ' Xfoo', \ ' Xfoo',
\ 'Tab page 2', \ 'Tab page 2',
\ '> Xbar'], a) \ '> Xbar'], a, msg)
" Test clicking on tab names in the tabline at the top. " Test clicking on tab names in the tabline at the top.
let col = 2 let col = 2
@@ -226,7 +231,7 @@ func Test_xterm_mouse_click_tab()
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
\ '> Xfoo', \ '> Xfoo',
\ 'Tab page 2', \ 'Tab page 2',
\ ' Xbar'], a) \ ' Xbar'], a, msg)
let col = 9 let col = 9
call MouseLeftClick(row, col) call MouseLeftClick(row, col)
@@ -235,7 +240,7 @@ func Test_xterm_mouse_click_tab()
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
\ ' Xfoo', \ ' Xfoo',
\ 'Tab page 2', \ 'Tab page 2',
\ '> Xbar'], a) \ '> Xbar'], a, msg)
%bwipe! %bwipe!
endfor endfor
@@ -258,6 +263,7 @@ func Test_xterm_mouse_click_X_to_close_tab()
" When 'ttymouse' is 'xterm', row/col bigger than 223 are not supported. " When 'ttymouse' is 'xterm', row/col bigger than 223 are not supported.
continue continue
endif endif
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
e Xtab1 e Xtab1
tabnew Xtab2 tabnew Xtab2
@@ -270,7 +276,7 @@ func Test_xterm_mouse_click_X_to_close_tab()
\ 'Tab page 2', \ 'Tab page 2',
\ '> Xtab2', \ '> Xtab2',
\ 'Tab page 3', \ 'Tab page 3',
\ ' Xtab3'], a) \ ' Xtab3'], a, msg)
" Click on "X" in tabline to close current tab i.e. Xtab2. " Click on "X" in tabline to close current tab i.e. Xtab2.
redraw redraw
@@ -280,7 +286,7 @@ func Test_xterm_mouse_click_X_to_close_tab()
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
\ ' Xtab1', \ ' Xtab1',
\ 'Tab page 2', \ 'Tab page 2',
\ '> Xtab3'], a) \ '> Xtab3'], a, msg)
%bwipe! %bwipe!
endfor endfor
@@ -299,6 +305,7 @@ func Test_xterm_mouse_drag_to_move_tab()
let row = 1 let row = 1
for ttymouse_val in ['xterm', 'sgr'] for ttymouse_val in ['xterm', 'sgr']
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
e Xtab1 e Xtab1
tabnew Xtab2 tabnew Xtab2
@@ -307,14 +314,14 @@ func Test_xterm_mouse_drag_to_move_tab()
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
\ ' Xtab1', \ ' Xtab1',
\ 'Tab page 2', \ 'Tab page 2',
\ '> Xtab2'], a) \ '> Xtab2'], a, msg)
redraw redraw
" Click in tab2 and drag it to tab1. " Click in tab2 and drag it to tab1.
" Check getcharmod() to verify that click is not " Check getcharmod() to verify that click is not
" interpreted as a spurious double-click. " interpreted as a spurious double-click.
call MouseLeftClick(row, 10) call MouseLeftClick(row, 10)
call assert_equal(0, getcharmod()) call assert_equal(0, getcharmod(), msg)
for col in [9, 8, 7, 6] for col in [9, 8, 7, 6]
call MouseLeftDrag(row, col) call MouseLeftDrag(row, col)
endfor endfor
@@ -323,7 +330,7 @@ func Test_xterm_mouse_drag_to_move_tab()
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
\ '> Xtab2', \ '> Xtab2',
\ 'Tab page 2', \ 'Tab page 2',
\ ' Xtab1'], a) \ ' Xtab1'], a, msg)
" brief sleep to avoid causing a double-click " brief sleep to avoid causing a double-click
sleep 20m sleep 20m
@@ -347,6 +354,7 @@ func Test_xterm_mouse_double_click_to_create_tab()
let col = 10 let col = 10
for ttymouse_val in ['xterm', 'sgr'] for ttymouse_val in ['xterm', 'sgr']
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' . ttymouse_val exe 'set ttymouse=' . ttymouse_val
e Xtab1 e Xtab1
tabnew Xtab2 tabnew Xtab2
@@ -355,16 +363,16 @@ func Test_xterm_mouse_double_click_to_create_tab()
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
\ ' Xtab1', \ ' Xtab1',
\ 'Tab page 2', \ 'Tab page 2',
\ '> Xtab2'], a) \ '> Xtab2'], a, msg)
redraw redraw
call MouseLeftClick(row, col) call MouseLeftClick(row, col)
" Check getcharmod() to verify that first click is not " Check getcharmod() to verify that first click is not
" interpreted as a spurious double-click. " interpreted as a spurious double-click.
call assert_equal(0, getcharmod()) call assert_equal(0, getcharmod(), msg)
call MouseLeftRelease(row, col) call MouseLeftRelease(row, col)
call MouseLeftClick(row, col) call MouseLeftClick(row, col)
call assert_equal(32, getcharmod()) " double-click call assert_equal(32, getcharmod(), msg) " double-click
call MouseLeftRelease(row, col) call MouseLeftRelease(row, col)
let a = split(execute(':tabs'), "\n") let a = split(execute(':tabs'), "\n")
call assert_equal(['Tab page 1', call assert_equal(['Tab page 1',
@@ -372,7 +380,7 @@ func Test_xterm_mouse_double_click_to_create_tab()
\ 'Tab page 2', \ 'Tab page 2',
\ '> [No Name]', \ '> [No Name]',
\ 'Tab page 3', \ 'Tab page 3',
\ ' Xtab2'], a) \ ' Xtab2'], a, msg)
if ttymouse_val !=# 'sgr' if ttymouse_val !=# 'sgr'
" We need to sleep, or else MouseLeftClick() in next loop " We need to sleep, or else MouseLeftClick() in next loop

View File

@@ -771,6 +771,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1178,
/**/ /**/
1177, 1177,
/**/ /**/