annotate src/testdir/test_terminal3.vim @ 21448:ce67668c796f

Added tag v8.2.1274 for changeset 369cde0d57710fe4aa0af92feb07a22a6365eec6
author Bram Moolenaar <Bram@vim.org>
date Thu, 23 Jul 2020 13:15:07 +0200
parents 299cf1c2a37d
children 8c6433359913
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21253
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for the terminal window.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " This is split in two, because it can take a lot of time.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 " See test_terminal.vim and test_terminal2.vim for further tests.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 source check.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 CheckFeature terminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 source shared.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 source screendump.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 source mouse.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 source term_util.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let $PROMPT_COMMAND=''
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 func Test_terminal_altscreen()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 " somehow doesn't work on MS-Windows
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 CheckUnix
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 let cmd = "cat Xtext\<CR>"
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 let buf = term_start(&shell, {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 call writefile(["\<Esc>[?1047h"], 'Xtext')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 call term_sendkeys(buf, cmd)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 call WaitForAssert({-> assert_equal(1, term_getaltscreen(buf))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 call writefile(["\<Esc>[?1047l"], 'Xtext')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 call term_sendkeys(buf, cmd)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 call WaitForAssert({-> assert_equal(0, term_getaltscreen(buf))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 call term_sendkeys(buf, "exit\r")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 exe buf . "bwipe!"
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 call delete('Xtext')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 func Test_terminal_shell_option()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 if has('unix')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 " exec is a shell builtin command, should fail without a shell.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 term exec ls runtest.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 call WaitForAssert({-> assert_match('job failed', term_getline(bufnr(), 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 bwipe!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 term ++shell exec ls runtest.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 call WaitForAssert({-> assert_match('runtest.vim', term_getline(bufnr(), 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 bwipe!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 elseif has('win32')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 " dir is a shell builtin command, should fail without a shell.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 try
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 term dir /b runtest.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 call WaitForAssert({-> assert_match('job failed\|cannot access .*: No such file or directory', term_getline(bufnr(), 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 catch /CreateProcess/
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 " ignore
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 endtry
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 bwipe!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 term ++shell dir /b runtest.vim
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 call WaitForAssert({-> assert_match('runtest.vim', term_getline(bufnr(), 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 bwipe!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 endif
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 func Test_terminal_invalid_arg()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 call assert_fails('terminal ++xyz', 'E181:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 func Test_terminal_in_popup()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 CheckRunVimInTerminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 let text =<< trim END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 some text
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 to edit
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 in a popup window
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 call writefile(text, 'Xtext')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 let cmd = GetVimCommandCleanTerm()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 let lines = [
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 \ 'call setline(1, range(20))',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 \ 'hi PopTerm ctermbg=grey',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 \ 'func OpenTerm(setColor)',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 \ " set noruler",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 \ " let s:buf = term_start('" .. cmd .. " Xtext', #{hidden: 1, term_finish: 'close'})",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 \ ' let g:winid = popup_create(s:buf, #{minwidth: 45, minheight: 7, border: [], drag: 1, resize: 1})',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 \ ' if a:setColor',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 \ ' call win_execute(g:winid, "set wincolor=PopTerm")',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 \ ' endif',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 \ 'endfunc',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 \ 'func HidePopup()',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 \ ' call popup_hide(g:winid)',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 \ 'endfunc',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 \ 'func ClosePopup()',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 \ ' call popup_close(g:winid)',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 \ 'endfunc',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 \ 'func ReopenPopup()',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 \ ' call popup_create(s:buf, #{minwidth: 40, minheight: 6, border: []})',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 \ 'endfunc',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 \ ]
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 call writefile(lines, 'XtermPopup')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 call TermWait(buf, 100)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 call term_sendkeys(buf, ":call OpenTerm(0)\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 call TermWait(buf, 100)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 call term_sendkeys(buf, ":\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 call TermWait(buf, 100)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 call term_sendkeys(buf, "\<C-W>:echo getwinvar(g:winid, \"&buftype\") win_gettype(g:winid)\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 call VerifyScreenDump(buf, 'Test_terminal_popup_1', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 call term_sendkeys(buf, ":q\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 call VerifyScreenDump(buf, 'Test_terminal_popup_2', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 call term_sendkeys(buf, ":call OpenTerm(1)\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 call TermWait(buf, 150)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 call term_sendkeys(buf, ":set hlsearch\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 call TermWait(buf, 100)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 call term_sendkeys(buf, "/edit\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 call VerifyScreenDump(buf, 'Test_terminal_popup_3', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 call term_sendkeys(buf, "\<C-W>:call HidePopup()\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 call VerifyScreenDump(buf, 'Test_terminal_popup_4', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 call term_sendkeys(buf, "\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 call TermWait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 call term_sendkeys(buf, "\<C-W>:call ClosePopup()\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 call VerifyScreenDump(buf, 'Test_terminal_popup_5', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 call term_sendkeys(buf, "\<C-W>:call ReopenPopup()\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 call VerifyScreenDump(buf, 'Test_terminal_popup_6', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 " Go to terminal-Normal mode and visually select text.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 call term_sendkeys(buf, "\<C-W>Ngg/in\<CR>vww")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 call VerifyScreenDump(buf, 'Test_terminal_popup_7', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 " Back to job mode, redraws
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 call term_sendkeys(buf, "A")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 call VerifyScreenDump(buf, 'Test_terminal_popup_8', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 call TermWait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 call term_sendkeys(buf, ":q\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 call TermWait(buf, 150) " wait for terminal to vanish
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 call StopVimInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 call delete('Xtext')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 call delete('XtermPopup')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 " Check a terminal in popup window uses the default mininum size.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 func Test_terminal_in_popup_min_size()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 CheckRunVimInTerminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 let text =<< trim END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 another text
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 to show
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 in a popup window
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 call writefile(text, 'Xtext')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 let lines = [
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 \ 'call setline(1, range(20))',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 \ 'func OpenTerm()',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 \ " let s:buf = term_start('cat Xtext', #{hidden: 1})",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 \ ' let g:winid = popup_create(s:buf, #{ border: []})',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 \ 'endfunc',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 \ ]
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 call writefile(lines, 'XtermPopup')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 call TermWait(buf, 100)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 call term_sendkeys(buf, ":set noruler\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 call term_sendkeys(buf, ":call OpenTerm()\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 call TermWait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 call term_sendkeys(buf, ":\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 call VerifyScreenDump(buf, 'Test_terminal_popup_m1', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 call TermWait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 call term_sendkeys(buf, ":q\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 call TermWait(buf, 50) " wait for terminal to vanish
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 call StopVimInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 call delete('Xtext')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 call delete('XtermPopup')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 " Check a terminal in popup window with different colors
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 func Terminal_in_popup_colored(group_name, highlight_cmd, highlight_opt)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 CheckRunVimInTerminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 CheckUnix
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 let lines = [
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 \ 'call setline(1, range(20))',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 \ 'func OpenTerm()',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 \ " let s:buf = term_start('cat', #{hidden: 1, "
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 \ .. a:highlight_opt .. "})",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 \ ' let g:winid = popup_create(s:buf, #{ border: []})',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 \ 'endfunc',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 \ a:highlight_cmd,
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 \ ]
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 call writefile(lines, 'XtermPopup')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 call TermWait(buf, 100)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 call term_sendkeys(buf, ":set noruler\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 call term_sendkeys(buf, ":call OpenTerm()\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 call TermWait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 call term_sendkeys(buf, "hello\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 call VerifyScreenDump(buf, 'Test_terminal_popup_' .. a:group_name, {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 call term_sendkeys(buf, "\<C-D>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 call TermWait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 call term_sendkeys(buf, ":q\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 call TermWait(buf, 50) " wait for terminal to vanish
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 call StopVimInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 call delete('XtermPopup')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 func Test_terminal_in_popup_colored_Terminal()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 call Terminal_in_popup_colored("Terminal", "highlight Terminal ctermfg=blue ctermbg=yellow", "")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 func Test_terminal_in_popup_colored_group()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 call Terminal_in_popup_colored("MyTermCol", "highlight MyTermCol ctermfg=darkgreen ctermbg=lightblue", "term_highlight: 'MyTermCol',")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 func Test_double_popup_terminal()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 let buf1 = term_start(&shell, #{hidden: 1})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 let win1 = popup_create(buf1, {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 let buf2 = term_start(&shell, #{hidden: 1})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 call assert_fails('call popup_create(buf2, {})', 'E861:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 call popup_close(win1)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 exe buf1 .. 'bwipe!'
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 exe buf2 .. 'bwipe!'
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 func Test_issue_5607()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 let wincount = winnr('$')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 exe 'terminal' &shell &shellcmdflag 'exit'
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 let job = term_getjob(bufnr())
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 call WaitForAssert({-> assert_equal("dead", job_status(job))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 let old_wincolor = &wincolor
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 try
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 set wincolor=
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 finally
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 let &wincolor = old_wincolor
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 bw!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 endtry
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 func Test_hidden_terminal()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 let buf = term_start(&shell, #{hidden: 1})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 call assert_equal('', bufname('^$'))
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 call StopShellInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 func Test_term_nasty_callback()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 CheckExecutable sh
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 set hidden
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 let g:buf0 = term_start('sh', #{hidden: 1, term_finish: 'close'})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 call popup_create(g:buf0, {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 call assert_fails("call term_start(['sh', '-c'], #{curwin: 1})", 'E863:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 call popup_clear(1)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 set hidden&
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 func Test_term_and_startinsert()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 CheckRunVimInTerminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 CheckUnix
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 let lines =<< trim EOL
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 put='some text'
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 term
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 startinsert
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 EOL
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 call writefile(lines, 'XTest_startinsert')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 let buf = RunVimInTerminal('-S XTest_startinsert', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 call term_sendkeys(buf, "exit\r")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 call WaitForAssert({-> assert_equal("some text", term_getline(buf, 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 call term_sendkeys(buf, "0l")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 call term_sendkeys(buf, "A<\<Esc>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 call WaitForAssert({-> assert_equal("some text<", term_getline(buf, 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 call StopVimInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 call delete('XTest_startinsert')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 " Test for passing invalid arguments to terminal functions
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 func Test_term_func_invalid_arg()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 call assert_fails('let b = term_getaltscreen([])', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 call assert_fails('let a = term_getattr(1, [])', 'E730:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 call assert_fails('let c = term_getcursor([])', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 call assert_fails('let l = term_getline([], 1)', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 call assert_fails('let l = term_getscrolled([])', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 call assert_fails('let s = term_getsize([])', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 call assert_fails('let s = term_getstatus([])', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 call assert_fails('let s = term_scrape([], 1)', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 call assert_fails('call term_sendkeys([], "a")', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 call assert_fails('call term_setapi([], "")', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 call assert_fails('call term_setrestore([], "")', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 call assert_fails('call term_setkill([], "")', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 if has('gui') || has('termguicolors')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 call assert_fails('let p = term_getansicolors([])', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 call assert_fails('call term_setansicolors([], [])', 'E745:')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 endif
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 " Test for sending various special keycodes to a terminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 func Test_term_keycode_translation()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 CheckRunVimInTerminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 let buf = RunVimInTerminal('', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 call term_sendkeys(buf, ":set nocompatible\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 let keys = ["\<F1>", "\<F2>", "\<F3>", "\<F4>", "\<F5>", "\<F6>", "\<F7>",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 \ "\<F8>", "\<F9>", "\<F10>", "\<F11>", "\<F12>", "\<Home>",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 \ "\<S-Home>", "\<C-Home>", "\<End>", "\<S-End>", "\<C-End>",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 \ "\<Ins>", "\<Del>", "\<Left>", "\<S-Left>", "\<C-Left>", "\<Right>",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 \ "\<S-Right>", "\<C-Right>", "\<Up>", "\<S-Up>", "\<Down>",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 \ "\<S-Down>"]
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 let output = ['<F1>', '<F2>', '<F3>', '<F4>', '<F5>', '<F6>', '<F7>',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 \ '<F8>', '<F9>', '<F10>', '<F11>', '<F12>', '<Home>', '<S-Home>',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 \ '<C-Home>', '<End>', '<S-End>', '<C-End>', '<Insert>', '<Del>',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 \ '<Left>', '<S-Left>', '<C-Left>', '<Right>', '<S-Right>',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 \ '<C-Right>', '<Up>', '<S-Up>', '<Down>', '<S-Down>']
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 call term_sendkeys(buf, "i")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 for i in range(len(keys))
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 call term_sendkeys(buf, "\<C-U>\<C-K>" .. keys[i])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 call WaitForAssert({-> assert_equal(output[i], term_getline(buf, 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 endfor
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 let keypad_keys = ["\<k0>", "\<k1>", "\<k2>", "\<k3>", "\<k4>", "\<k5>",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 \ "\<k6>", "\<k7>", "\<k8>", "\<k9>", "\<kPoint>", "\<kPlus>",
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 \ "\<kMinus>", "\<kMultiply>", "\<kDivide>"]
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 let keypad_output = ['0', '1', '2', '3', '4', '5',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 \ '6', '7', '8', '9', '.', '+',
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 \ '-', '*', '/']
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 for i in range(len(keypad_keys))
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 " TODO: Mysteriously keypad 3 and 9 do not work on some systems.
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 if keypad_output[i] == '3' || keypad_output[i] == '9'
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 continue
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 endif
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 call term_sendkeys(buf, "\<C-U>" .. keypad_keys[i])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 call WaitForAssert({-> assert_equal(keypad_output[i], term_getline(buf, 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 endfor
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 call feedkeys("\<C-U>\<kEnter>\<BS>one\<C-W>.two", 'xt')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 call WaitForAssert({-> assert_equal('two', term_getline(buf, 1))})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 call StopVimInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 " Test for using the mouse in a terminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 func Test_term_mouse()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 CheckNotGui
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 CheckRunVimInTerminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 let save_mouse = &mouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 let save_term = &term
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 let save_ttymouse = &ttymouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 let save_clipboard = &clipboard
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 set mouse=a term=xterm ttymouse=sgr mousetime=200 clipboard=
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 let lines =<< trim END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 one two three four five
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 red green yellow red blue
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 vim emacs sublime nano
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 call writefile(lines, 'Xtest_mouse')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 " Create a terminal window running Vim for the test with mouse enabled
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 let prev_win = win_getid()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 let buf = RunVimInTerminal('Xtest_mouse -n', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 call term_sendkeys(buf, ":set nocompatible\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 call term_sendkeys(buf, ":set clipboard=\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 call term_sendkeys(buf, ":set mousemodel=extend\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 call term_wait(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 redraw!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 " Use the mouse to enter the terminal window
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 call win_gotoid(prev_win)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 call feedkeys(MouseLeftClickCode(1, 1), 'x')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 call feedkeys(MouseLeftReleaseCode(1, 1), 'x')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 call assert_equal(1, getwininfo(win_getid())[0].terminal)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 " Test for <LeftMouse> click/release
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 call test_setmouse(2, 5)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 call feedkeys("\<LeftMouse>\<LeftRelease>", 'xt')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 call test_setmouse(3, 8)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 let pos = json_decode(readfile('Xbuf')[0])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 call assert_equal([3, 8], pos[1:2])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 " Test for selecting text using mouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 call delete('Xbuf')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 call test_setmouse(2, 11)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 call term_sendkeys(buf, "\<LeftMouse>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 call test_setmouse(2, 16)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 call term_sendkeys(buf, "\<LeftRelease>y")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 call assert_equal('yellow', readfile('Xbuf')[0])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 " Test for selecting text using doubleclick
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 call delete('Xbuf')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 call test_setmouse(1, 11)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 call test_setmouse(1, 17)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 call term_sendkeys(buf, "\<LeftRelease>y")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 call assert_equal('three four', readfile('Xbuf')[0])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 " Test for selecting a line using triple click
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 call delete('Xbuf')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 call test_setmouse(3, 2)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>y")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 " Test for selecting a block using qudraple click
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 call delete('Xbuf')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 call test_setmouse(1, 11)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 call test_setmouse(3, 13)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 call term_sendkeys(buf, "\<LeftRelease>y")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 " Test for extending a selection using right click
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 call delete('Xbuf')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 call test_setmouse(2, 9)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 call test_setmouse(2, 16)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 call term_sendkeys(buf, "\<RightMouse>\<RightRelease>y")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 call assert_equal("n yellow", readfile('Xbuf')[0])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 " Test for pasting text using middle click
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 call delete('Xbuf')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 call term_sendkeys(buf, ":let @r='bright '\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 call test_setmouse(2, 22)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 call term_sendkeys(buf, "\"r\<MiddleMouse>\<MiddleRelease>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 call term_sendkeys(buf, ":call writefile([getline(2)], 'Xbuf')\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 call term_wait(buf, 50)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 call assert_equal("red bright blue", readfile('Xbuf')[0][-15:])
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 " cleanup
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 call term_wait(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 call StopVimInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 let &mouse = save_mouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 let &term = save_term
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 let &ttymouse = save_ttymouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 let &clipboard = save_clipboard
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 set mousetime&
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 call delete('Xtest_mouse')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 call delete('Xbuf')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 " Test for modeless selection in a terminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 func Test_term_modeless_selection()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 CheckUnix
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 CheckNotGui
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 CheckRunVimInTerminal
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 CheckFeature clipboard_working
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 let save_mouse = &mouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 let save_term = &term
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 let save_ttymouse = &ttymouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 set mouse=a term=xterm ttymouse=sgr mousetime=200
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 set clipboard=autoselectml
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 let lines =<< trim END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 one two three four five
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 red green yellow red blue
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 vim emacs sublime nano
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 END
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 call writefile(lines, 'Xtest_modeless')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 " Create a terminal window running Vim for the test with mouse disabled
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 let prev_win = win_getid()
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 let buf = RunVimInTerminal('Xtest_modeless -n', {})
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 call term_sendkeys(buf, ":set nocompatible\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 call term_sendkeys(buf, ":set mouse=\<CR>")
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 call term_wait(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 redraw!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 " Use the mouse to enter the terminal window
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 call win_gotoid(prev_win)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 call feedkeys(MouseLeftClickCode(1, 1), 'x')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 call feedkeys(MouseLeftReleaseCode(1, 1), 'x')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 call term_wait(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 call assert_equal(1, getwininfo(win_getid())[0].terminal)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 " Test for copying a modeless selection to clipboard
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 let @* = 'clean'
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 " communicating with X server may take a little time
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 sleep 100m
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 call feedkeys(MouseLeftClickCode(2, 3), 'x')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 call feedkeys(MouseLeftDragCode(2, 11), 'x')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 call feedkeys(MouseLeftReleaseCode(2, 11), 'x')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 call assert_equal("d green y", @*)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 " cleanup
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 call term_wait(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 call StopVimInTerminal(buf)
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 let &mouse = save_mouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 let &term = save_term
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 let &ttymouse = save_ttymouse
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 set mousetime& clipboard&
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 call delete('Xtest_modeless')
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 new | only!
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 endfunc
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521
21295
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
522 func Test_terminal_getwinpos()
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
523 CheckRunVimInTerminal
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
524
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
525 " split, go to the bottom-right window
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
526 split
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
527 wincmd j
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
528 set splitright
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
529
21427
299cf1c2a37d patch 8.2.1264: terminal getwinpos() test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21295
diff changeset
530 let buf = RunVimInTerminal('', {'cols': 60})
299cf1c2a37d patch 8.2.1264: terminal getwinpos() test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21295
diff changeset
531 call TermWait(buf, 100)
299cf1c2a37d patch 8.2.1264: terminal getwinpos() test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21295
diff changeset
532 call term_sendkeys(buf, ":echo getwinpos(500)\<CR>")
21295
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
533
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
534 " Find the output of getwinpos() in the bottom line.
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
535 let rows = term_getsize(buf)[0]
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
536 call WaitForAssert({-> assert_match('\[\d\+, \d\+\]', term_getline(buf, rows))})
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
537 let line = term_getline(buf, rows)
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
538 let xpos = str2nr(substitute(line, '\[\(\d\+\), \d\+\]', '\1', ''))
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
539 let ypos = str2nr(substitute(line, '\[\d\+, \(\d\+\)\]', '\1', ''))
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
540
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
541 " Position must be bigger than the getwinpos() result of Vim itself.
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
542 " The calculation in the console assumes a 10 x 7 character cell.
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
543 " In the GUI it can be more, let's assume a 20 x 14 cell.
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
544 " And then add 100 / 200 tolerance.
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
545 let [xroot, yroot] = getwinpos()
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
546 let winpos = 50->getwinpos()
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
547 call assert_equal(xroot, winpos[0])
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
548 call assert_equal(yroot, winpos[1])
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
549 let [winrow, wincol] = win_screenpos('.')
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
550 let xoff = wincol * (has('gui_running') ? 14 : 7) + 100
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
551 let yoff = winrow * (has('gui_running') ? 20 : 10) + 200
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
552 call assert_inrange(xroot + 2, xroot + xoff, xpos)
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
553 call assert_inrange(yroot + 2, yroot + yoff, ypos)
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
554
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
555 call TermWait(buf)
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
556 call term_sendkeys(buf, ":q\<CR>")
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
557 call StopVimInTerminal(buf)
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
558 exe buf . 'bwipe!'
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
559 set splitright&
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
560 only!
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
561 endfunc
3e0d4782d0c6 patch 8.2.1198: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
562
21253
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 " vim: shiftwidth=2 sts=2 expandtab