Mercurial > vim
comparison src/testdir/test_terminal.vim @ 11846:1c65cad8b967 v8.0.0803
patch 8.0.0804: terminal window functions not yet implemented
commit https://github.com/vim/vim/commit/c6df10e5d33ffab2c392626e285317ea8241ebff
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 29 20:15:08 2017 +0200
patch 8.0.0804: terminal window functions not yet implemented
Problem: Terminal window functions not yet implemented.
Solution: Implement several functions. Add a first test. (Yasuhiro
Matsumoto, closes #1871)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 29 Jul 2017 20:30:04 +0200 |
parents | |
children | ff8122091ec6 |
comparison
equal
deleted
inserted
replaced
11845:4be4a033c246 | 11846:1c65cad8b967 |
---|---|
1 " Tests for the terminal window. | |
2 | |
3 if !exists('*term_start') | |
4 finish | |
5 endif | |
6 | |
7 source shared.vim | |
8 | |
9 func Test_terminal_basic() | |
10 let buf = term_start(&shell) | |
11 | |
12 let termlist = term_list() | |
13 call assert_equal(1, len(termlist)) | |
14 call assert_equal(buf, termlist[0]) | |
15 | |
16 let g:job = term_getjob(buf) | |
17 call assert_equal(v:t_job, type(g:job)) | |
18 | |
19 call term_sendkeys(buf, "exit\r") | |
20 call WaitFor('job_status(g:job) == "dead"') | |
21 call assert_equal('dead', job_status(g:job)) | |
22 | |
23 exe buf . 'bwipe' | |
24 unlet g:job | |
25 endfunc | |
26 | |
27 func Check_123(buf) | |
28 let l = term_scrape(a:buf, 0) | |
29 call assert_true(len(l) > 0) | |
30 call assert_equal('1', l[0].chars) | |
31 call assert_equal('2', l[1].chars) | |
32 call assert_equal('3', l[2].chars) | |
33 call assert_equal('#00e000', l[0].fg) | |
34 if &background == 'light' | |
35 call assert_equal('#ffffff', l[0].bg) | |
36 else | |
37 call assert_equal('#000000', l[0].bg) | |
38 endif | |
39 | |
40 let l = term_getline(a:buf, 0) | |
41 call assert_equal('123', l) | |
42 endfunc | |
43 | |
44 func Test_terminal_scrape() | |
45 if has('win32') | |
46 let cmd = 'cmd /c "cls && color 2 && echo 123"' | |
47 else | |
48 call writefile(["\<Esc>[32m123"], 'Xtext') | |
49 let cmd = "cat Xtext" | |
50 endif | |
51 let buf = term_start(cmd) | |
52 | |
53 let termlist = term_list() | |
54 call assert_equal(1, len(termlist)) | |
55 call assert_equal(buf, termlist[0]) | |
56 | |
57 call term_wait(buf) | |
58 call Check_123(buf) | |
59 | |
60 " Must still work after the job ended. | |
61 let g:job = term_getjob(buf) | |
62 call WaitFor('job_status(g:job) == "dead"') | |
63 call term_wait(buf) | |
64 call Check_123(buf) | |
65 | |
66 exe buf . 'bwipe' | |
67 endfunc |