Patch 8.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)
Files:      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


*** ../vim-8.2.4227/runtime/doc/builtin.txt     2022-01-18 20:51:29.702559521 
+0000
--- runtime/doc/builtin.txt     2022-01-27 13:13:11.903319402 +0000
***************
*** 645,650 ****
--- 645,653 ----
                                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
*** ../vim-8.2.4227/runtime/doc/testing.txt     2022-01-20 14:57:18.280528244 
+0000
--- runtime/doc/testing.txt     2022-01-27 13:13:11.903319402 +0000
***************
*** 117,122 ****
--- 121,144 ----
                |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
*** ../vim-8.2.4227/runtime/doc/usr_41.txt      2022-01-10 13:36:31.264892417 
+0000
--- runtime/doc/usr_41.txt      2022-01-27 13:13:11.907319344 +0000
***************
*** 1027,1032 ****
--- 1118,1125 ----
        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
*** ../vim-8.2.4227/src/evalfunc.c      2022-01-26 21:01:11.192928481 +0000
--- src/evalfunc.c      2022-01-27 13:13:11.907319344 +0000
***************
*** 2330,2335 ****
--- 2330,2339 ----
                        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,
*** ../vim-8.2.4227/src/normal.c        2022-01-26 12:14:10.674341349 +0000
--- src/normal.c        2022-01-27 13:13:11.907319344 +0000
***************
*** 2801,2808 ****
  }
  
  /*
!  * Get the count specified after a 'z' command. Returns TRUE to process
!  * the 'z' command and FALSE to skip it.
   */
      static int
  nv_z_get_count(cmdarg_T *cap, int *nchar_arg)
--- 2801,2809 ----
  }
  
  /*
!  * 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)
*** ../vim-8.2.4227/src/proto/testing.pro       2021-06-23 19:46:46.914256853 
+0100
--- src/proto/testing.pro       2022-01-27 13:13:11.911319285 +0000
***************
*** 35,40 ****
--- 35,42 ----
  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 : */
*** ../vim-8.2.4227/src/testdir/test_diffmode.vim       2022-01-16 
15:00:04.936316085 +0000
--- src/testdir/test_diffmode.vim       2022-01-27 13:13:11.911319285 +0000
***************
*** 1464,1467 ****
--- 1464,1513 ----
    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
*** ../vim-8.2.4227/src/testdir/test_gui.vim    2021-12-26 10:51:33.711079465 
+0000
--- src/testdir/test_gui.vim    2022-01-27 13:13:11.911319285 +0000
***************
*** 1266,1269 ****
--- 1266,1322 ----
    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
*** ../vim-8.2.4227/src/testdir/test_normal.vim 2022-01-03 11:15:40.756705643 
+0000
--- src/testdir/test_normal.vim 2022-01-27 13:13:11.911319285 +0000
***************
*** 891,896 ****
--- 891,897 ----
  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,936 ****
    call assert_equal(10, winheight(0))
    exe "norm! z12\<cr>"
    call assert_equal(12, winheight(0))
!   exe "norm! z10\<cr>"
    call assert_equal(10, winheight(0))
  
    " Test for z.
--- 931,937 ----
    call assert_equal(10, winheight(0))
    exe "norm! z12\<cr>"
    call assert_equal(12, winheight(0))
!   exe "norm! z15\<Del>0\<cr>"
    call assert_equal(10, winheight(0))
  
    " Test for z.
*** ../vim-8.2.4227/src/testing.c       2022-01-20 14:57:18.280528244 +0000
--- src/testing.c       2022-01-27 13:13:11.911319285 +0000
***************
*** 1340,1345 ****
--- 1340,1379 ----
  }
  
      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)
*** ../vim-8.2.4227/src/version.c       2022-01-26 21:32:55.691520478 +0000
--- src/version.c       2022-01-27 13:13:51.954735337 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4228,
  /**/

-- 
Did Adam and Eve have navels?

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220127131851.09F8D1C4EFA%40moolenaar.net.

Raspunde prin e-mail lui