2016-11-15 10:06:10 -07:00
|
|
|
" Tests for the getbufinfo(), getwininfo() and gettabinfo() functions
|
|
|
|
|
|
|
|
function Test_getbufwintabinfo()
|
|
|
|
1,$bwipeout
|
|
|
|
edit Xtestfile1
|
|
|
|
edit Xtestfile2
|
|
|
|
let buflist = getbufinfo()
|
|
|
|
call assert_equal(2, len(buflist))
|
|
|
|
call assert_match('Xtestfile1', buflist[0].name)
|
|
|
|
call assert_match('Xtestfile2', getbufinfo('Xtestfile2')[0].name)
|
|
|
|
call assert_equal([], getbufinfo(2016))
|
|
|
|
edit Xtestfile1
|
|
|
|
hide edit Xtestfile2
|
|
|
|
hide enew
|
|
|
|
call assert_equal(3, len(getbufinfo({'bufloaded':1})))
|
|
|
|
|
2016-11-15 11:41:01 -07:00
|
|
|
set tabstop&vim
|
|
|
|
let b:editor = 'vim'
|
|
|
|
let l = getbufinfo('%')
|
|
|
|
call assert_equal(bufnr('%'), l[0].nr)
|
|
|
|
call assert_equal(8, l[0].options.tabstop)
|
|
|
|
call assert_equal('vim', l[0].variables.editor)
|
|
|
|
call assert_notequal(-1, index(l[0].windows, bufwinid('%')))
|
|
|
|
|
|
|
|
if has('signs')
|
|
|
|
call append(0, ['Linux', 'Windows', 'Mac'])
|
|
|
|
sign define Mark text=>> texthl=Search
|
|
|
|
exe "sign place 2 line=3 name=Mark buffer=" . bufnr('%')
|
|
|
|
let l = getbufinfo('%')
|
|
|
|
call assert_equal(2, l[0].signs[0].id)
|
|
|
|
call assert_equal(3, l[0].signs[0].lnum)
|
|
|
|
call assert_equal('Mark', l[0].signs[0].name)
|
|
|
|
sign unplace *
|
|
|
|
sign undefine Mark
|
|
|
|
enew!
|
|
|
|
endif
|
|
|
|
|
2016-11-15 10:06:10 -07:00
|
|
|
only
|
|
|
|
let w1_id = win_getid()
|
|
|
|
new
|
|
|
|
let w2_id = win_getid()
|
|
|
|
tabnew | let w3_id = win_getid()
|
|
|
|
new | let w4_id = win_getid()
|
|
|
|
new | let w5_id = win_getid()
|
2016-11-15 11:41:01 -07:00
|
|
|
call setwinvar(0, 'signal', 'green')
|
2016-11-15 10:06:10 -07:00
|
|
|
tabfirst
|
|
|
|
let winlist = getwininfo()
|
|
|
|
call assert_equal(5, len(winlist))
|
2016-11-15 11:41:01 -07:00
|
|
|
call assert_equal(winbufnr(2), winlist[1].bufnum)
|
|
|
|
call assert_equal(winheight(2), winlist[1].height)
|
|
|
|
call assert_equal(1, winlist[2].nr)
|
|
|
|
call assert_equal('auto', winlist[0].options.signcolumn)
|
2016-11-15 10:06:10 -07:00
|
|
|
call assert_equal(2, winlist[3].tpnr)
|
2016-11-15 11:41:01 -07:00
|
|
|
call assert_equal('green', winlist[2].variables.signal)
|
|
|
|
call assert_equal(winwidth(1), winlist[0].width)
|
|
|
|
call assert_equal(w4_id, winlist[3].winid)
|
2016-11-15 10:06:10 -07:00
|
|
|
let winfo = getwininfo(w5_id)[0]
|
|
|
|
call assert_equal(2, winfo.tpnr)
|
|
|
|
call assert_equal([], getwininfo(3))
|
|
|
|
|
2016-11-15 11:41:01 -07:00
|
|
|
call settabvar(1, 'space', 'build')
|
2016-11-15 10:06:10 -07:00
|
|
|
let tablist = gettabinfo()
|
|
|
|
call assert_equal(2, len(tablist))
|
|
|
|
call assert_equal(3, len(tablist[1].windows))
|
2016-11-15 11:41:01 -07:00
|
|
|
call assert_equal(2, tablist[1].nr)
|
|
|
|
call assert_equal('build', tablist[0].variables.space)
|
|
|
|
call assert_equal(w2_id, tablist[0].windows[0])
|
2016-11-15 10:06:10 -07:00
|
|
|
call assert_equal([], gettabinfo(3))
|
|
|
|
|
|
|
|
tabonly | only
|
2016-11-15 11:41:01 -07:00
|
|
|
|
|
|
|
lexpr ''
|
|
|
|
lopen
|
|
|
|
copen
|
|
|
|
let winlist = getwininfo()
|
|
|
|
call assert_false(winlist[0].quickfix)
|
|
|
|
call assert_false(winlist[0].loclist)
|
|
|
|
call assert_true(winlist[1].quickfix)
|
|
|
|
call assert_true(winlist[1].loclist)
|
|
|
|
call assert_true(winlist[2].quickfix)
|
|
|
|
call assert_false(winlist[2].loclist)
|
|
|
|
wincmd t | only
|
2016-11-15 10:06:10 -07:00
|
|
|
endfunction
|