diff options
Diffstat (limited to 'test/functional/ui/screen.lua')
| -rw-r--r-- | test/functional/ui/screen.lua | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 8b1b77eb81..a81851cbba 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -71,10 +71,10 @@ -- To help write screen tests, see Screen:snapshot_util(). -- To debug screen tests, see Screen:redraw_debug(). -local global_helpers = require('test.helpers') -local deepcopy = global_helpers.deepcopy -local shallowcopy = global_helpers.shallowcopy local helpers = require('test.functional.helpers')(nil) +local deepcopy = helpers.deepcopy +local shallowcopy = helpers.shallowcopy +local concat_tables = helpers.concat_tables local request, run_session = helpers.request, helpers.run_session local eq = helpers.eq local dedent = helpers.dedent @@ -259,22 +259,19 @@ local ext_keys = { 'messages', 'showmode', 'showcmd', 'ruler', 'float_pos', } --- Asserts that the screen state eventually matches an expected state +-- Asserts that the screen state eventually matches an expected state. -- --- This function can either be called with the positional forms --- --- screen:expect(grid, [attr_ids, attr_ignore]) --- screen:expect(condition) --- --- or to use additional arguments (or grid and condition at the same time) --- the keyword form has to be used: --- --- screen:expect{grid=[[...]], cmdline={...}, condition=function() ... end} +-- Can be called with positional args: +-- screen:expect(grid, [attr_ids, attr_ignore]) +-- screen:expect(condition) +-- or keyword args (supports more options): +-- screen:expect{grid=[[...]], cmdline={...}, condition=function() ... end} -- -- -- grid: Expected screen state (string). Each line represents a screen -- row. Last character of each row (typically "|") is stripped. -- Common indentation is stripped. +-- Lines containing only "{IGNORE}|" are skipped. -- attr_ids: Expected text attributes. Screen rows are transformed according -- to this table, as follows: each substring S composed of -- characters having the same attributes will be substituted by @@ -416,26 +413,23 @@ screen:redraw_debug() to show all intermediate screen states. ]]) end end - -- Extension features. The default expectations should cover the case of + -- UI extensions. The default expectations should cover the case of -- the ext_ feature being disabled, or the feature currently not activated - -- (for instance no external cmdline visible). Some extensions require + -- (e.g. no external cmdline visible). Some extensions require -- preprocessing to represent highlights in a reproducible way. local extstate = self:_extstate_repr(attr_state) - - -- convert assertion errors into invalid screen state descriptions - local status, res = pcall(function() - for _, k in ipairs(ext_keys) do - -- Empty states is considered the default and need not be mentioned - if not (expected[k] == nil and isempty(extstate[k])) then - eq(expected[k], extstate[k], k) + if expected['mode'] ~= nil then + extstate['mode'] = self.mode + end + -- Convert assertion errors into invalid screen state descriptions. + for _, k in ipairs(concat_tables(ext_keys, {'mode'})) do + -- Empty states are considered the default and need not be mentioned. + if (not (expected[k] == nil and isempty(extstate[k]))) then + local status, res = pcall(eq, expected[k], extstate[k], k) + if not status then + return (tostring(res)..'\nHint: full state of "'..k..'":\n '..inspect(extstate[k])) end end - if expected.mode ~= nil then - eq(expected.mode, self.mode, "mode") - end - end) - if not status then - return tostring(res) end end, expected) end @@ -937,10 +931,7 @@ function Screen:_handle_option_set(name, value) end function Screen:_handle_popupmenu_show(items, selected, row, col, grid) - if (not self._options.ext_multigrid) and grid == 1 then - grid = nil - end - self.popupmenu = {items=items, pos=selected, anchor={row, col, grid}} + self.popupmenu = {items=items, pos=selected, anchor={grid, row, col}} end function Screen:_handle_popupmenu_select(selected) |