mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
patch 8.2.4228: no tests for clicking in the GUI tabline
Problem: No tests for clicking in the GUI tabline. Solution: Add test functions to generate the events. Add tests using the functions. (Yegappan Lakshmanan, closes #9638)
This commit is contained in:
committed by
Bram Moolenaar
parent
e939f5ebba
commit
b0ad2d92fd
@ -645,6 +645,9 @@ test_gui_drop_files({list}, {row}, {col}, {mods})
|
||||
none drop a list of files in a window
|
||||
test_gui_mouse_event({button}, {row}, {col}, {repeated}, {mods})
|
||||
none add a mouse event to the input buffer
|
||||
test_gui_tabline_event({tabnr}) Bool add a tabline event to the input buffer
|
||||
test_gui_tabmenu_event({tabnr}, {event})
|
||||
none add a tabmenu event to the input buffer
|
||||
test_ignore_error({expr}) none ignore a specific error
|
||||
test_null_blob() Blob null value for testing
|
||||
test_null_channel() Channel null value for testing
|
||||
|
@ -121,6 +121,24 @@ test_gui_mouse_event({button}, {row}, {col}, {multiclick}, {modifiers})
|
||||
|feedkeys()| to have them processed, e.g.: >
|
||||
call feedkeys("y", 'Lx!')
|
||||
|
||||
*test_gui_tabline_event()*
|
||||
test_gui_tabline_event({tabnr})
|
||||
Add an event that simulates a click on the tabline to select
|
||||
tabpage {tabnr} to the input buffer.
|
||||
Returns TRUE if the event is successfully added, FALSE if
|
||||
already in the tabpage {tabnr} or the cmdline window is open.
|
||||
After injecting the event you probably should call
|
||||
|feedkeys()| to have them processed, e.g.: >
|
||||
call feedkeys("y", 'Lx!')
|
||||
|
||||
*test_gui_tabmenu_event()*
|
||||
test_gui_tabmenu_event({tabnr}, {event})
|
||||
Add an event that simulates selecting a tabline menu entry for
|
||||
tabpage {tabnr} to the input buffer. {event} is 1 for the
|
||||
first menu entry, 2 for the second entry and so on.
|
||||
After injecting the event you probably should call
|
||||
|feedkeys()| to have them processed, e.g.: >
|
||||
call feedkeys("y", 'Lx!')
|
||||
|
||||
test_ignore_error({expr}) *test_ignore_error()*
|
||||
Ignore any error containing {expr}. A normal message is given
|
||||
|
@ -1118,6 +1118,8 @@ Testing: *test-functions*
|
||||
test_getvalue() get value of an internal variable
|
||||
test_gui_drop_files() drop file(s) in a window
|
||||
test_gui_mouse_event() add a GUI mouse event to the input buffer
|
||||
test_gui_tabline_event() add a GUI tabline event to the input buffer
|
||||
test_gui_tabmenu_event() add a GUI tabmenu event to the input buffer
|
||||
test_ignore_error() ignore a specific error message
|
||||
test_null_blob() return a null Blob
|
||||
test_null_channel() return a null Channel
|
||||
|
@ -2330,6 +2330,10 @@ static funcentry_T global_functions[] =
|
||||
ret_void, f_test_gui_drop_files},
|
||||
{"test_gui_mouse_event", 5, 5, 0, arg5_number,
|
||||
ret_void, f_test_gui_mouse_event},
|
||||
{"test_gui_tabline_event", 1, 1, 0, arg1_number,
|
||||
ret_bool, f_test_gui_tabline_event},
|
||||
{"test_gui_tabmenu_event", 2, 2, 0, arg2_number,
|
||||
ret_void, f_test_gui_tabmenu_event},
|
||||
{"test_ignore_error", 1, 1, FEARG_1, arg1_string,
|
||||
ret_void, f_test_ignore_error},
|
||||
{"test_null_blob", 0, 0, 0, NULL,
|
||||
|
@ -2801,8 +2801,9 @@ scroll_redraw(int up, long count)
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the count specified after a 'z' command. Returns TRUE to process
|
||||
* the 'z' command and FALSE to skip it.
|
||||
* Get the count specified after a 'z' command. Only the 'z<CR>', 'zl', 'zh',
|
||||
* 'z<Left>', and 'z<Right>' commands accept a count after 'z'.
|
||||
* Returns TRUE to process the 'z' command and FALSE to skip it.
|
||||
*/
|
||||
static int
|
||||
nv_z_get_count(cmdarg_T *cap, int *nchar_arg)
|
||||
|
@ -35,6 +35,8 @@ void f_test_void(typval_T *argvars, typval_T *rettv);
|
||||
void f_test_scrollbar(typval_T *argvars, typval_T *rettv);
|
||||
void f_test_setmouse(typval_T *argvars, typval_T *rettv);
|
||||
void f_test_gui_mouse_event(typval_T *argvars, typval_T *rettv);
|
||||
void f_test_gui_tabline_event(typval_T *argvars, typval_T *rettv);
|
||||
void f_test_gui_tabmenu_event(typval_T *argvars, typval_T *rettv);
|
||||
void f_test_settime(typval_T *argvars, typval_T *rettv);
|
||||
void f_test_gui_drop_files(typval_T *argvars, typval_T *rettv);
|
||||
/* vim: set ft=c : */
|
||||
|
@ -1464,4 +1464,50 @@ func Test_diff_binary()
|
||||
set diffopt&vim
|
||||
endfunc
|
||||
|
||||
" Test for using the 'zi' command to invert 'foldenable' in diff windows (test
|
||||
" for the issue fixed by patch 6.2.317)
|
||||
func Test_diff_foldinvert()
|
||||
%bw!
|
||||
edit Xfile1
|
||||
new Xfile2
|
||||
new Xfile3
|
||||
windo diffthis
|
||||
" open a non-diff window
|
||||
botright new
|
||||
1wincmd w
|
||||
call assert_true(getwinvar(1, '&foldenable'))
|
||||
call assert_true(getwinvar(2, '&foldenable'))
|
||||
call assert_true(getwinvar(3, '&foldenable'))
|
||||
normal zi
|
||||
call assert_false(getwinvar(1, '&foldenable'))
|
||||
call assert_false(getwinvar(2, '&foldenable'))
|
||||
call assert_false(getwinvar(3, '&foldenable'))
|
||||
normal zi
|
||||
call assert_true(getwinvar(1, '&foldenable'))
|
||||
call assert_true(getwinvar(2, '&foldenable'))
|
||||
call assert_true(getwinvar(3, '&foldenable'))
|
||||
|
||||
" If the current window has 'noscrollbind', then 'zi' should not change
|
||||
" 'foldenable' in other windows.
|
||||
1wincmd w
|
||||
set noscrollbind
|
||||
normal zi
|
||||
call assert_false(getwinvar(1, '&foldenable'))
|
||||
call assert_true(getwinvar(2, '&foldenable'))
|
||||
call assert_true(getwinvar(3, '&foldenable'))
|
||||
|
||||
" 'zi' should not change the 'foldenable' for windows with 'noscrollbind'
|
||||
1wincmd w
|
||||
set scrollbind
|
||||
normal zi
|
||||
call setwinvar(2, '&scrollbind', v:false)
|
||||
normal zi
|
||||
call assert_false(getwinvar(1, '&foldenable'))
|
||||
call assert_true(getwinvar(2, '&foldenable'))
|
||||
call assert_false(getwinvar(3, '&foldenable'))
|
||||
|
||||
%bw!
|
||||
set scrollbind&
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@ -1266,4 +1266,57 @@ func Test_gui_drop_files()
|
||||
cunmap <buffer> <F4>
|
||||
endfunc
|
||||
|
||||
" Test for generating a GUI tabline event to select a tab page
|
||||
func Test_gui_tabline_event()
|
||||
%bw!
|
||||
edit Xfile1
|
||||
tabedit Xfile2
|
||||
tabedit Xfile3
|
||||
|
||||
tabfirst
|
||||
call assert_equal(v:true, test_gui_tabline_event(2))
|
||||
call feedkeys("y", "Lx!")
|
||||
call assert_equal(2, tabpagenr())
|
||||
call assert_equal(v:true, test_gui_tabline_event(3))
|
||||
call feedkeys("y", "Lx!")
|
||||
call assert_equal(3, tabpagenr())
|
||||
call assert_equal(v:false, test_gui_tabline_event(3))
|
||||
|
||||
" From the cmdline window, tabline event should not be handled
|
||||
call feedkeys("q::let t = test_gui_tabline_event(2)\<CR>:q\<CR>", 'x!')
|
||||
call assert_equal(v:false, t)
|
||||
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" Test for generating a GUI tabline menu event to execute an action
|
||||
func Test_gui_tabmenu_event()
|
||||
%bw!
|
||||
|
||||
" Try to close the last tab page
|
||||
call test_gui_tabmenu_event(1, 1)
|
||||
call feedkeys("y", "Lx!")
|
||||
|
||||
edit Xfile1
|
||||
tabedit Xfile2
|
||||
call test_gui_tabmenu_event(1, 1)
|
||||
call feedkeys("y", "Lx!")
|
||||
call assert_equal(1, tabpagenr('$'))
|
||||
call assert_equal('Xfile2', bufname())
|
||||
|
||||
call test_gui_tabmenu_event(1, 2)
|
||||
call feedkeys("y", "Lx!")
|
||||
call assert_equal(2, tabpagenr('$'))
|
||||
|
||||
" If tabnr is 0, then the current tabpage should be used.
|
||||
call test_gui_tabmenu_event(0, 2)
|
||||
call feedkeys("y", "Lx!")
|
||||
call assert_equal(3, tabpagenr('$'))
|
||||
call test_gui_tabmenu_event(0, 1)
|
||||
call feedkeys("y", "Lx!")
|
||||
call assert_equal(2, tabpagenr('$'))
|
||||
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@ -891,6 +891,7 @@ endfunc
|
||||
func Test_normal_z_error()
|
||||
call assert_beeps('normal! z2p')
|
||||
call assert_beeps('normal! zq')
|
||||
call assert_beeps('normal! cz1')
|
||||
endfunc
|
||||
|
||||
func Test_normal15_z_scroll_vert()
|
||||
@ -930,7 +931,7 @@ func Test_normal15_z_scroll_vert()
|
||||
call assert_equal(10, winheight(0))
|
||||
exe "norm! z12\<cr>"
|
||||
call assert_equal(12, winheight(0))
|
||||
exe "norm! z10\<cr>"
|
||||
exe "norm! z15\<Del>0\<cr>"
|
||||
call assert_equal(10, winheight(0))
|
||||
|
||||
" Test for z.
|
||||
|
@ -1337,6 +1337,40 @@ f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
|
||||
gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), repeated_click, mods);
|
||||
# endif
|
||||
}
|
||||
|
||||
void
|
||||
f_test_gui_tabline_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
{
|
||||
# ifdef FEAT_GUI
|
||||
int tabnr;
|
||||
|
||||
if (check_for_number_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
tabnr = tv_get_number(&argvars[0]);
|
||||
|
||||
rettv->v_type = VAR_BOOL;
|
||||
rettv->vval.v_number = send_tabline_event(tabnr);
|
||||
# endif
|
||||
}
|
||||
|
||||
void
|
||||
f_test_gui_tabmenu_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
{
|
||||
# ifdef FEAT_GUI
|
||||
int tabnr;
|
||||
int event;
|
||||
|
||||
if (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL)
|
||||
return;
|
||||
|
||||
tabnr = tv_get_number(&argvars[0]);
|
||||
event = tv_get_number(&argvars[1]);
|
||||
|
||||
send_tabline_menu_event(tabnr, event);
|
||||
# endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4228,
|
||||
/**/
|
||||
4227,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user