]> granicus.if.org Git - vim/commitdiff
patch 8.2.4228: no tests for clicking in the GUI tabline v8.2.4228
authorYegappan Lakshmanan <yegappan@yahoo.com>
Thu, 27 Jan 2022 13:16:59 +0000 (13:16 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 27 Jan 2022 13:16:59 +0000 (13:16 +0000)
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)

runtime/doc/builtin.txt
runtime/doc/testing.txt
runtime/doc/usr_41.txt
src/evalfunc.c
src/normal.c
src/proto/testing.pro
src/testdir/test_diffmode.vim
src/testdir/test_gui.vim
src/testdir/test_normal.vim
src/testing.c
src/version.c

index 7bb48b8c3d7d509321c8885a2fd5092dfdc0883e..bfb63d0d59ab08f4ba68cf5646939dc875fa921a 100644 (file)
@@ -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
index fb43fbc02d76b3763f7d32082d6d1351bf685513..e5b91347364abb8784bdab5074885be7fc59ccab 100644 (file)
@@ -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
index 71a4850eda4366c9d60a2c61bf37334b18784b72..66b267f935f6fb481623760bc3a41999d792a50a 100644 (file)
@@ -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
index 169f972c24304a59aac768f5fe1bd26f70cbf730..627ebb0b085dc453c6148f9d096d08bdde9938c0 100644 (file)
@@ -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,
index b6c59d3108cbe562658bc58f88ca860381da5863..e69c14196824b67ee68c6222671c182beb049489 100644 (file)
@@ -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)
index 0d4ff4995532c54620f778f8c7978b9a49046c69..b432b4f57412fad283794226a91bfb3c45738e29 100644 (file)
@@ -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 : */
index 57115de852c23e5f532fd43d23f9ab8622e392fd..ea217d94e262aef32abe6af60873ab351aca9658 100644 (file)
@@ -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
index 90552843d1cf9239fcb3f6ba66007f4a9bd21e1d..aeacb31aa5ad62b983e2a3ad3d2ff26600d81aab 100644 (file)
@@ -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
index 4a09964e970b61e5e3c84da5e9f5d9a00a77e49b..9fcc9fda71c9133879f664f1edfb0947a010af81 100644 (file)
@@ -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.
index 4d2a942675110f96be24c6b8a499e6f623179397..675eaa2499798cb7d2c6d7b61e539ab984b2ae00 100644 (file)
@@ -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
index e77826c079ac2d138c9b0f68c73e29d066ad173d..e3a97154a9f5554e25586ac70632fde594ba3c14 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4228,
 /**/
     4227,
 /**/