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
|
|
|
|
|
|
|
describe('ui receives option updates', function()
|
|
|
|
local screen
|
|
|
|
|
2018-11-06 11:56:31 -07:00
|
|
|
local function reset(opts, ...)
|
|
|
|
local defaults = {
|
|
|
|
ambiwidth='single',
|
|
|
|
arabicshape=true,
|
|
|
|
emoji=true,
|
|
|
|
guifont='',
|
|
|
|
guifontset='',
|
|
|
|
guifontwide='',
|
|
|
|
linespace=0,
|
2019-01-20 13:23:17 -07:00
|
|
|
pumblend=0,
|
2018-11-06 11:56:31 -07:00
|
|
|
showtabline=1,
|
|
|
|
termguicolors=false,
|
|
|
|
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)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
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)
|