mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 08:56:29 +00:00
vim-patch:8.2.1025: tabpage menu and tabline not sufficiently tested
Problem: Tabpage menu and tabline not sufficiently tested.
Solution: Add tests. (Yegappan Lakshmanan, closes vim/vim#6307)
8c524f76eb
Cherry-pick Test_entering_digraph() from patch v8.2.1022.
Cherry-pick :CheckGui from patch v8.1.1826.
This commit is contained in:
@@ -74,6 +74,14 @@ func CheckCanRunGui()
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Command to check that we are using the GUI
|
||||
command CheckGui call CheckGui()
|
||||
func CheckGui()
|
||||
if !has('gui_running')
|
||||
throw 'Skipped: only works in the GUI'
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Command to check that not currently using the GUI
|
||||
command CheckNotGui call CheckNotGui()
|
||||
func CheckNotGui()
|
||||
|
@@ -1,8 +1,8 @@
|
||||
" Tests for digraphs
|
||||
|
||||
if !has("digraphs")
|
||||
finish
|
||||
endif
|
||||
source check.vim
|
||||
CheckFeature digraphs
|
||||
source term_util.vim
|
||||
|
||||
func Put_Dig(chars)
|
||||
exe "norm! o\<c-k>".a:chars
|
||||
@@ -487,4 +487,20 @@ func Test_show_digraph_cp1251()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for the characters displayed on the screen when entering a digraph
|
||||
func Test_entering_digraph()
|
||||
CheckRunVimInTerminal
|
||||
let buf = RunVimInTerminal('', {'rows': 6})
|
||||
call term_sendkeys(buf, "i\<C-K>")
|
||||
call term_wait(buf)
|
||||
call assert_equal('?', term_getline(buf, 1))
|
||||
call term_sendkeys(buf, "1")
|
||||
call term_wait(buf)
|
||||
call assert_equal('1', term_getline(buf, 1))
|
||||
call term_sendkeys(buf, "2")
|
||||
call term_wait(buf)
|
||||
call assert_equal('½', term_getline(buf, 1))
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -1,6 +1,7 @@
|
||||
" Tests for tabpage
|
||||
|
||||
source screendump.vim
|
||||
source check.vim
|
||||
|
||||
function Test_tabpage()
|
||||
bw!
|
||||
@@ -607,4 +608,82 @@ func Test_tabpage_cmdheight()
|
||||
call delete('XTest_tabpage_cmdheight')
|
||||
endfunc
|
||||
|
||||
" Return the terminal key code for selecting a tab page from the tabline. This
|
||||
" sequence contains the following codes: a CSI (0x9b), KS_TABLINE (0xf0),
|
||||
" KS_FILLER (0x58) and then the tab page number.
|
||||
func TabLineSelectPageCode(tabnr)
|
||||
return "\x9b\xf0\x58" .. nr2char(a:tabnr)
|
||||
endfunc
|
||||
|
||||
" Return the terminal key code for opening a new tabpage from the tabpage
|
||||
" menu. This sequence consists of the following codes: a CSI (0x9b),
|
||||
" KS_TABMENU (0xef), KS_FILLER (0x58), the tab page number and
|
||||
" TABLINE_MENU_NEW (2).
|
||||
func TabMenuNewItemCode(tabnr)
|
||||
return "\x9b\xef\x58" .. nr2char(a:tabnr) .. nr2char(2)
|
||||
endfunc
|
||||
|
||||
" Return the terminal key code for closing a tabpage from the tabpage menu.
|
||||
" This sequence consists of the following codes: a CSI (0x9b), KS_TABMENU
|
||||
" (0xef), KS_FILLER (0x58), the tab page number and TABLINE_MENU_CLOSE (1).
|
||||
func TabMenuCloseItemCode(tabnr)
|
||||
return "\x9b\xef\x58" .. nr2char(a:tabnr) .. nr2char(1)
|
||||
endfunc
|
||||
|
||||
" Test for using the tabpage menu from the insert and normal modes
|
||||
func Test_tabline_tabmenu()
|
||||
" only works in GUI
|
||||
CheckGui
|
||||
|
||||
%bw!
|
||||
tabnew
|
||||
tabnew
|
||||
call assert_equal(3, tabpagenr())
|
||||
|
||||
" go to tab page 2 in normal mode
|
||||
call feedkeys(TabLineSelectPageCode(2), "Lx!")
|
||||
call assert_equal(2, tabpagenr())
|
||||
|
||||
" close tab page 3 in normal mode
|
||||
call feedkeys(TabMenuCloseItemCode(3), "Lx!")
|
||||
call assert_equal(2, tabpagenr('$'))
|
||||
call assert_equal(2, tabpagenr())
|
||||
|
||||
" open new tab page before tab page 1 in normal mode
|
||||
call feedkeys(TabMenuNewItemCode(1), "Lx!")
|
||||
call assert_equal(1, tabpagenr())
|
||||
call assert_equal(3, tabpagenr('$'))
|
||||
|
||||
" go to tab page 2 in operator-pending mode (should beep)
|
||||
call assert_beeps('call feedkeys("f" .. TabLineSelectPageCode(2), "Lx!")')
|
||||
|
||||
" open new tab page before tab page 1 in operator-pending mode (should beep)
|
||||
call assert_beeps('call feedkeys("f" .. TabMenuNewItemCode(1), "Lx!")')
|
||||
|
||||
" open new tab page after tab page 3 in normal mode
|
||||
call feedkeys(TabMenuNewItemCode(4), "Lx!")
|
||||
call assert_equal(4, tabpagenr())
|
||||
call assert_equal(4, tabpagenr('$'))
|
||||
|
||||
" go to tab page 2 in insert mode
|
||||
call feedkeys("i" .. TabLineSelectPageCode(2) .. "\<C-C>", "Lx!")
|
||||
call assert_equal(2, tabpagenr())
|
||||
|
||||
" close tab page 2 in insert mode
|
||||
call feedkeys("i" .. TabMenuCloseItemCode(2) .. "\<C-C>", "Lx!")
|
||||
call assert_equal(3, tabpagenr('$'))
|
||||
|
||||
" open new tab page before tab page 3 in insert mode
|
||||
call feedkeys("i" .. TabMenuNewItemCode(3) .. "\<C-C>", "Lx!")
|
||||
call assert_equal(3, tabpagenr())
|
||||
call assert_equal(4, tabpagenr('$'))
|
||||
|
||||
" open new tab page after tab page 4 in insert mode
|
||||
call feedkeys("i" .. TabMenuNewItemCode(5) .. "\<C-C>", "Lx!")
|
||||
call assert_equal(5, tabpagenr())
|
||||
call assert_equal(5, tabpagenr('$'))
|
||||
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user