diff options
Diffstat (limited to 'test/functional/terminal/tui_spec.lua')
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 113 |
1 files changed, 112 insertions, 1 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index ba0c531c7e..14700a2622 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -1,10 +1,10 @@ -- Some sanity checks for the TUI using the builtin terminal emulator -- as a simple way to send keys and assert screen state. -local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers') local thelpers = require('test.functional.terminal.helpers') local feed = thelpers.feed_data local execute = helpers.execute +local nvim_dir = helpers.nvim_dir describe('tui', function() local screen @@ -173,3 +173,114 @@ describe('tui with non-tty file descriptors', function() ]]) end) end) + +describe('tui focus event handling', function() + local screen + + before_each(function() + helpers.clear() + screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]') + execute('autocmd FocusGained * echo "gained"') + execute('autocmd FocusLost * echo "lost"') + end) + + it('can handle focus events in normal mode', function() + feed('\x1b[I') + screen:expect([[ + {1: } | + ~ | + ~ | + ~ | + [No Name] | + gained | + -- TERMINAL -- | + ]]) + + feed('\x1b[O') + screen:expect([[ + {1: } | + ~ | + ~ | + ~ | + [No Name] | + lost | + -- TERMINAL -- | + ]]) + end) + + it('can handle focus events in insert mode', function() + execute('set noshowmode') + feed('i') + feed('\x1b[I') + screen:expect([[ + {1: } | + ~ | + ~ | + ~ | + [No Name] | + gained | + -- TERMINAL -- | + ]]) + feed('\x1b[O') + screen:expect([[ + {1: } | + ~ | + ~ | + ~ | + [No Name] | + lost | + -- TERMINAL -- | + ]]) + end) + + it('can handle focus events in cmdline mode', function() + feed(':') + feed('\x1b[I') + screen:expect([[ + | + ~ | + ~ | + ~ | + [No Name] | + g{1:a}ined | + -- TERMINAL -- | + ]]) + feed('\x1b[O') + screen:expect([[ + | + ~ | + ~ | + ~ | + [No Name] | + l{1:o}st | + -- TERMINAL -- | + ]]) + end) + + it('can handle focus events in terminal mode', function() + execute('set shell='..nvim_dir..'/shell-test') + execute('set laststatus=0') + execute('set noshowmode') + execute('terminal') + feed('\x1b[I') + screen:expect([[ + ready $ | + [Process exited 0]{1: } | + | + | + | + gained | + -- TERMINAL -- | + ]]) + feed('\x1b[O') + screen:expect([[ + ready $ | + [Process exited 0]{1: } | + | + | + | + lost | + -- TERMINAL -- | + ]]) + end) +end) |