diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-25 09:14:47 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-25 18:57:36 -0300 |
commit | 2aa2513b8e023a0d7bd2071299f0ea59a4d4ce25 (patch) | |
tree | b684785ba9c769491e6ebdac8e21495cf22dbdd3 /test/functional/terminal/altscreen_spec.lua | |
parent | 710002c820e5a55e3b234074fefb84ab745e11a3 (diff) | |
download | rneovim-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/altscreen_spec.lua')
-rw-r--r-- | test/functional/terminal/altscreen_spec.lua | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua new file mode 100644 index 0000000000..9ec0fc7c5a --- /dev/null +++ b/test/functional/terminal/altscreen_spec.lua @@ -0,0 +1,158 @@ +local helpers = require('test.functional.helpers') +local thelpers = require('test.functional.terminal.helpers') +local Screen = require('test.functional.ui.screen') +local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf +local feed = helpers.feed +local feed_data = thelpers.feed_data +local enter_altscreen = thelpers.enter_altscreen +local exit_altscreen = thelpers.exit_altscreen + +describe('terminal altscreen', function() + local screen + + before_each(function() + clear() + screen = thelpers.screen_setup() + feed_data({'line1', 'line2', 'line3', 'line4', 'line5', 'line6', + 'line7', 'line8', ''}) + screen:expect([[ + line4 | + line5 | + line6 | + line7 | + line8 | + {1: } | + -- TERMINAL -- | + ]]) + enter_altscreen() + screen:expect([[ + | + | + | + | + | + {1: } | + -- TERMINAL -- | + ]]) + eq(10, curbuf('line_count')) + end) + + it('wont clear lines already in the scrollback', function() + feed('<c-\\><c-n>gg') + screen:expect([[ + ^tty ready | + line1 | + line2 | + line3 | + | + | + | + ]]) + end) + + describe('on exit', function() + before_each(exit_altscreen) + + it('restores buffer state', function() + screen:expect([[ + line4 | + line5 | + line6 | + line7 | + line8 | + {1: } | + -- TERMINAL -- | + ]]) + feed('<c-\\><c-n>gg') + screen:expect([[ + ^tty ready | + line1 | + line2 | + line3 | + line4 | + line5 | + | + ]]) + end) + end) + + describe('with lines printed after the screen height limit', function() + before_each(function() + feed_data({'line9', 'line10', 'line11', 'line12', 'line13', + 'line14', 'line15', 'line16', ''}) + screen:expect([[ + line12 | + line13 | + line14 | + line15 | + line16 | + {1: } | + -- TERMINAL -- | + ]]) + end) + + it('wont modify line count', function() + eq(10, curbuf('line_count')) + end) + + it('wont modify lines in the scrollback', function() + feed('<c-\\><c-n>gg') + screen:expect([[ + ^tty ready | + line1 | + line2 | + line3 | + line12 | + line13 | + | + ]]) + end) + end) + + describe('after height is decreased by 2', function() + local function wait_removal() + screen:try_resize(screen._width, screen._height - 2) + screen:expect([[ + | + | + rows: 4, cols: 50 | + {1: } | + -- TERMINAL -- | + ]]) + end + + it('removes 2 lines from the bottom of the visible buffer', function() + wait_removal() + feed('<c-\\><c-n>4k') + screen:expect([[ + ^line3 | + | + | + rows: 4, cols: 50 | + | + ]]) + eq(8, curbuf('line_count')) + end) + + describe('and after exit', function() + before_each(function() + wait_removal() + exit_altscreen() + end) + + it('restore buffer state', function() + -- FIXME(tarruda): Note that the last line was lost after restoring the + -- screen. This is a libvterm bug: When the main screen is restored it + -- seems to "cut" lines that would have been left below the new visible + -- screen. + screen:expect([[ + line4 | + line5 | + line6 | + line7 | + -- TERMINAL -- | + ]]) + end) + end) + end) +end) |