aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-11-13 19:21:07 -0600
committerGitHub <noreply@github.com>2023-11-13 19:21:07 -0600
commit582d7f47905d82f315dc852a9d2937cd5b655e55 (patch)
tree2a8b82a0bb4e7079dc6c5be33f00c360e9547c6b /test
parent28f4f3c48498086307ed825d1761edb5789ca0e8 (diff)
parent22eb2ba18336df6cd70a88f666818ee5d8ba92d2 (diff)
downloadrneovim-582d7f47905d82f315dc852a9d2937cd5b655e55.tar.gz
rneovim-582d7f47905d82f315dc852a9d2937cd5b655e55.tar.bz2
rneovim-582d7f47905d82f315dc852a9d2937cd5b655e55.zip
Merge pull request #25918 from gpanders/background-color
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/ui_spec.lua2
-rw-r--r--test/functional/terminal/tui_spec.lua6
-rw-r--r--test/functional/ui/options_spec.lua16
-rw-r--r--test/unit/tui_spec.lua162
4 files changed, 3 insertions, 183 deletions
diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua
index a668d47448..6efb6726fe 100644
--- a/test/functional/api/ui_spec.lua
+++ b/test/functional/api/ui_spec.lua
@@ -36,8 +36,6 @@ describe('nvim_ui_attach()', function()
pcall_err(meths.ui_attach, 80, 24, { term_name=true }))
eq("Invalid 'term_colors': expected Integer, got Boolean",
pcall_err(meths.ui_attach, 80, 24, { term_colors=true }))
- eq("Invalid 'term_background': expected String, got Boolean",
- pcall_err(meths.ui_attach, 80, 24, { term_background=true }))
eq("Invalid 'stdin_fd': expected Integer, got String",
pcall_err(meths.ui_attach, 80, 24, { stdin_fd='foo' }))
eq("Invalid 'stdin_tty': expected Boolean, got String",
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 682eb48a27..960870fb46 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -2557,7 +2557,7 @@ describe('TUI bg color', function()
|
{3:-- TERMINAL --} |
]])
- feed_data('\027]11;rgb:ffff/ffff/ffff\007')
+ feed_data('\027]11;rgb:ffff/ffff/ffff\027\\')
screen:expect{any='did OptionSet, yay!'}
feed_data(':echo "new_bg=".&background\n')
@@ -2610,7 +2610,7 @@ describe('TUI bg color', function()
]])
-- Send a background response with the Pt portion split.
feed_data('\027]11;rgba:ffff/fff')
- feed_data('f/ffff/8000\007')
+ feed_data('f/ffff/8000\027\\')
screen:expect{any='did OptionSet, yay!'}
feed_data(':echo "new_bg=".&background\n')
@@ -2643,7 +2643,7 @@ describe('TUI bg color', function()
|
{3:-- TERMINAL --} |
]])
- feed_data('\027]11;rgba:ffff/foo/ffff/8000\007')
+ feed_data('\027]11;rgba:ffff/foo/ffff/8000\027\\')
screen:expect_unchanged()
feed_data(':echo "new_bg=".&background\n')
diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua
index f3817856f7..6af1820430 100644
--- a/test/functional/ui/options_spec.lua
+++ b/test/functional/ui/options_spec.lua
@@ -210,22 +210,6 @@ describe('UI can set terminal option', function()
screen = Screen.new(20,5)
end)
- it('term_background', function()
- eq('dark', eval '&background')
-
- screen:attach {term_background='light'}
- eq('light', eval '&background')
- end)
-
- it("term_background but not if 'background' already set by user", function()
- eq('dark', eval '&background')
- command 'set background=dark'
-
- screen:attach {term_background='light'}
-
- eq('dark', eval '&background')
- end)
-
it('term_name', function()
eq('nvim', eval '&term')
diff --git a/test/unit/tui_spec.lua b/test/unit/tui_spec.lua
deleted file mode 100644
index 192e35a485..0000000000
--- a/test/unit/tui_spec.lua
+++ /dev/null
@@ -1,162 +0,0 @@
-local helpers = require("test.unit.helpers")(after_each)
-local cimport = helpers.cimport
-local eq = helpers.eq
-local ffi = helpers.ffi
-local itp = helpers.gen_itp(it)
-local to_cstr = helpers.to_cstr
-
-local cinput = cimport("./src/nvim/tui/input.h")
-local rbuffer = cimport("./test/unit/fixtures/rbuffer.h")
-local globals = cimport("./src/nvim/globals.h")
-local multiqueue = cimport("./test/unit/fixtures/multiqueue.h")
-local ui_client = cimport("./src/nvim/ui_client.h")
-
-itp('handle_background_color', function()
- local handle_background_color = cinput.handle_background_color
- local term_input = ffi.new('TermInput', {})
- local events = globals.main_loop.thread_events
- local kIncomplete = cinput.kIncomplete
- local kNotApplicable = cinput.kNotApplicable
- local kComplete = cinput.kComplete
-
- -- Short-circuit when not waiting for response.
- term_input.waiting_for_bg_response = 0
- eq(kNotApplicable, handle_background_color(term_input))
-
- local capacity = 100
- local rbuf = ffi.gc(rbuffer.rbuffer_new(capacity), rbuffer.rbuffer_free)
- term_input.read_stream.buffer = rbuf
-
- local function assert_bg(colorspace, color, bg)
- local term_response = '\027]11;'..colorspace..':'..color..'\007'
- rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
-
- term_input.waiting_for_bg_response = 1
- eq(kComplete, handle_background_color(term_input))
- eq(0, term_input.waiting_for_bg_response)
- eq(0, multiqueue.multiqueue_size(events))
- eq(bg, ({[0]="light", [1] = "dark", [-1] = "none"})
- [tonumber(ui_client.ui_client_bg_response)])
-
- -- Buffer has been consumed.
- eq(0, rbuf.size)
- end
-
- assert_bg('rgb', '0000/0000/0000', 'dark')
- assert_bg('rgb', 'ffff/ffff/ffff', 'light')
- assert_bg('rgb', '000/000/000', 'dark')
- assert_bg('rgb', 'fff/fff/fff', 'light')
- assert_bg('rgb', '00/00/00', 'dark')
- assert_bg('rgb', 'ff/ff/ff', 'light')
- assert_bg('rgb', '0/0/0', 'dark')
- assert_bg('rgb', 'f/f/f', 'light')
-
- assert_bg('rgb', 'f/0/0', 'dark')
- assert_bg('rgb', '0/f/0', 'light')
- assert_bg('rgb', '0/0/f', 'dark')
-
- assert_bg('rgb', '1/1/1', 'dark')
- assert_bg('rgb', '2/2/2', 'dark')
- assert_bg('rgb', '3/3/3', 'dark')
- assert_bg('rgb', '4/4/4', 'dark')
- assert_bg('rgb', '5/5/5', 'dark')
- assert_bg('rgb', '6/6/6', 'dark')
- assert_bg('rgb', '7/7/7', 'dark')
- assert_bg('rgb', '8/8/8', 'light')
- assert_bg('rgb', '9/9/9', 'light')
- assert_bg('rgb', 'a/a/a', 'light')
- assert_bg('rgb', 'b/b/b', 'light')
- assert_bg('rgb', 'c/c/c', 'light')
- assert_bg('rgb', 'd/d/d', 'light')
- assert_bg('rgb', 'e/e/e', 'light')
-
- assert_bg('rgb', '0/e/0', 'light')
- assert_bg('rgb', '0/d/0', 'light')
- assert_bg('rgb', '0/c/0', 'dark')
- assert_bg('rgb', '0/b/0', 'dark')
-
- assert_bg('rgb', 'f/0/f', 'dark')
- assert_bg('rgb', 'f/1/f', 'dark')
- assert_bg('rgb', 'f/2/f', 'dark')
- assert_bg('rgb', 'f/3/f', 'light')
- assert_bg('rgb', 'f/4/f', 'light')
-
- assert_bg('rgba', '0000/0000/0000/0000', 'dark')
- assert_bg('rgba', '0000/0000/0000/ffff', 'dark')
- assert_bg('rgba', 'ffff/ffff/ffff/0000', 'light')
- assert_bg('rgba', 'ffff/ffff/ffff/ffff', 'light')
- assert_bg('rgba', '000/000/000/000', 'dark')
- assert_bg('rgba', '000/000/000/fff', 'dark')
- assert_bg('rgba', 'fff/fff/fff/000', 'light')
- assert_bg('rgba', 'fff/fff/fff/fff', 'light')
- assert_bg('rgba', '00/00/00/00', 'dark')
- assert_bg('rgba', '00/00/00/ff', 'dark')
- assert_bg('rgba', 'ff/ff/ff/00', 'light')
- assert_bg('rgba', 'ff/ff/ff/ff', 'light')
- assert_bg('rgba', '0/0/0/0', 'dark')
- assert_bg('rgba', '0/0/0/f', 'dark')
- assert_bg('rgba', 'f/f/f/0', 'light')
- assert_bg('rgba', 'f/f/f/f', 'light')
-
-
- -- Incomplete sequence: necessarily correct behavior.
- local term_response = '\027]11;rgba:f/f/f/f' -- missing '\007
- rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
-
- term_input.waiting_for_bg_response = 1
- eq(kIncomplete, handle_background_color(term_input))
- eq(1, term_input.waiting_for_bg_response)
- eq(#term_response, rbuf.size)
-
- term_response = '\007'
- rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
- eq(kComplete, handle_background_color(term_input))
- eq(0, term_input.waiting_for_bg_response)
-
- eq(0, tonumber(ui_client.ui_client_bg_response))
- eq(0, multiqueue.multiqueue_size(events))
- eq(0, rbuf.size)
-
- term_response = '\027]11;rg'
- rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
-
- term_input.waiting_for_bg_response = 1
- eq(kIncomplete, handle_background_color(term_input))
- eq(1, term_input.waiting_for_bg_response)
- eq(#term_response, rbuf.size)
-
- term_response = 'ba:f/f/f/f\007'
- rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
- eq(kComplete, handle_background_color(term_input))
- eq(0, term_input.waiting_for_bg_response)
-
- eq(0, tonumber(ui_client.ui_client_bg_response))
- eq(0, multiqueue.multiqueue_size(events))
- eq(0, rbuf.size)
-
-
- -- Does nothing when not at start of buffer.
- term_response = '123\027]11;rgba:f/f/f/f\007456'
- rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
-
- term_input.waiting_for_bg_response = 3
- eq(kNotApplicable, handle_background_color(term_input))
- eq(2, term_input.waiting_for_bg_response)
-
- eq(0, multiqueue.multiqueue_size(events))
- eq(#term_response, rbuf.size)
- rbuffer.rbuffer_consumed(rbuf, #term_response)
-
-
- -- Keeps trailing buffer.
- term_response = '\027]11;rgba:f/f/f/f\007456'
- rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
-
- term_input.waiting_for_bg_response = 1
- eq(kComplete, handle_background_color(term_input))
- eq(0, term_input.waiting_for_bg_response)
-
- eq(0, multiqueue.multiqueue_size(events))
- eq(3, rbuf.size)
- rbuffer.rbuffer_consumed(rbuf, rbuf.size)
-end)