aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/tui_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal/tui_spec.lua')
-rw-r--r--test/functional/terminal/tui_spec.lua114
1 files changed, 99 insertions, 15 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 9a1fdfca55..3c79bc1fdb 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -5,6 +5,7 @@ local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
local feed = thelpers.feed_data
local execute = helpers.execute
+local nvim_dir = helpers.nvim_dir
describe('tui', function()
local screen
@@ -148,10 +149,41 @@ describe('tui', function()
-- TERMINAL -- |
]])
end)
+end)
+
+describe('tui with non-tty file descriptors', function()
+ before_each(helpers.clear)
+
+ after_each(function()
+ os.remove('testF') -- ensure test file is removed
+ end)
- it('can handle focus events', function()
+ it('can handle pipes as stdout and stderr', function()
+ local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog..' -u NONE -i NONE --cmd \'set noswapfile\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
+ screen:set_default_attr_ids({})
+ screen:set_default_attr_ignore(true)
+ feed(':w testF\n:q\n')
+ screen:expect([[
+ :w testF |
+ :q |
+ abc |
+ |
+ [Process exited 0] |
+ |
+ -- TERMINAL -- |
+ ]])
+ end)
+end)
+
+describe('tui focus event handling', function()
+ before_each(function()
+ helpers.clear()
+ screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
execute('autocmd FocusGained * echo "gained"')
execute('autocmd FocusLost * echo "lost"')
+ end)
+
+ it('can handle focus events in normal mode', function()
feed('\x1b[I')
screen:expect([[
{1: } |
@@ -174,27 +206,79 @@ describe('tui', function()
-- TERMINAL -- |
]])
end)
-end)
-describe('tui with non-tty file descriptors', function()
- before_each(helpers.clear)
+ it('can handle focus events in insert mode', function()
+ execute('set noshowmode')
+ feed('i')
+ feed('\x1b[I')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ gained |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ lost |
+ -- TERMINAL -- |
+ ]])
+ end)
- after_each(function()
- os.remove('testF') -- ensure test file is removed
+ it('can handle focus events in cmdline mode', function()
+ feed(':')
+ feed('\x1b[I')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ g{1:a}ined |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ l{1:o}st |
+ -- TERMINAL -- |
+ ]])
end)
- it('can handle pipes as stdout and stderr', function()
- local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog..' -u NONE -i NONE --cmd \'set noswapfile\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
- screen:set_default_attr_ids({})
- screen:set_default_attr_ignore(true)
- feed(':w testF\n:q\n')
+ it('can handle focus events in terminal mode', function()
+ execute('set shell='..nvim_dir..'/shell-test')
+ execute('set laststatus=0')
+ execute('set noshowmode')
+ execute('terminal')
+ feed('\x1b[I')
screen:expect([[
- :w testF |
- :q |
- abc |
+ ready $ |
+ [Process exited 0]{1: } |
+ |
|
- [Process exited 0] |
|
+ gained |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ ready $ |
+ [Process exited 0]{1: } |
+ |
+ |
+ |
+ lost |
-- TERMINAL -- |
]])
end)