From 6329fd420eec1f1325be2131726e82e23da3e90b Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Fri, 20 Nov 2015 23:09:30 +0000 Subject: [PATCH] Reorganize focus events test into individual tests The focus event tests now live in their own `describe` block with each test testing the handling of focus events in a single mode. --- test/functional/terminal/tui_spec.lua | 211 +++++++++++++------------- 1 file changed, 109 insertions(+), 102 deletions(-) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 92cd9567d2..3c79bc1fdb 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -149,108 +149,6 @@ describe('tui', function() -- TERMINAL -- | ]]) end) - - it('can handle focus events', function() - execute('set noshowmode') - execute('autocmd FocusGained * echo "gained"') - execute('autocmd FocusLost * echo "lost"') - - -- In normal mode - feed('\x1b[I') - screen:expect([[ - {1: } | - ~ | - ~ | - ~ | - [No Name] | - gained | - -- TERMINAL -- | - ]]) - - feed('\x1b[O') - screen:expect([[ - {1: } | - ~ | - ~ | - ~ | - [No Name] | - lost | - -- TERMINAL -- | - ]]) - - -- In insert mode - feed('i') - feed('\x1b[I') - screen:expect([[ - {1: } | - ~ | - ~ | - ~ | - [No Name] | - gained | - -- TERMINAL -- | - ]]) - feed('\x1b[O') - screen:expect([[ - {1: } | - ~ | - ~ | - ~ | - [No Name] | - lost | - -- TERMINAL -- | - ]]) - - -- In command-line mode - feed('\x1b') - 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 -- | - ]]) - - -- In terminal mode - execute('set shell='..nvim_dir..'/shell-test') - execute('set laststatus=0') - feed('\x1b') - 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) describe('tui with non-tty file descriptors', function() @@ -276,3 +174,112 @@ describe('tui with non-tty file descriptors', function() ]]) end) end) + +describe('tui focus event handling', function() + 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)