summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-01-27 13:16:59 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-27 13:16:59 +0000
commitb0ad2d92fd19e673ddbbc66742bae3f71778efde (patch)
tree4029f2cb1c3d7b73cad2a52ede1586876949c774
parente939f5ebbae8dd7825d62d84e0c9910fa1756a9c (diff)
patch 8.2.4228: no tests for clicking in the GUI tablinev8.2.4228
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)
-rw-r--r--runtime/doc/builtin.txt3
-rw-r--r--runtime/doc/testing.txt18
-rw-r--r--runtime/doc/usr_41.txt2
-rw-r--r--src/evalfunc.c4
-rw-r--r--src/normal.c5
-rw-r--r--src/proto/testing.pro2
-rw-r--r--src/testdir/test_diffmode.vim46
-rw-r--r--src/testdir/test_gui.vim53
-rw-r--r--src/testdir/test_normal.vim3
-rw-r--r--src/testing.c34
-rw-r--r--src/version.c2
11 files changed, 169 insertions, 3 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 7bb48b8c3d..bfb63d0d59 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -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
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index fb43fbc02d..e5b9134736 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -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
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 71a4850eda..66b267f935 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -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
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 169f972c24..627ebb0b08 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -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,
diff --git a/src/normal.c b/src/normal.c
index b6c59d3108..e69c141968 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -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)
diff --git a/src/proto/testing.pro b/src/proto/testing.pro
index 0d4ff49955..b432b4f574 100644
--- a/src/proto/testing.pro
+++ b/src/proto/testing.pro
@@ -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 : */
diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index 57115de852..ea217d94e2 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
@@ -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
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index 90552843d1..aeacb31aa5 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -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
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index 4a09964e97..9fcc9fda71 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -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.
diff --git a/src/testing.c b/src/testing.c
index 4d2a942675..675eaa2499 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -1340,6 +1340,40 @@ f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
}
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
f_test_settime(typval_T *argvars, typval_T *rettv UNUSED)
{
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
diff --git a/src/version.c b/src/version.c
index e77826c079..e3a97154a9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4228,
+/**/
4227,
/**/
4226,