2016-06-26 12:35:14 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
local child_session = require('test.functional.terminal.helpers')
|
|
|
|
local ok = helpers.ok
|
|
|
|
|
2022-11-21 17:13:30 -07:00
|
|
|
if helpers.skip(helpers.is_os('win')) then return end
|
2016-06-26 12:35:14 -07:00
|
|
|
|
|
|
|
describe('api', function()
|
|
|
|
local screen
|
2022-06-01 11:28:14 -07:00
|
|
|
local socket_name = "./Xtest_functional_api.sock"
|
2016-06-26 12:35:14 -07:00
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
helpers.clear()
|
|
|
|
os.remove(socket_name)
|
|
|
|
screen = child_session.screen_setup(0, '["'..helpers.nvim_prog
|
2017-02-09 19:39:00 -07:00
|
|
|
..'", "-u", "NONE", "-i", "NONE", "--cmd", "'..helpers.nvim_set..'"]')
|
2016-06-26 12:35:14 -07:00
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
os.remove(socket_name)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("qa! RPC request during insert-mode", function()
|
2022-05-02 12:10:01 -07:00
|
|
|
screen:expect{grid=[[
|
|
|
|
{1: } |
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
|
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]]}
|
|
|
|
|
2016-06-26 12:35:14 -07:00
|
|
|
-- Start the socket from the child nvim.
|
|
|
|
child_session.feed_data(":echo serverstart('"..socket_name.."')\n")
|
|
|
|
|
2016-10-19 06:18:47 -07:00
|
|
|
-- Wait for socket creation.
|
2016-06-26 12:35:14 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
2017-02-09 19:39:00 -07:00
|
|
|
{4:~ }|
|
2022-06-01 11:28:14 -07:00
|
|
|
]]..socket_name..[[ |
|
2016-06-26 12:35:14 -07:00
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
|
|
|
|
local socket_session1 = helpers.connect(socket_name)
|
|
|
|
local socket_session2 = helpers.connect(socket_name)
|
|
|
|
|
|
|
|
child_session.feed_data("i[tui] insert-mode")
|
2016-10-19 06:18:47 -07:00
|
|
|
-- Wait for stdin to be processed.
|
|
|
|
screen:expect([[
|
|
|
|
[tui] insert-mode{1: } |
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
2017-02-09 19:39:00 -07:00
|
|
|
{4:~ }|
|
2016-10-19 06:18:47 -07:00
|
|
|
{3:-- INSERT --} |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
2016-06-26 12:35:14 -07:00
|
|
|
|
2022-06-30 04:16:46 -07:00
|
|
|
ok((socket_session1:request("nvim_ui_attach", 42, 6, {rgb=true})))
|
|
|
|
ok((socket_session2:request("nvim_ui_attach", 25, 30, {rgb=true})))
|
2016-06-26 12:35:14 -07:00
|
|
|
|
|
|
|
socket_session1:notify("nvim_input", "\n[socket 1] this is more than 25 columns")
|
|
|
|
socket_session2:notify("nvim_input", "\n[socket 2] input")
|
|
|
|
|
|
|
|
screen:expect([[
|
|
|
|
[tui] insert-mode |
|
2023-05-01 11:08:25 -07:00
|
|
|
[socket 1] this is more t |
|
|
|
|
han 25 columns |
|
|
|
|
[socket 2] input{1: } |
|
|
|
|
{4:~ } |
|
2016-06-26 12:35:14 -07:00
|
|
|
{3:-- INSERT --} |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
|
|
|
|
socket_session1:request("nvim_command", "qa!")
|
|
|
|
end)
|
|
|
|
end)
|