test: popupmenu placement

This commit is contained in:
rpigott 2018-08-30 21:00:04 -07:00 committed by Justin M. Keyes
parent a5fe6d34a9
commit 59c5c4f006

View File

@ -12,6 +12,9 @@ describe('ui/ext_popupmenu', function()
screen:set_default_attr_ids({
[1] = {bold=true, foreground=Screen.colors.Blue},
[2] = {bold = true},
[3] = {reverse = true},
[4] = {bold = true, reverse = true},
[5] = {bold = true, foreground = Screen.colors.SeaGreen}
})
end)
@ -89,3 +92,139 @@ describe('ui/ext_popupmenu', function()
]]}
end)
end)
describe('popup placement', function()
local screen
before_each(function()
clear()
screen = Screen.new(32, 20)
screen:attach()
screen:set_default_attr_ids({
-- popup selected item / scrollbar track
['s'] = {background = Screen.colors.WebGray},
-- popup non-selected item
['n'] = {background = Screen.colors.LightMagenta},
-- popup scrollbar knob
['c'] = {background = Screen.colors.Grey0},
[1] = {bold = true, foreground = Screen.colors.Blue},
[2] = {bold = true},
[3] = {reverse = true},
[4] = {bold = true, reverse = true},
[5] = {bold = true, foreground = Screen.colors.SeaGreen}
})
end)
it('works with preview-window above', function()
feed(':ped<CR><c-w>4+')
feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
feed('<c-x><c-n>')
screen:expect([[
aa bb cc dd ee ff gg hh ii jj |
aa |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{3:[No Name] [Preview][+] }|
aa bb cc dd ee ff gg hh ii jj |
aa^ |
{s:aa }{c: }{1: }|
{n:bb }{c: }{1: }|
{n:cc }{c: }{1: }|
{n:dd }{c: }{1: }|
{n:ee }{c: }{1: }|
{n:ff }{c: }{1: }|
{n:gg }{s: }{1: }|
{n:hh }{s: }{4: }|
{2:-- }{5:match 1 of 10} |
]])
end)
it('works with preview-window below', function()
feed(':ped<CR><c-w>4+<c-w>r')
feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
feed('<c-x><c-n>')
screen:expect([[
aa bb cc dd ee ff gg hh ii jj |
aa^ |
{s:aa }{c: }{1: }|
{n:bb }{c: }{1: }|
{n:cc }{c: }{1: }|
{n:dd }{c: }{1: }|
{n:ee }{c: }{1: }|
{n:ff }{c: }{1: }|
{n:gg }{s: }{1: }|
{n:hh }{s: }{4: }|
aa bb cc dd ee ff gg hh ii jj |
aa |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{3:[No Name] [Preview][+] }|
{2:-- }{5:match 1 of 10} |
]])
end)
it('works with preview-window above and inverted', function()
feed(':ped<CR><c-w>4+')
feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
feed('<c-x><c-n>')
screen:expect([[
aa |
bb |
cc |
dd |
ee |
ff |
gg |
hh |
{3:[No Name] [Preview][+] }|
cc |
dd |
ee |
ff |
gg |
hh |
{s:aa }{c: } |
{n:bb }{s: } |
aa^ |
{4:[No Name] [+] }|
{2:-- }{5:match 1 of 10} |
]])
end)
it('works with preview-window below and inverted', function()
feed(':ped<CR><c-w>4+<c-w>r')
feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
feed('<c-x><c-n>')
screen:expect([[
{s:aa }{c: } |
{n:bb }{c: } |
{n:cc }{c: } |
{n:dd }{c: } |
{n:ee }{c: } |
{n:ff }{c: } |
{n:gg }{s: } |
{n:hh }{s: } |
aa^ |
{4:[No Name] [+] }|
aa |
bb |
cc |
dd |
ee |
ff |
gg |
hh |
{3:[No Name] [Preview][+] }|
{2:-- }{5:match 1 of 10} |
]])
end)
end)