Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 1 | " Tests for popup windows for text properties |
| 2 | |
| 3 | source check.vim |
| 4 | CheckFeature textprop |
| 5 | |
| 6 | source screendump.vim |
| 7 | CheckScreendump |
| 8 | |
| 9 | func Test_textprop_popup() |
| 10 | let lines =<< trim END |
| 11 | call setline(1, range(1, 100)) |
| 12 | call setline(50, 'some text to work with') |
| 13 | 50 |
| 14 | normal zz |
| 15 | set scrolloff=0 |
| 16 | call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) |
| 17 | call prop_add(50, 11, #{ |
| 18 | \ length: 7, |
| 19 | \ type: 'popupMarker', |
| 20 | \ }) |
| 21 | let winid = popup_create('the text', #{ |
| 22 | \ pos: 'botleft', |
| 23 | \ textprop: 'popupMarker', |
| 24 | \ border: [], |
| 25 | \ padding: [0,1,0,1], |
| 26 | \ close: 'click', |
| 27 | \ }) |
| 28 | END |
| 29 | call writefile(lines, 'XtestTextpropPopup') |
| 30 | let buf = RunVimInTerminal('-S XtestTextpropPopup', #{rows: 10}) |
| 31 | call VerifyScreenDump(buf, 'Test_popup_textprop_01', {}) |
| 32 | |
| 33 | call term_sendkeys(buf, "zt") |
| 34 | call VerifyScreenDump(buf, 'Test_popup_textprop_02', {}) |
| 35 | |
| 36 | call term_sendkeys(buf, "zzIawe\<Esc>") |
| 37 | call VerifyScreenDump(buf, 'Test_popup_textprop_03', {}) |
| 38 | |
| 39 | call term_sendkeys(buf, "0dw") |
| 40 | call VerifyScreenDump(buf, 'Test_popup_textprop_04', {}) |
| 41 | |
| 42 | call term_sendkeys(buf, "Oinserted\<Esc>") |
| 43 | call VerifyScreenDump(buf, 'Test_popup_textprop_05', {}) |
| 44 | |
| 45 | call term_sendkeys(buf, "k2dd") |
| 46 | call VerifyScreenDump(buf, 'Test_popup_textprop_06', {}) |
| 47 | |
| 48 | " clean up |
| 49 | call StopVimInTerminal(buf) |
| 50 | call delete('XtestTextpropPopup') |
| 51 | endfunc |
| 52 | |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 53 | func Test_textprop_popup_corners() |
| 54 | let lines =<< trim END |
| 55 | call setline(1, range(1, 100)) |
| 56 | call setline(50, 'now working with some longer text here') |
| 57 | 50 |
| 58 | normal zz |
| 59 | set scrolloff=0 |
| 60 | call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) |
| 61 | call prop_add(50, 23, #{ |
| 62 | \ length: 6, |
| 63 | \ type: 'popupMarker', |
| 64 | \ }) |
| 65 | let winid = popup_create('bottom left', #{ |
| 66 | \ pos: 'botleft', |
| 67 | \ textprop: 'popupMarker', |
| 68 | \ padding: [0,1,0,1], |
| 69 | \ }) |
| 70 | let winid = popup_create('bottom right', #{ |
| 71 | \ pos: 'botright', |
| 72 | \ textprop: 'popupMarker', |
| 73 | \ border: [], |
| 74 | \ padding: [0,1,0,1], |
| 75 | \ }) |
| 76 | let winid = popup_create('top left', #{ |
| 77 | \ pos: 'topleft', |
| 78 | \ textprop: 'popupMarker', |
| 79 | \ border: [], |
| 80 | \ padding: [0,1,0,1], |
| 81 | \ }) |
| 82 | let winid = popup_create('top right', #{ |
| 83 | \ pos: 'topright', |
| 84 | \ textprop: 'popupMarker', |
| 85 | \ padding: [0,1,0,1], |
| 86 | \ }) |
| 87 | END |
| 88 | call writefile(lines, 'XtestTextpropPopupCorners') |
| 89 | let buf = RunVimInTerminal('-S XtestTextpropPopupCorners', #{rows: 12}) |
| 90 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_1', {}) |
| 91 | |
| 92 | call term_sendkeys(buf, "0dw") |
| 93 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_2', {}) |
| 94 | |
| 95 | call term_sendkeys(buf, "46Goextra\<Esc>") |
| 96 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_3', {}) |
| 97 | |
| 98 | call term_sendkeys(buf, "u") |
Bram Moolenaar | 57441d6 | 2019-08-28 22:38:07 +0200 | [diff] [blame^] | 99 | call term_sendkeys(buf, ":\<CR>") |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 100 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_4', {}) |
| 101 | |
| 102 | " clean up |
| 103 | call StopVimInTerminal(buf) |
| 104 | call delete('XtestTextpropPopupCorners') |
| 105 | endfunc |
| 106 | |
Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 107 | |
| 108 | " vim: shiftwidth=2 sts=2 |