" Tests for popup windows
source check.vim
CheckFeature textprop
source screendump.vim
func Test_simple_popup()
if !CanRunVimInTerminal()
throw 'Skipped: cannot make screendumps'
endif
call writefile([
\ "call setline(1, range(1, 100))",
\ "hi PopupColor1 ctermbg=lightblue",
\ "hi PopupColor2 ctermbg=lightcyan",
\ "hi Comment ctermfg=red",
\ "call prop_type_add('comment', {'highlight': 'Comment'})",
\ "let winid = popup_create('hello there', {'line': 3, 'col': 11, 'minwidth': 20, 'highlight': 'PopupColor1'})",
\ "let winid2 = popup_create(['another one', 'another two', 'another three'], {'line': 3, 'col': 25, 'minwidth': 20})",
\ "call setwinvar(winid2, '&wincolor', 'PopupColor2')",
\], 'XtestPopup')
let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10})
call VerifyScreenDump(buf, 'Test_popupwin_01', {})
" Add a tabpage
call term_sendkeys(buf, ":tabnew\<CR>")
call term_sendkeys(buf, ":let popupwin = popup_create(["
\ .. "{'text': 'other tab'},"
\ .. "{'text': 'a comment line', 'props': [{"
\ .. "'col': 3, 'length': 7, 'minwidth': 20, 'type': 'comment'"
\ .. "}]},"
\ .. "], {'line': 4, 'col': 9, 'minwidth': 20})\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_02', {})
" switch back to first tabpage
call term_sendkeys(buf, "gt")
call VerifyScreenDump(buf, 'Test_popupwin_03', {})
" close that tabpage
call term_sendkeys(buf, ":quit!\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_04', {})
" set 'columns' to a small value, size must be recomputed
call term_sendkeys(buf, ":let cols = &columns\<CR>")
call term_sendkeys(buf, ":set columns=12\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_04a', {})
call term_sendkeys(buf, ":let &columns = cols\<CR>")
" resize popup, show empty line at bottom
call term_sendkeys(buf, ":call popup_move(popupwin, {'minwidth': 15, 'maxwidth': 25, 'minheight': 3, 'maxheight': 5})\<CR>")
call term_sendkeys(buf, ":redraw\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_05', {})
" show not fitting line at bottom