diff options
Diffstat (limited to 'test/functional/ui/embed_spec.lua')
-rw-r--r-- | test/functional/ui/embed_spec.lua | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index db01c55e23..fb2cdb3c4a 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -2,10 +2,13 @@ local uv = require'luv' local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local thelpers = require('test.functional.terminal.helpers') local feed = helpers.feed local eq = helpers.eq local clear = helpers.clear +local ok = helpers.ok + local function test_embed(ext_linegrid) local screen @@ -133,3 +136,61 @@ describe('--embed UI', function() ]]} end) end) + +describe('--embed --listen UI', function() + it('waits for connection on listening address', function() + helpers.skip(helpers.is_os('win')) + clear() + local child_server = assert(helpers.new_pipename()) + + local screen = thelpers.screen_setup(0, + string.format( + [=[["%s", "--embed", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s"]]=], + helpers.nvim_prog, child_server, helpers.nvim_set)) + screen:expect{grid=[[ + {1: } | + | + | + | + | + | + {3:-- TERMINAL --} | + ]]} + + local child_session = helpers.connect(child_server) + + local info_ok, api_info = child_session:request('nvim_get_api_info') + ok(info_ok) + eq(2, #api_info) + ok(api_info[1] > 2, 'channel_id > 2', api_info[1]) + + child_session:request('nvim_exec2', [[ + let g:evs = [] + autocmd UIEnter * call add(g:evs, $"UIEnter:{v:event.chan}") + autocmd VimEnter * call add(g:evs, "VimEnter") + ]], {}) + + -- VimEnter and UIEnter shouldn't be triggered until after attach + local var_ok, var = child_session:request('nvim_get_var', 'evs') + ok(var_ok) + eq({}, var) + + local child_screen = Screen.new(40, 6) + child_screen:attach(nil, child_session) + child_screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], attr_ids={ + [1] = {foreground = Screen.colors.Blue, bold = true}; + }} + + -- VimEnter and UIEnter should now be triggered + var_ok, var = child_session:request('nvim_get_var', 'evs') + ok(var_ok) + eq({'VimEnter', ('UIEnter:%d'):format(api_info[1])}, var) + end) +end) |