view src/testdir/test_winbar.vim @ 16519:a147acab726f v8.1.1263

patch 8.1.1263: mouse clicks in WinBar not tested commit https://github.com/vim/vim/commit/66f83111520f299e688eb15e3cb95ec1fa10ba10 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 4 16:06:12 2019 +0200 patch 8.1.1263: mouse clicks in WinBar not tested Problem: Mouse clicks in WinBar not tested. Solution: Add a test for clicking on the WinBar entries.
author Bram Moolenaar <Bram@vim.org>
date Sat, 04 May 2019 16:15:05 +0200
parents 3f16cf18386c
children 1bf49cd87e6b
line wrap: on
line source

" Test WinBar

if !has('menu')
  finish
endif

func Test_add_remove_menu()
  new
  amenu 1.10 WinBar.Next :let g:did_next = 11<CR>
  amenu 1.20 WinBar.Cont :let g:did_cont = 12<CR>
  emenu WinBar.Next
  call assert_equal(11, g:did_next)
  emenu WinBar.Cont
  call assert_equal(12, g:did_cont)

  wincmd w
  call assert_fails('emenu WinBar.Next', 'E334')
  wincmd p

  aunmenu WinBar.Next
  aunmenu WinBar.Cont
  close
endfunc

func Test_click_in_winbar()
  new
  amenu 1.10 WinBar.Next :let g:did_next = 11<CR>
  amenu 1.20 WinBar.Cont :let g:did_cont = 12<CR>
  amenu 1.30 WinBar.Close :close<CR>
  redraw

  let save_mouse = &mouse
  set mouse=a

  " Columns of the button edges:
  " _Next_  _Cont_  _Close_
  " 2    7  10  15  18   24
  let g:did_next = 0
  let g:did_cont = 0
  for col in [1, 8, 9, 16, 17, 25, 26]
    call test_setmouse(1, 1)
    call feedkeys("\<LeftMouse>", "xt")
    call assert_equal(0, g:did_next, 'col ' .. col)
    call assert_equal(0, g:did_cont, 'col ' .. col)
  endfor

  for col in range(2, 7)
    let g:did_next = 0
    call test_setmouse(1, col)
    call feedkeys("\<LeftMouse>", "xt")
    call assert_equal(11, g:did_next, 'col ' .. col)
  endfor

  for col in range(10, 15)
    let g:did_cont = 0
    call test_setmouse(1, col)
    call feedkeys("\<LeftMouse>", "xt")
    call assert_equal(12, g:did_cont, 'col ' .. col)
  endfor

  let wincount = winnr('$')
  call test_setmouse(1, 20)
  call feedkeys("\<LeftMouse>", "xt")
  call assert_equal(wincount - 1, winnr('$'))

  let &mouse = save_mouse
endfunc