aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/ex_cmds/menu_spec.lua65
-rw-r--r--test/functional/terminal/helpers.lua6
-rw-r--r--test/functional/terminal/mouse_spec.lua79
-rw-r--r--test/functional/terminal/window_spec.lua98
4 files changed, 196 insertions, 52 deletions
diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua
index 2c0535acda..2309e949c0 100644
--- a/test/functional/ex_cmds/menu_spec.lua
+++ b/test/functional/ex_cmds/menu_spec.lua
@@ -63,25 +63,27 @@ describe('menu_get', function()
before_each(function()
clear()
- command('nnoremenu &Test.Test inormal<ESC>')
- command('inoremenu Test.Test insert')
- command('vnoremenu Test.Test x')
- command('cnoremenu Test.Test cmdmode')
- command('menu Test.Nested.test level1')
- command('menu Test.Nested.Nested2 level2')
+ command([=[
+ nnoremenu &Test.Test inormal<ESC>
+ inoremenu Test.Test insert
+ vnoremenu Test.Test x
+ cnoremenu Test.Test cmdmode
+ menu Test.Nested.test level1
+ menu Test.Nested.Nested2 level2
- command('nnoremenu <script> Export.Script p')
- command('tmenu Export.Script This is the tooltip')
- command('menu ]Export.hidden thisoneshouldbehidden')
+ nnoremenu <script> Export.Script p
+ tmenu Export.Script This is the tooltip
+ menu ]Export.hidden thisoneshouldbehidden
- command('nnoremenu Edit.Paste p')
- command('cnoremenu Edit.Paste <C-R>"')
+ nnoremenu Edit.Paste p
+ cnoremenu Edit.Paste <C-R>"
+ ]=])
end)
it("path='', modes='a'", function()
local m = funcs.menu_get("","a");
-- HINT: To print the expected table and regenerate the tests:
- -- print(require('pl.pretty').dump(m))
+ -- print(require('inspect')(m))
local expected = {
{
shortcut = "T",
@@ -306,10 +308,13 @@ describe('menu_get', function()
eq(expected, m)
end)
- it('matching path, default modes', function()
+ it('matching path, all modes', function()
local m = funcs.menu_get("Export", "a")
- local expected = {
- {
+ local expected = { {
+ hidden = 0,
+ name = "Export",
+ priority = 500,
+ submenus = { {
tooltip = "This is the tooltip",
hidden = 0,
name = "Script",
@@ -323,8 +328,8 @@ describe('menu_get', function()
silent = 0
}
}
- }
- }
+ } }
+ } }
eq(expected, m)
end)
@@ -349,8 +354,6 @@ describe('menu_get', function()
name = "Test",
hidden = 0
},
- {
- }
},
priority = 500,
name = "Test"
@@ -363,14 +366,22 @@ describe('menu_get', function()
local m = funcs.menu_get("Test","i")
local expected = {
{
- mappings = {
- i = {
- sid = 1,
- noremap = 1,
- enabled = 1,
- rhs = "insert",
- silent = 0
- }
+ shortcut = "T",
+ submenus = {
+ {
+ mappings = {
+ i = {
+ sid = 1,
+ noremap = 1,
+ enabled = 1,
+ rhs = "insert",
+ silent = 0
+ },
+ },
+ priority = 500,
+ name = "Test",
+ hidden = 0
+ },
},
priority = 500,
name = "Test",
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index 7de0152de0..18f0b9e4c1 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -33,7 +33,7 @@ local function disable_mouse() feed_termcode('[?1002l') end
local default_command = '["'..nvim_dir..'/tty-test'..'"]'
-local function screen_setup(extra_rows, command, cols)
+local function screen_setup(extra_rows, command, cols, opts)
extra_rows = extra_rows and extra_rows or 0
command = command and command or default_command
cols = cols and cols or 50
@@ -55,7 +55,7 @@ local function screen_setup(extra_rows, command, cols)
[10] = {foreground = 121}, -- "Press ENTER" in embedded :terminal session.
})
- screen:attach({rgb=false})
+ screen:attach(opts or {rgb=false})
feed_command('enew | call termopen('..command..')')
nvim('input', '<CR>')
@@ -69,7 +69,7 @@ local function screen_setup(extra_rows, command, cols)
-- tty-test puts the terminal into raw mode and echoes input. Tests work by
-- feeding termcodes to control the display and asserting by screen:expect.
- if command == default_command then
+ if command == default_command and opts == nil then
-- Wait for "tty ready" to be printed before each test or the terminal may
-- still be in canonical mode (will echo characters for example).
local empty_line = (' '):rep(cols)
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index 263a5ce79d..5cd8c729cb 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -108,41 +108,42 @@ describe('terminal mouse', function()
]])
feed(':enew | set number<cr>')
screen:expect([[
- {7: 1 }^ │line28 |
- {4:~ }│line29 |
+ {7: 1 }^ │line29 |
{4:~ }│line30 |
{4:~ }│rows: 5, cols: 25 |
+ {4:~ }│rows: 5, cols: 24 |
{4:~ }│{2: } |
========== ========== |
:enew | set number |
]])
feed('30iline\n<esc>')
screen:expect([[
- {7: 27 }line │line28 |
- {7: 28 }line │line29 |
- {7: 29 }line │line30 |
- {7: 30 }line │rows: 5, cols: 25 |
+ {7: 27 }line │line29 |
+ {7: 28 }line │line30 |
+ {7: 29 }line │rows: 5, cols: 25 |
+ {7: 30 }line │rows: 5, cols: 24 |
{7: 31 }^ │{2: } |
========== ========== |
|
]])
feed('<c-w>li')
screen:expect([[
- {7: 27 }line │line28 |
- {7: 28 }line │line29 |
- {7: 29 }line │line30 |
- {7: 30 }line │rows: 5, cols: 25 |
+ {7: 27 }line │line29 |
+ {7: 28 }line │line30 |
+ {7: 29 }line │rows: 5, cols: 25 |
+ {7: 30 }line │rows: 5, cols: 24 |
{7: 31 } │{1: } |
========== ========== |
{3:-- TERMINAL --} |
]])
+
-- enabling mouse won't affect interaction with other windows
thelpers.enable_mouse()
thelpers.feed_data('mouse enabled\n')
screen:expect([[
- {7: 27 }line │line29 |
- {7: 28 }line │line30 |
- {7: 29 }line │rows: 5, cols: 25 |
+ {7: 27 }line │line30 |
+ {7: 28 }line │rows: 5, cols: 25 |
+ {7: 29 }line │rows: 5, cols: 24 |
{7: 30 }line │mouse enabled |
{7: 31 } │{1: } |
========== ========== |
@@ -153,9 +154,9 @@ describe('terminal mouse', function()
it('wont lose focus if another window is scrolled', function()
feed('<ScrollWheelUp><0,0><ScrollWheelUp><0,0>')
screen:expect([[
- {7: 21 }line │line29 |
- {7: 22 }line │line30 |
- {7: 23 }line │rows: 5, cols: 25 |
+ {7: 21 }line │line30 |
+ {7: 22 }line │rows: 5, cols: 25 |
+ {7: 23 }line │rows: 5, cols: 24 |
{7: 24 }line │mouse enabled |
{7: 25 }line │{1: } |
========== ========== |
@@ -163,9 +164,9 @@ describe('terminal mouse', function()
]])
feed('<S-ScrollWheelDown><0,0>')
screen:expect([[
- {7: 26 }line │line29 |
- {7: 27 }line │line30 |
- {7: 28 }line │rows: 5, cols: 25 |
+ {7: 26 }line │line30 |
+ {7: 27 }line │rows: 5, cols: 25 |
+ {7: 28 }line │rows: 5, cols: 24 |
{7: 29 }line │mouse enabled |
{7: 30 }line │{1: } |
========== ========== |
@@ -176,15 +177,49 @@ describe('terminal mouse', function()
it('will lose focus if another window is clicked', function()
feed('<LeftMouse><5,1>')
screen:expect([[
- {7: 27 }line │line29 |
- {7: 28 }l^ine │line30 |
- {7: 29 }line │rows: 5, cols: 25 |
+ {7: 27 }line │line30 |
+ {7: 28 }l^ine │rows: 5, cols: 25 |
+ {7: 29 }line │rows: 5, cols: 24 |
{7: 30 }line │mouse enabled |
{7: 31 } │{2: } |
========== ========== |
|
]])
end)
+
+ it('handles terminal size when switching buffers', function()
+ nvim('set_option', 'hidden', true)
+ feed('<c-\\><c-n><c-w><c-w>')
+ screen:expect([[
+ {7: 27 }line │line30 |
+ {7: 28 }line │rows: 5, cols: 25 |
+ {7: 29 }line │rows: 5, cols: 24 |
+ {7: 30 }line │mouse enabled |
+ {7: 31 }^ │{2: } |
+ ========== ========== |
+ |
+ ]])
+ feed(':bn<cr>')
+ screen:expect([[
+ rows: 5, cols: 25 │rows: 5, cols: 25 |
+ rows: 5, cols: 24 │rows: 5, cols: 24 |
+ mouse enabled │mouse enabled |
+ rows: 5, cols: 25 │rows: 5, cols: 25 |
+ {2:^ } │{2: } |
+ ========== ========== |
+ :bn |
+ ]])
+ feed(':bn<cr>')
+ screen:expect([[
+ {7: 27 }line │rows: 5, cols: 24 |
+ {7: 28 }line │mouse enabled |
+ {7: 29 }line │rows: 5, cols: 25 |
+ {7: 30 }line │rows: 5, cols: 24 |
+ {7: 31 }^ │{2: } |
+ ========== ========== |
+ :bn |
+ ]])
+ end)
end)
end)
end)
diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua
index 842a81872e..242377f9bd 100644
--- a/test/functional/terminal/window_spec.lua
+++ b/test/functional/terminal/window_spec.lua
@@ -124,3 +124,101 @@ describe('terminal window', function()
end)
end)
+describe('terminal window with multigrid', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = thelpers.screen_setup(0,nil,50,{ext_multigrid=true})
+ end)
+
+ it('resizes to requested size', function()
+ screen:expect([[
+ ## grid 1
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ {3:-- TERMINAL --} |
+ ## grid 2
+ tty ready |
+ {1: } |
+ |
+ |
+ |
+ |
+ ]])
+
+ screen:try_resize_grid(2, 20, 10)
+ if iswin() then
+ screen:expect{any="rows: 10, cols: 20"}
+ else
+ screen:expect([[
+ ## grid 1
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ {3:-- TERMINAL --} |
+ ## grid 2
+ tty ready |
+ rows: 10, cols: 20 |
+ {1: } |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ ]])
+ end
+
+ screen:try_resize_grid(2, 70, 3)
+ if iswin() then
+ screen:expect{any="rows: 3, cols: 70"}
+ else
+ screen:expect([[
+ ## grid 1
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ {3:-- TERMINAL --} |
+ ## grid 2
+ rows: 10, cols: 20 |
+ rows: 3, cols: 70 |
+ {1: } |
+ ]])
+ end
+
+ screen:try_resize_grid(2, 0, 0)
+ if iswin() then
+ screen:expect{any="rows: 6, cols: 50"}
+ else
+ screen:expect([[
+ ## grid 1
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|
+ {3:-- TERMINAL --} |
+ ## grid 2
+ tty ready |
+ rows: 10, cols: 20 |
+ rows: 3, cols: 70 |
+ rows: 6, cols: 50 |
+ {1: } |
+ |
+ ]])
+ end
+ end)
+end)