aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/window_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/api/window_spec.lua')
-rw-r--r--test/functional/api/window_spec.lua106
1 files changed, 74 insertions, 32 deletions
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 901d24327c..7c65cf9c37 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -15,25 +15,6 @@ local command = helpers.command
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
--- check if str is visible at the beginning of some line
-local function is_visible(str)
- local slen = string.len(str)
- local nlines = eval("&lines")
- for i = 1,nlines do
- local iseq = true
- for j = 1,slen do
- if string.byte(str,j) ~= eval("screenchar("..i..","..j..")") then
- iseq = false
- break
- end
- end
- if iseq then
- return true
- end
- end
- return false
-end
-
describe('API/win', function()
before_each(clear)
@@ -79,27 +60,61 @@ describe('API/win', function()
end)
it('updates the screen, and also when the window is unfocused', function()
+ local screen = Screen.new(30, 9)
+ screen:set_default_attr_ids({
+ [1] = {bold = true, foreground = Screen.colors.Blue},
+ [2] = {bold = true, reverse = true};
+ [3] = {reverse = true};
+ })
+ screen:attach()
+
insert("prologue")
feed('100o<esc>')
insert("epilogue")
local win = curwin()
feed('gg')
- poke_eventloop() -- let nvim process the 'gg' command
+ screen:expect{grid=[[
+ ^prologue |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ ]]}
-- cursor position is at beginning
eq({1, 0}, window('get_cursor', win))
- eq(true, is_visible("prologue"))
- eq(false, is_visible("epilogue"))
-- move cursor to end
window('set_cursor', win, {101, 0})
- eq(false, is_visible("prologue"))
- eq(true, is_visible("epilogue"))
+ screen:expect{grid=[[
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ ^epilogue |
+ |
+ ]]}
-- move cursor to the beginning again
window('set_cursor', win, {1, 0})
- eq(true, is_visible("prologue"))
- eq(false, is_visible("epilogue"))
+ screen:expect{grid=[[
+ ^prologue |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ ]]}
-- move focus to new window
nvim('command',"new")
@@ -107,18 +122,45 @@ describe('API/win', function()
-- sanity check, cursor position is kept
eq({1, 0}, window('get_cursor', win))
- eq(true, is_visible("prologue"))
- eq(false, is_visible("epilogue"))
+ screen:expect{grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {2:[No Name] }|
+ prologue |
+ |
+ |
+ {3:[No Name] [+] }|
+ |
+ ]]}
-- move cursor to end
window('set_cursor', win, {101, 0})
- eq(false, is_visible("prologue"))
- eq(true, is_visible("epilogue"))
+ screen:expect{grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {2:[No Name] }|
+ |
+ |
+ epilogue |
+ {3:[No Name] [+] }|
+ |
+ ]]}
-- move cursor to the beginning again
window('set_cursor', win, {1, 0})
- eq(true, is_visible("prologue"))
- eq(false, is_visible("epilogue"))
+ screen:expect{grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {2:[No Name] }|
+ prologue |
+ |
+ |
+ {3:[No Name] [+] }|
+ |
+ ]]}
-- curwin didn't change back
neq(win, curwin())