aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/wildmode_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui/wildmode_spec.lua')
-rw-r--r--test/functional/ui/wildmode_spec.lua81
1 files changed, 27 insertions, 54 deletions
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index b60d520ca0..8931d9245b 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -1,3 +1,5 @@
+local global_helpers = require('test.helpers')
+local shallowcopy = global_helpers.shallowcopy
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, command = helpers.clear, helpers.feed, helpers.command
@@ -18,6 +20,14 @@ describe("'wildmenu'", function()
screen:detach()
end)
+ -- expect the screen stayed unchanged some time after first seen success
+ local function expect_stay_unchanged(args)
+ screen:expect(args)
+ args = shallowcopy(args)
+ args.unchanged = true
+ screen:expect(args)
+ end
+
it(':sign <tab> shows wildmenu completions', function()
command('set wildmode=full')
command('set wildmenu')
@@ -76,10 +86,6 @@ describe("'wildmenu'", function()
end)
it('is preserved during :terminal activity', function()
- -- Because this test verifies a _lack_ of activity after screen:sleep(), we
- -- must wait the full timeout. So make it reasonable.
- screen.timeout = 1000
-
command('set wildmenu wildmode=full')
command('set scrollback=4')
if iswin() then
@@ -90,26 +96,24 @@ describe("'wildmenu'", function()
feed([[<C-\><C-N>gg]])
feed([[:sign <Tab>]]) -- Invoke wildmenu.
- screen:sleep(50) -- Allow some terminal output.
- screen:expect([[
+ expect_stay_unchanged{grid=[[
foo |
foo |
foo |
define jump list > |
:sign define^ |
- ]])
+ ]]}
-- cmdline CTRL-D display should also be preserved.
feed([[<C-\><C-N>]])
feed([[:sign <C-D>]]) -- Invoke cmdline CTRL-D.
- screen:sleep(50) -- Allow some terminal output.
- screen:expect([[
+ expect_stay_unchanged{grid=[[
:sign |
define place |
jump undefine |
list unplace |
:sign ^ |
- ]])
+ ]]}
-- Exiting cmdline should show the buffer.
feed([[<C-\><C-N>]])
@@ -123,22 +127,17 @@ describe("'wildmenu'", function()
end)
it('ignores :redrawstatus called from a timer #7108', function()
- -- Because this test verifies a _lack_ of activity after screen:sleep(), we
- -- must wait the full timeout. So make it reasonable.
- screen.timeout = 1000
-
command('set wildmenu wildmode=full')
command([[call timer_start(10, {->execute('redrawstatus')}, {'repeat':-1})]])
feed([[<C-\><C-N>]])
feed([[:sign <Tab>]]) -- Invoke wildmenu.
- screen:sleep(30) -- Allow some timer activity.
- screen:expect([[
+ expect_stay_unchanged{grid=[[
|
~ |
~ |
define jump list > |
:sign define^ |
- ]])
+ ]]}
end)
it('with laststatus=0, :vsplit, :term #2255', function()
@@ -164,10 +163,9 @@ describe("'wildmenu'", function()
feed([[<C-\><C-N>]])
feed([[:<Tab>]]) -- Invoke wildmenu.
- screen:sleep(10) -- Flush
-- Check only the last 2 lines, because the shell output is
-- system-dependent.
- screen:expect('! # & < = > @ > \n:!^', nil, nil, nil, true)
+ expect_stay_unchanged{any='! # & < = > @ > \n:!^'}
end)
end)
@@ -204,21 +202,11 @@ end)
describe('ui/ext_wildmenu', function()
local screen
- local items, selected = nil, nil
before_each(function()
clear()
screen = Screen.new(25, 5)
screen:attach({rgb=true, ext_wildmenu=true})
- screen:set_on_event_handler(function(name, data)
- if name == "wildmenu_show" then
- items = data[1]
- elseif name == "wildmenu_select" then
- selected = data[1]
- elseif name == "wildmenu_hide" then
- items, selected = nil, nil
- end
- end)
end)
after_each(function()
@@ -238,63 +226,48 @@ describe('ui/ext_wildmenu', function()
command('set wildmode=full')
command('set wildmenu')
feed(':sign <tab>')
- screen:expect([[
+ screen:expect{grid=[[
|
~ |
~ |
~ |
:sign define^ |
- ]], nil, nil, function()
- eq(expected, items)
- eq(0, selected)
- end)
+ ]], wildmenu_items=expected, wildmenu_pos=0}
feed('<tab>')
- screen:expect([[
+ screen:expect{grid=[[
|
~ |
~ |
~ |
:sign jump^ |
- ]], nil, nil, function()
- eq(expected, items)
- eq(1, selected)
- end)
+ ]], wildmenu_items=expected, wildmenu_pos=1}
feed('<left><left>')
- screen:expect([[
+ screen:expect{grid=[[
|
~ |
~ |
~ |
:sign ^ |
- ]], nil, nil, function()
- eq(expected, items)
- eq(-1, selected)
- end)
+ ]], wildmenu_items=expected, wildmenu_pos=-1}
feed('<right>')
- screen:expect([[
+ screen:expect{grid=[[
|
~ |
~ |
~ |
:sign define^ |
- ]], nil, nil, function()
- eq(expected, items)
- eq(0, selected)
- end)
+ ]], wildmenu_items=expected, wildmenu_pos=0}
feed('a')
- screen:expect([[
+ screen:expect{grid=[[
|
~ |
~ |
~ |
:sign definea^ |
- ]], nil, nil, function()
- eq(nil, items)
- eq(nil, selected)
- end)
+ ]]}
end)
end)