aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/ui_spec.lua21
-rw-r--r--test/functional/terminal/tui_spec.lua31
2 files changed, 49 insertions, 3 deletions
diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua
index 2758da6a1f..279cd1856d 100644
--- a/test/functional/api/ui_spec.lua
+++ b/test/functional/api/ui_spec.lua
@@ -35,3 +35,24 @@ describe('nvim_ui_attach()', function()
pcall_err(request, 'nvim_ui_attach', 40, 10, { rgb=false }))
end)
end)
+
+it('autocmds UIEnter/UILeave', function()
+ clear{
+ args_rm={'--headless'},
+ args={
+ '--cmd', 'let g:evs = []',
+ '--cmd', 'autocmd UIEnter * :call add(g:evs, "UIEnter") | let g:uienter_ev = deepcopy(v:event)',
+ '--cmd', 'autocmd UILeave * :call add(g:evs, "UILeave") | let g:uileave_ev = deepcopy(v:event)',
+ '--cmd', 'autocmd VimEnter * :call add(g:evs, "VimEnter")',
+ }}
+ local screen = Screen.new()
+ screen:attach()
+ eq({chan=1}, eval('g:uienter_ev'))
+ screen:detach()
+ eq({chan=1}, eval('g:uileave_ev'))
+ eq({
+ 'VimEnter',
+ 'UIEnter',
+ 'UILeave',
+ }, eval('g:evs'))
+end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 789f5d4c2f..c55093cb0f 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -721,8 +721,8 @@ describe('TUI', function()
|
{4:~ }|
{5: }|
- [[['height', 6], ['override', v:false], ['rgb', v:|
- false], ['width', 50]]] |
+ [[['chan', 0], ['height', 6], ['override', v:false|
+ ], ['rgb', v:false], ['width', 50]]] |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
]=])
@@ -767,11 +767,36 @@ describe('TUI', function()
end)
end)
+describe('TUI UIEnter/UILeave', function()
+ it('fires exactly once, after VimEnter', function()
+ clear()
+ local screen = thelpers.screen_setup(0,
+ '["'..nvim_prog..'", "-u", "NONE", "-i", "NONE"'
+ ..[[, "--cmd", "set noswapfile noshowcmd noruler"]]
+ ..[[, "--cmd", "let g:evs = []"]]
+ ..[[, "--cmd", "autocmd UIEnter * :call add(g:evs, 'UIEnter')"]]
+ ..[[, "--cmd", "autocmd UILeave * :call add(g:evs, 'UILeave')"]]
+ ..[[, "--cmd", "autocmd VimEnter * :call add(g:evs, 'VimEnter')"]]
+ ..']'
+ )
+ feed_data(":echo g:evs\n")
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ ['VimEnter', 'UIEnter'] |
+ {3:-- TERMINAL --} |
+ ]]}
+ end)
+end)
+
describe('TUI FocusGained/FocusLost', function()
local screen
before_each(function()
- helpers.clear()
+ clear()
screen = thelpers.screen_setup(0, '["'..nvim_prog
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
feed_data(":autocmd FocusGained * echo 'gained'\n")