Bram Moolenaar | 4d784b2 | 2019-05-25 19:51:39 +0200 | [diff] [blame] | 1 | " Tests for popup windows |
| 2 | |
| 3 | if !has('textprop') |
| 4 | finish |
| 5 | endif |
| 6 | |
| 7 | source screendump.vim |
| 8 | |
| 9 | func Test_simple_popup() |
| 10 | if !CanRunVimInTerminal() |
| 11 | return |
| 12 | endif |
| 13 | call writefile([ |
| 14 | \ "call setline(1, range(1, 100))", |
| 15 | \ "let winid = popup_create('hello there', {'line': 3, 'col': 11})", |
| 16 | \ "hi PopupColor ctermbg=lightblue", |
| 17 | \ "call setwinvar(winid, '&wincolor', 'PopupColor')", |
| 18 | \ "let winid2 = popup_create(['another one', 'another two', 'another three'], {'line': 3, 'col': 25})", |
| 19 | \], 'XtestPopup') |
| 20 | let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10}) |
| 21 | call VerifyScreenDump(buf, 'Test_popupwin_01', {}) |
| 22 | |
Bram Moolenaar | ec58384 | 2019-05-26 14:11:23 +0200 | [diff] [blame] | 23 | " Add a tabpage |
| 24 | call term_sendkeys(buf, ":tabnew\<CR>") |
| 25 | call term_sendkeys(buf, ":call popup_create('other tab', {'line': 4, 'col': 9})\<CR>") |
| 26 | call VerifyScreenDump(buf, 'Test_popupwin_02', {}) |
| 27 | |
| 28 | " switch back to first tabpage |
| 29 | call term_sendkeys(buf, "gt") |
| 30 | call VerifyScreenDump(buf, 'Test_popupwin_03', {}) |
| 31 | |
| 32 | " close that tabpage |
| 33 | call term_sendkeys(buf, ":quit!\<CR>") |
| 34 | call VerifyScreenDump(buf, 'Test_popupwin_04', {}) |
| 35 | |
Bram Moolenaar | 4d784b2 | 2019-05-25 19:51:39 +0200 | [diff] [blame] | 36 | " clean up |
| 37 | call StopVimInTerminal(buf) |
| 38 | call delete('XtestPopup') |
| 39 | endfunc |
Bram Moolenaar | 51fe3b1 | 2019-05-26 20:10:06 +0200 | [diff] [blame^] | 40 | |
| 41 | func Test_popup_time() |
| 42 | topleft vnew |
| 43 | call setline(1, 'hello') |
| 44 | |
| 45 | call popup_create('world', { |
| 46 | \ 'line': 1, |
| 47 | \ 'col': 1, |
| 48 | \ 'time': 500, |
| 49 | \}) |
| 50 | redraw |
| 51 | let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') |
| 52 | call assert_equal('world', line) |
| 53 | |
| 54 | sleep 700m |
| 55 | let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') |
| 56 | call assert_equal('hello', line) |
| 57 | |
| 58 | call popup_create('on the command line', { |
| 59 | \ 'line': &lines, |
| 60 | \ 'col': 10, |
| 61 | \ 'time': 500, |
| 62 | \}) |
| 63 | redraw |
| 64 | let line = join(map(range(1, 30), 'screenstring(&lines, v:val)'), '') |
| 65 | call assert_match('.*on the command line.*', line) |
| 66 | |
| 67 | sleep 700m |
| 68 | redraw |
| 69 | let line = join(map(range(1, 30), 'screenstring(&lines, v:val)'), '') |
| 70 | call assert_notmatch('.*on the command line.*', line) |
| 71 | |
| 72 | bwipe! |
| 73 | endfunc |