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