Skip to content

Commit

Permalink
WIP: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bfredl committed May 24, 2017
1 parent d7ceb26 commit 42213ed
Showing 1 changed file with 103 additions and 21 deletions.
124 changes: 103 additions & 21 deletions test/functional/ui/highlight_spec.lua
Expand Up @@ -5,6 +5,7 @@ local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command = helpers.command
local eval, exc_exec = helpers.eval, helpers.exc_exec
local feed_command, request, eq = helpers.feed_command, helpers.request, helpers.eq
local curbufmeths = helpers.curbufmeths

describe('colorscheme compatibility', function()
before_each(function()
Expand Down Expand Up @@ -670,20 +671,31 @@ describe("'winhighlight' highlight", function()
[8] = {background = Screen.colors.DarkMagenta, bold = true, foreground = Screen.colors.Blue1},
[9] = {foreground = Screen.colors.Brown},
[10] = {foreground = Screen.colors.Brown, background = Screen.colors.DarkBlue},
[11] = {background = Screen.colors.DarkBlue, bold = true, reverse = true},
[12] = {background = Screen.colors.DarkGreen, reverse = true},
[13] = {background = Screen.colors.Magenta4, reverse = true},
[14] = {background = Screen.colors.DarkBlue, reverse = true},
[15] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[16] = {foreground = Screen.colors.Blue1},
[17] = {background = Screen.colors.LightRed},
[18] = {background = Screen.colors.Gray90},
[19] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray},
[20] = {background = Screen.colors.LightGrey, underline = true},
[21] = {bold = true},
})
command("hi Background1 guibg=DarkBlue")
command("hi Background2 guibg=DarkGreen")
end)

it('works', function()
it('works for background color', function()
insert("aa")
command("split")
command("set winhl=Normal:Background1")
screen:expect([[
{1:a^a }|
{2:~ }|
{2:~ }|
{3:[No Name] [+] }|
{11:[No Name] [+] }|
aa |
{0:~ }|
{4:[No Name] [+] }|
Expand All @@ -695,7 +707,7 @@ describe("'winhighlight' highlight", function()
{1:^ }|
{2:~ }|
{2:~ }|
{3:[No Name] }|
{11:[No Name] }|
aa |
{0:~ }|
{4:[No Name] [+] }|
Expand Down Expand Up @@ -740,7 +752,7 @@ describe("'winhighlight' highlight", function()
{1:a^a }|
{2:~ }|
{2:~ }|
{3:[No Name] [+] }|
{11:[No Name] [+] }|
aa |
{0:~ }|
{4:[No Name] [+] }|
Expand All @@ -764,7 +776,7 @@ describe("'winhighlight' highlight", function()
{1:^aa }|
{2:~ }|
{2:~ }|
{3:[No Name] [+] }|
{11:[No Name] [+] }|
aa |
{0:~ }|
{4:[No Name] [+] }|
Expand All @@ -773,18 +785,18 @@ describe("'winhighlight' highlight", function()

end)

it('for inactive window works', function()
it('for inactive window background works', function()
command("set winhl=Normal:Background1,NormalNC:Background2")
-- tests global value is copied across split
command("split")
screen:expect([[
{1:^ }|
{2:~ }|
{2:~ }|
{3:[No Name] }|
{11:[No Name] }|
{5: }|
{6:~ }|
{4:[No Name] }|
{12:[No Name] }|
|
]])

Expand All @@ -793,10 +805,10 @@ describe("'winhighlight' highlight", function()
{5: }|
{6:~ }|
{6:~ }|
{4:[No Name] }|
{12:[No Name] }|
{1:^ }|
{2:~ }|
{3:[No Name] }|
{11:[No Name] }|
|
]])

Expand All @@ -805,10 +817,10 @@ describe("'winhighlight' highlight", function()
{1:^ }|
{2:~ }|
{2:~ }|
{3:[No Name] }|
{11:[No Name] }|
{5: }|
{6:~ }|
{4:[No Name] }|
{12:[No Name] }|
|
]])

Expand All @@ -825,7 +837,7 @@ describe("'winhighlight' highlight", function()
{3:[No Name] }|
{7: }|
{8:~ }|
{4:[No Name] }|
{13:[No Name] }|
|
]])

Expand All @@ -834,7 +846,7 @@ describe("'winhighlight' highlight", function()
{7: }|
{8:~ }|
{8:~ }|
{4:[No Name] }|
{13:[No Name] }|
^ |
{0:~ }|
{3:[No Name] }|
Expand All @@ -848,10 +860,10 @@ describe("'winhighlight' highlight", function()
{7: }|
{8:~ }|
{8:~ }|
{4:[No Name] }|
{13:[No Name] }|
{1:^ }|
{2:~ }|
{3:[No Name] }|
{11:[No Name] }|
|
]])

Expand All @@ -863,7 +875,7 @@ describe("'winhighlight' highlight", function()
{3:[No Name] }|
{1: }|
{2:~ }|
{4:[No Name] }|
{14:[No Name] }|
|
]])

Expand All @@ -873,10 +885,10 @@ describe("'winhighlight' highlight", function()
{7: }|
{8:~ }|
{8:~ }|
{4:[No Name] }|
{13:[No Name] }|
{1:^ }|
{2:~ }|
{3:[No Name] }|
{11:[No Name] }|
|
]])

Expand All @@ -888,13 +900,13 @@ describe("'winhighlight' highlight", function()
{3:[No Name] }|
{5: }|
{6:~ }|
{4:[No Name] }|
{12:[No Name] }|
|
]])

end)

it('applies also to non-text', function()
it('background applies also to non-text', function()
insert('Lorem ipsum dolor sit amet ')
command('set shiftwidth=2')
feed('>>')
Expand Down Expand Up @@ -940,6 +952,76 @@ describe("'winhighlight' highlight", function()
|
]])
end)

it('can override NonText, Conceal and EndOfBuffer', function()
curbufmeths.set_lines(0,-1,true, {"raa\000"})
command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})')
command('set cole=2 cocu=nvic')
command('split')
command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})')
command('set winhl=SpecialKey:ErrorMsg,EndOfBuffer:Background1,Conceal:Background2')

screen:expect([[
^r{5:#}a{15:^@} |
{1:~ }|
{1:~ }|
{3:[No Name] [+] }|
r{19:#}a{16:^@} |
{0:~ }|
{4:[No Name] [+] }|
|
]])
end)

it('can override LineNr, CursorColumn and ColorColumn', function()
insert('very text\nmore text')
command('set number')
command('set colorcolumn=2')
command('set cursorcolumn')

command('split')
command('set winhl=LineNr:Background1,CursorColumn:Background2,ColorColumn:ErrorMsg')
screen:expect([[
{1: 1 }v{15:e}ry tex{5:t} |
{1: 2 }m{15:o}re tex^t |
{0:~ }|
{3:[No Name] [+] }|
{9: 1 }v{17:e}ry tex{18:t} |
{9: 2 }m{17:o}re text |
{4:[No Name] [+] }|
|
]])
end)

it('can override Tabline', function()
command('tabnew')
command('set winhl=TabLine:Background1,TabLineSel:ErrorMsg')

screen:expect([[
{20: No Name] }{15: No Name]}{20:X}|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
command("tabnext")
screen:expect([[
{21: No Name] }{1: No Name]}{20:X}|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)

--, ModeMsg and PopupMenu

end)


0 comments on commit 42213ed

Please sign in to comment.