2017-12-12 10:23:19 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local clear = helpers.clear
|
|
|
|
local command = helpers.command
|
|
|
|
local eq = helpers.eq
|
2019-05-18 05:09:43 -07:00
|
|
|
local shallowcopy = helpers.shallowcopy
|
2017-12-12 10:23:19 -07:00
|
|
|
|
2019-11-25 09:56:42 -07:00
|
|
|
describe('UI receives option updates', function()
|
2017-12-12 10:23:19 -07:00
|
|
|
local screen
|
|
|
|
|
2018-11-06 11:56:31 -07:00
|
|
|
local function reset(opts, ...)
|
|
|
|
local defaults = {
|
|
|
|
ambiwidth='single',
|
|
|
|
arabicshape=true,
|
|
|
|
emoji=true,
|
|
|
|
guifont='',
|
|
|
|
guifontwide='',
|
|
|
|
linespace=0,
|
2019-01-20 13:23:17 -07:00
|
|
|
pumblend=0,
|
2020-09-06 11:40:07 -07:00
|
|
|
mousefocus=false,
|
2018-11-06 11:56:31 -07:00
|
|
|
showtabline=1,
|
|
|
|
termguicolors=false,
|
2020-03-19 11:31:10 -07:00
|
|
|
ttimeout=true,
|
|
|
|
ttimeoutlen=50,
|
2018-11-06 11:56:31 -07:00
|
|
|
ext_cmdline=false,
|
|
|
|
ext_popupmenu=false,
|
|
|
|
ext_tabline=false,
|
|
|
|
ext_wildmenu=false,
|
|
|
|
ext_linegrid=false,
|
|
|
|
ext_hlstate=false,
|
2017-12-09 03:26:06 -07:00
|
|
|
ext_multigrid=false,
|
2017-10-31 08:46:02 -07:00
|
|
|
ext_messages=false,
|
2019-02-05 08:17:23 -07:00
|
|
|
ext_termcolors=false,
|
2018-11-06 11:56:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
clear(...)
|
2017-12-12 10:23:19 -07:00
|
|
|
screen = Screen.new(20,5)
|
2018-11-06 11:56:31 -07:00
|
|
|
screen:attach(opts)
|
|
|
|
-- NB: UI test suite can be run in both "linegrid" and legacy grid mode.
|
|
|
|
-- In both cases check that the received value is the one requested.
|
|
|
|
defaults.ext_linegrid = screen._options.ext_linegrid or false
|
|
|
|
return defaults
|
|
|
|
end
|
2017-12-12 10:23:19 -07:00
|
|
|
|
|
|
|
it("for defaults", function()
|
2018-11-06 11:56:31 -07:00
|
|
|
local expected = reset()
|
2017-12-12 10:23:19 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2017-12-12 10:23:19 -07:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2019-11-25 09:56:42 -07:00
|
|
|
it('on attach #11372', function()
|
|
|
|
clear()
|
|
|
|
local evs = {}
|
|
|
|
screen = Screen.new(20,5)
|
|
|
|
-- Override mouse_on/mouse_off handlers.
|
2019-11-30 00:48:14 -07:00
|
|
|
function screen:_handle_mouse_on()
|
2019-11-25 09:56:42 -07:00
|
|
|
table.insert(evs, 'mouse_on')
|
|
|
|
end
|
2019-11-30 00:48:14 -07:00
|
|
|
function screen:_handle_mouse_off()
|
2019-11-25 09:56:42 -07:00
|
|
|
table.insert(evs, 'mouse_off')
|
|
|
|
end
|
|
|
|
screen:attach()
|
|
|
|
screen:expect(function()
|
|
|
|
eq({'mouse_off'}, evs)
|
|
|
|
end)
|
|
|
|
command("set mouse=nvi")
|
|
|
|
screen:expect(function()
|
|
|
|
eq({'mouse_off','mouse_on'}, evs)
|
|
|
|
end)
|
|
|
|
screen:detach()
|
|
|
|
eq({'mouse_off','mouse_on'}, evs)
|
|
|
|
screen:attach()
|
|
|
|
screen:expect(function()
|
|
|
|
eq({'mouse_off','mouse_on','mouse_on'}, evs)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2017-12-12 10:23:19 -07:00
|
|
|
it("when setting options", function()
|
2018-11-06 11:56:31 -07:00
|
|
|
local expected = reset()
|
|
|
|
local defaults = shallowcopy(expected)
|
2017-12-12 10:23:19 -07:00
|
|
|
|
|
|
|
command("set termguicolors")
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.termguicolors = true
|
2017-12-12 10:23:19 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2017-12-12 10:23:19 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
command("set guifont=Comic\\ Sans")
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.guifont = "Comic Sans"
|
2017-12-12 10:23:19 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2017-12-12 10:23:19 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
command("set showtabline=0")
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.showtabline = 0
|
2017-12-12 10:23:19 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2017-12-12 10:23:19 -07:00
|
|
|
end)
|
|
|
|
|
2018-01-20 23:31:57 -07:00
|
|
|
command("set linespace=13")
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.linespace = 13
|
2018-01-20 23:31:57 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2018-01-20 23:31:57 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
command("set linespace=-11")
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.linespace = -11
|
2018-01-20 23:31:57 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2018-01-20 23:31:57 -07:00
|
|
|
end)
|
|
|
|
|
2020-09-06 11:40:07 -07:00
|
|
|
command("set mousefocus")
|
|
|
|
expected.mousefocus = true
|
|
|
|
screen:expect(function()
|
|
|
|
eq(expected, screen.options)
|
|
|
|
end)
|
|
|
|
|
2020-03-19 11:31:10 -07:00
|
|
|
command("set nottimeout")
|
|
|
|
expected.ttimeout = false
|
|
|
|
screen:expect(function()
|
|
|
|
eq(expected, screen.options)
|
|
|
|
end)
|
|
|
|
|
|
|
|
command("set ttimeoutlen=100")
|
|
|
|
expected.ttimeoutlen = 100
|
|
|
|
screen:expect(function()
|
|
|
|
eq(expected, screen.options)
|
|
|
|
end)
|
|
|
|
|
2017-12-12 10:23:19 -07:00
|
|
|
command("set all&")
|
|
|
|
screen:expect(function()
|
|
|
|
eq(defaults, screen.options)
|
|
|
|
end)
|
|
|
|
end)
|
2018-02-13 05:45:49 -07:00
|
|
|
|
|
|
|
it('with UI extensions', function()
|
2018-11-06 11:56:31 -07:00
|
|
|
local expected = reset({ext_cmdline=true, ext_wildmenu=true})
|
2018-02-13 05:45:49 -07:00
|
|
|
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.ext_cmdline = true
|
|
|
|
expected.ext_wildmenu = true
|
2018-02-13 05:45:49 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2018-02-13 05:45:49 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
screen:set_option('ext_popupmenu', true)
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.ext_popupmenu = true
|
2018-02-13 05:45:49 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2018-02-13 05:45:49 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
screen:set_option('ext_wildmenu', false)
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.ext_wildmenu = false
|
2018-02-13 05:45:49 -07:00
|
|
|
screen:expect(function()
|
2018-11-06 11:56:31 -07:00
|
|
|
eq(expected, screen.options)
|
2018-02-13 05:45:49 -07:00
|
|
|
end)
|
|
|
|
end)
|
2018-11-06 11:56:31 -07:00
|
|
|
|
|
|
|
local function startup_test(headless)
|
2019-04-16 16:38:59 -07:00
|
|
|
local expected = reset(nil, {args_rm=(headless and {} or {'--headless'}),
|
|
|
|
args={'--cmd', 'set guifont=Comic\\ Sans\\ 12'}})
|
2018-11-06 11:56:31 -07:00
|
|
|
expected.guifont = "Comic Sans 12"
|
|
|
|
screen:expect(function()
|
|
|
|
eq(expected, screen.options)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
it('from startup options with --headless', function() startup_test(true) end)
|
|
|
|
it('from startup options with --embed', function() startup_test(false) end)
|
2017-12-12 10:23:19 -07:00
|
|
|
end)
|