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
|
|
|
|
|
|
|
|
describe('ui receives option updates', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(20,5)
|
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
|
|
|
local defaults = {
|
|
|
|
ambiwidth='single',
|
|
|
|
arabicshape=true,
|
|
|
|
emoji=true,
|
|
|
|
guifont='',
|
|
|
|
guifontset='',
|
|
|
|
guifontwide='',
|
2018-01-20 23:31:57 -07:00
|
|
|
linespace=0,
|
2017-12-12 10:23:19 -07:00
|
|
|
showtabline=1,
|
|
|
|
termguicolors=false,
|
2018-02-13 05:45:49 -07:00
|
|
|
ext_cmdline=false,
|
|
|
|
ext_popupmenu=false,
|
|
|
|
ext_tabline=false,
|
|
|
|
ext_wildmenu=false,
|
2018-09-28 05:19:37 -07:00
|
|
|
ext_linegrid=false,
|
2018-07-06 05:39:50 -07:00
|
|
|
ext_hlstate=false,
|
2017-12-12 10:23:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
it("for defaults", function()
|
2018-02-13 05:45:49 -07:00
|
|
|
screen:attach()
|
2018-09-28 05:19:37 -07:00
|
|
|
-- NB: UI test suite can be run in both "linegrid" and legacy grid mode.
|
2018-07-06 05:39:50 -07:00
|
|
|
-- In both cases check that the received value is the one requested.
|
2018-09-28 05:19:37 -07:00
|
|
|
defaults.ext_linegrid = screen._options.ext_linegrid or false
|
2017-12-12 10:23:19 -07:00
|
|
|
screen:expect(function()
|
|
|
|
eq(defaults, screen.options)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("when setting options", function()
|
2018-02-13 05:45:49 -07:00
|
|
|
screen:attach()
|
2018-09-28 05:19:37 -07:00
|
|
|
defaults.ext_linegrid = screen._options.ext_linegrid or false
|
2017-12-12 10:23:19 -07:00
|
|
|
local changed = {}
|
|
|
|
for k,v in pairs(defaults) do
|
|
|
|
changed[k] = v
|
|
|
|
end
|
|
|
|
|
|
|
|
command("set termguicolors")
|
|
|
|
changed.termguicolors = true
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, screen.options)
|
|
|
|
end)
|
|
|
|
|
|
|
|
command("set guifont=Comic\\ Sans")
|
|
|
|
changed.guifont = "Comic Sans"
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, screen.options)
|
|
|
|
end)
|
|
|
|
|
|
|
|
command("set showtabline=0")
|
|
|
|
changed.showtabline = 0
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, screen.options)
|
|
|
|
end)
|
|
|
|
|
2018-01-20 23:31:57 -07:00
|
|
|
command("set linespace=13")
|
|
|
|
changed.linespace = 13
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, screen.options)
|
|
|
|
end)
|
|
|
|
|
|
|
|
command("set linespace=-11")
|
|
|
|
changed.linespace = -11
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, 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()
|
|
|
|
local changed = {}
|
|
|
|
for k,v in pairs(defaults) do
|
|
|
|
changed[k] = v
|
|
|
|
end
|
|
|
|
|
|
|
|
screen:attach({ext_cmdline=true, ext_wildmenu=true})
|
2018-09-28 05:19:37 -07:00
|
|
|
defaults.ext_linegrid = screen._options.ext_linegrid or false
|
2018-02-13 05:45:49 -07:00
|
|
|
changed.ext_cmdline = true
|
|
|
|
changed.ext_wildmenu = true
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, screen.options)
|
|
|
|
end)
|
|
|
|
|
|
|
|
screen:set_option('ext_popupmenu', true)
|
|
|
|
changed.ext_popupmenu = true
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, screen.options)
|
|
|
|
end)
|
|
|
|
|
|
|
|
screen:set_option('ext_wildmenu', false)
|
|
|
|
changed.ext_wildmenu = false
|
|
|
|
screen:expect(function()
|
|
|
|
eq(changed, screen.options)
|
|
|
|
end)
|
|
|
|
end)
|
2017-12-12 10:23:19 -07:00
|
|
|
end)
|