diff options
Diffstat (limited to 'test/functional/ui/embed_spec.lua')
| -rw-r--r-- | test/functional/ui/embed_spec.lua | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index 3bc3af9853..072c9e89ce 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -38,10 +38,7 @@ local function test_embed(ext_linegrid) it('can display errors', function() startup('--cmd', 'echoerr invalid+') screen:expect([[ - | - | - | - | + |*4 {6: }| {7:Error detected while processing pre-vimrc command line:} | {7:E121: Undefined variable: invalid} | @@ -51,12 +48,7 @@ local function test_embed(ext_linegrid) feed('<cr>') screen:expect([[ ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*6 | ]]) end) @@ -67,9 +59,7 @@ local function test_embed(ext_linegrid) end startup('--cmd', 'echoerr "foo"', '--cmd', 'color default', '--cmd', 'echoerr "bar"') screen:expect([[ - | - | - | + |*3 {9: }| {7:Error detected while processing pre-vimrc command line:} | {7:foo} | @@ -81,9 +71,7 @@ local function test_embed(ext_linegrid) it("doesn't erase output when setting Normal colors", function() startup('--cmd', 'echoerr "foo"', '--cmd', 'hi Normal guibg=Green', '--cmd', 'echoerr "bar"') screen:expect{grid=[[ - | - | - | + |*3 {6: }| {7:Error detected while processing pre-vimrc command line:} | {7:foo} | @@ -122,11 +110,7 @@ describe('--embed UI', function() screen:expect{grid=[[ ^hello nvim | from external input | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]} @@ -136,13 +120,43 @@ describe('--embed UI', function() hello nvim | ^ | from external input | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {2:-- INSERT --} | ]]} end) + + it("only sets background colors once even if overridden", function() + local screen, current, seen + local function handle_default_colors_set(_, _, rgb_bg, _, _, _) + seen[rgb_bg] = true + current = rgb_bg + end + local function startup(...) + seen = {} + current = nil + clear {args_rm={'--headless'}, args={...}} + + -- attach immediately after startup, for early UI + screen = Screen.new(40, 8) + screen._handle_default_colors_set = handle_default_colors_set + screen:attach() + end + + startup() + screen:expect{condition=function() + eq(16777215, current) + end} + eq({[16777215]=true}, seen) + + -- NB: by accident how functional/helpers.lua currently handles the default color scheme, the + -- above is sufficient to test the behavior. But in case that workaround is removed, we need + -- a test with an explicit override like below, so do it to remain safe. + startup('--cmd', 'hi NORMAL guibg=#FF00FF') + screen:expect{condition=function() + eq(16711935, current) + end} + eq({[16711935]=true}, seen) -- we only saw the last one, despite 16777215 was set internally earlier + end) end) describe('--embed --listen UI', function() @@ -175,9 +189,7 @@ describe('--embed --listen UI', function() child_screen:attach(nil, child_session) child_screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] 0,0-1 All}| | ]], attr_ids={ |
