aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/cursor_spec.lua
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-03-25 09:14:47 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-03-25 18:57:36 -0300
commit2aa2513b8e023a0d7bd2071299f0ea59a4d4ce25 (patch)
treeb684785ba9c769491e6ebdac8e21495cf22dbdd3 /test/functional/terminal/cursor_spec.lua
parent710002c820e5a55e3b234074fefb84ab745e11a3 (diff)
downloadrneovim-2aa2513b8e023a0d7bd2071299f0ea59a4d4ce25.tar.gz
rneovim-2aa2513b8e023a0d7bd2071299f0ea59a4d4ce25.tar.bz2
rneovim-2aa2513b8e023a0d7bd2071299f0ea59a4d4ce25.zip
test: Add terminal tests
- Modify tty-test to allow easier control over the terminal - Add a new directory with various terminal tests/specifications - Remove a pending job/pty test. - Flush stdout in Screen:snapshot_util() (avoid waiting for the test to finish) - Replace libuv sigwinch watcher by a sigaction handler. libuv randomly fails to deliver signals on OSX. Might be related to the problem fixed by @bbcddc55ee1e5605657592644be0102ed3a5f104 (under the hoods, libuv uses a pipe to deliver signals to the main thread, which might be blocking in some situations)
Diffstat (limited to 'test/functional/terminal/cursor_spec.lua')
-rw-r--r--test/functional/terminal/cursor_spec.lua174
1 files changed, 174 insertions, 0 deletions
diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua
new file mode 100644
index 0000000000..3e3f9cbf4f
--- /dev/null
+++ b/test/functional/terminal/cursor_spec.lua
@@ -0,0 +1,174 @@
+local helpers = require('test.functional.helpers')
+local Screen = require('test.functional.ui.screen')
+local thelpers = require('test.functional.terminal.helpers')
+local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
+local nvim_dir, execute, eq = helpers.nvim_dir, helpers.execute, helpers.eq
+local hide_cursor = thelpers.hide_cursor
+local show_cursor = thelpers.show_cursor
+
+
+describe('terminal cursor', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = thelpers.screen_setup()
+ end)
+
+
+ it('moves the screen cursor when focused', function()
+ thelpers.feed_data('testing cursor')
+ screen:expect([[
+ tty ready |
+ testing cursor{1: } |
+ |
+ |
+ |
+ |
+ -- TERMINAL -- |
+ ]])
+ eq(2, screen._cursor.row)
+ eq(15, screen._cursor.col)
+ end)
+
+ it('is highlighted when not focused', function()
+ feed('<c-\\><c-n>')
+ screen:expect([[
+ tty ready |
+ {2: } |
+ |
+ |
+ |
+ ^ |
+ |
+ ]])
+ end)
+
+ describe('with number column', function()
+ before_each(function()
+ feed('<c-\\><c-n>:set number<cr>')
+ end)
+
+ it('is positioned correctly when unfocused', function()
+ screen:expect([[
+ 1 tty ready |
+ 2 {2: } |
+ 3 |
+ 4 |
+ 5 |
+ 6 ^ |
+ :set number |
+ ]])
+ end)
+
+ it('is positioned correctly when focused', function()
+ feed('i')
+ screen:expect([[
+ 1 tty ready |
+ 2 {1: } |
+ 3 |
+ 4 |
+ 5 |
+ 6 |
+ -- TERMINAL -- |
+ ]])
+ end)
+ end)
+
+ describe('when invisible', function()
+ it('is not highlighted and is detached from screen cursor', function()
+ hide_cursor()
+ screen:expect([[
+ tty ready |
+ |
+ |
+ |
+ |
+ |
+ -- TERMINAL -- |
+ ]])
+ show_cursor()
+ screen:expect([[
+ tty ready |
+ {1: } |
+ |
+ |
+ |
+ |
+ -- TERMINAL -- |
+ ]])
+ -- same for when the terminal is unfocused
+ feed('<c-\\><c-n>')
+ hide_cursor()
+ screen:expect([[
+ tty ready |
+ |
+ |
+ |
+ |
+ ^ |
+ |
+ ]])
+ show_cursor()
+ screen:expect([[
+ tty ready |
+ {2: } |
+ |
+ |
+ |
+ ^ |
+ |
+ ]])
+ end)
+ end)
+end)
+
+
+describe('cursor with customized highlighting', function()
+ local screen
+
+ before_each(function()
+ clear()
+ nvim('set_var', 'terminal_focused_cursor_highlight', 'CursorFocused')
+ nvim('set_var', 'terminal_unfocused_cursor_highlight', 'CursorUnfocused')
+ nvim('command', 'highlight CursorFocused ctermfg=45 ctermbg=46')
+ nvim('command', 'highlight CursorUnfocused ctermfg=55 ctermbg=56')
+ screen = Screen.new(50, 7)
+ screen:set_default_attr_ids({
+ [1] = {foreground = 45, background = 46},
+ [2] = {foreground = 55, background = 56}
+ })
+ screen:set_default_attr_ignore({
+ [1] = {bold = true},
+ [2] = {foreground = 12},
+ [3] = {bold = true, reverse = true},
+ [5] = {background = 11},
+ [6] = {foreground = 130},
+ })
+ screen:attach(false)
+ execute('term "' ..nvim_dir.. '/tty-test"')
+ end)
+
+ it('overrides the default highlighting', function()
+ screen:expect([[
+ tty ready |
+ {1: } |
+ |
+ |
+ |
+ |
+ -- TERMINAL -- |
+ ]])
+ feed('<c-\\><c-n>')
+ screen:expect([[
+ tty ready |
+ {2: } |
+ |
+ |
+ |
+ ^ |
+ |
+ ]])
+ end)
+end)
+