aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-02-17 14:47:40 +0100
committerJustin M. Keyes <justinkz@gmail.com>2019-02-17 14:47:40 +0100
commit6bd6927656500c50787b16de1fadf1bc46b7aefa (patch)
tree39b7291f434431e40e0a2d526de3026fc166226a /test
parentdc9dd8d664f2ffec3d199f96e4605cb0729497ec (diff)
parent7e9b99d55be68938689b9f593e200054533c3783 (diff)
downloadrneovim-6bd6927656500c50787b16de1fadf1bc46b7aefa.tar.gz
rneovim-6bd6927656500c50787b16de1fadf1bc46b7aefa.tar.bz2
rneovim-6bd6927656500c50787b16de1fadf1bc46b7aefa.zip
Merge #5027 'TUI: detect background color'
Diffstat (limited to 'test')
-rw-r--r--test/functional/terminal/tui_spec.lua78
1 files changed, 71 insertions, 7 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index f1ad2bdb95..70356b7e2d 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -269,7 +269,7 @@ describe('TUI', function()
end)
end)
-describe('tui with non-tty file descriptors', function()
+describe('TUI with non-tty file descriptors', function()
before_each(helpers.clear)
after_each(function()
@@ -277,7 +277,7 @@ describe('tui with non-tty file descriptors', function()
end)
it('can handle pipes as stdout and stderr', function()
- local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog
+ local screen = thelpers.screen_setup(0, '"'..nvim_prog
..' -u NONE -i NONE --cmd \'set noswapfile noshowcmd noruler\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
feed_data(':w testF\n:q\n')
screen:expect([[
@@ -292,12 +292,12 @@ describe('tui with non-tty file descriptors', function()
end)
end)
-describe('tui FocusGained/FocusLost', function()
+describe('TUI FocusGained/FocusLost', function()
local screen
before_each(function()
helpers.clear()
- screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog
+ screen = thelpers.screen_setup(0, '["'..nvim_prog
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
feed_data(":autocmd FocusGained * echo 'gained'\n")
feed_data(":autocmd FocusLost * echo 'lost'\n")
@@ -459,7 +459,7 @@ end)
-- These tests require `thelpers` because --headless/--embed
-- does not initialize the TUI.
-describe("tui 't_Co' (terminal colors)", function()
+describe("TUI 't_Co' (terminal colors)", function()
local screen
local is_freebsd = (string.lower(uname()) == 'freebsd')
@@ -731,7 +731,7 @@ end)
-- These tests require `thelpers` because --headless/--embed
-- does not initialize the TUI.
-describe("tui 'term' option", function()
+describe("TUI 'term' option", function()
local screen
local is_bsd = not not string.find(string.lower(uname()), 'bsd')
local is_macos = not not string.find(string.lower(uname()), 'darwin')
@@ -783,7 +783,7 @@ end)
-- These tests require `thelpers` because --headless/--embed
-- does not initialize the TUI.
-describe("tui", function()
+describe("TUI", function()
local screen
local logfile = 'Xtest_tui_verbose_log'
after_each(function()
@@ -826,3 +826,67 @@ describe("tui", function()
end)
end)
+
+describe('TUI background color', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = thelpers.screen_setup(0, '["'..nvim_prog
+ ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+ end)
+
+ local function assert_bg(color, bg)
+ it('handles '..color..' as '..bg, function()
+ feed_data('\027]11;rgb:'..color..'\007:echo &background\n')
+ screen:expect(string.format([[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] 0,0-1 All}|
+ %-5s |
+ {3:-- TERMINAL --} |
+ ]], bg))
+ end)
+ end
+
+ assert_bg('0000/0000/0000', 'dark')
+ assert_bg('ffff/ffff/ffff', 'light')
+ assert_bg('000/000/000', 'dark')
+ assert_bg('fff/fff/fff', 'light')
+ assert_bg('00/00/00', 'dark')
+ assert_bg('ff/ff/ff', 'light')
+ assert_bg('0/0/0', 'dark')
+ assert_bg('f/f/f', 'light')
+
+ assert_bg('f/0/0', 'dark')
+ assert_bg('0/f/0', 'light')
+ assert_bg('0/0/f', 'dark')
+
+ assert_bg('1/1/1', 'dark')
+ assert_bg('2/2/2', 'dark')
+ assert_bg('3/3/3', 'dark')
+ assert_bg('4/4/4', 'dark')
+ assert_bg('5/5/5', 'dark')
+ assert_bg('6/6/6', 'dark')
+ assert_bg('7/7/7', 'dark')
+ assert_bg('8/8/8', 'light')
+ assert_bg('9/9/9', 'light')
+ assert_bg('a/a/a', 'light')
+ assert_bg('b/b/b', 'light')
+ assert_bg('c/c/c', 'light')
+ assert_bg('d/d/d', 'light')
+ assert_bg('e/e/e', 'light')
+
+ assert_bg('0/e/0', 'light')
+ assert_bg('0/d/0', 'light')
+ assert_bg('0/c/0', 'dark')
+ assert_bg('0/b/0', 'dark')
+
+ assert_bg('f/0/f', 'dark')
+ assert_bg('f/1/f', 'dark')
+ assert_bg('f/2/f', 'dark')
+ assert_bg('f/3/f', 'light')
+ assert_bg('f/4/f', 'light')
+end)