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 | |
Bram Moolenaar | 1fb0831 | 2019-08-29 20:02:11 +0200 | [diff] [blame] | 48 | call term_sendkeys(buf, "4\<C-E>") |
| 49 | call VerifyScreenDump(buf, 'Test_popup_textprop_07', {}) |
| 50 | |
Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 51 | " clean up |
| 52 | call StopVimInTerminal(buf) |
| 53 | call delete('XtestTextpropPopup') |
| 54 | endfunc |
| 55 | |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 56 | func Test_textprop_popup_corners() |
| 57 | let lines =<< trim END |
| 58 | call setline(1, range(1, 100)) |
| 59 | call setline(50, 'now working with some longer text here') |
| 60 | 50 |
| 61 | normal zz |
| 62 | set scrolloff=0 |
| 63 | call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) |
| 64 | call prop_add(50, 23, #{ |
| 65 | \ length: 6, |
| 66 | \ type: 'popupMarker', |
| 67 | \ }) |
| 68 | let winid = popup_create('bottom left', #{ |
| 69 | \ pos: 'botleft', |
| 70 | \ textprop: 'popupMarker', |
| 71 | \ padding: [0,1,0,1], |
| 72 | \ }) |
| 73 | let winid = popup_create('bottom right', #{ |
| 74 | \ pos: 'botright', |
| 75 | \ textprop: 'popupMarker', |
| 76 | \ border: [], |
| 77 | \ padding: [0,1,0,1], |
| 78 | \ }) |
| 79 | let winid = popup_create('top left', #{ |
| 80 | \ pos: 'topleft', |
| 81 | \ textprop: 'popupMarker', |
| 82 | \ border: [], |
| 83 | \ padding: [0,1,0,1], |
| 84 | \ }) |
| 85 | let winid = popup_create('top right', #{ |
| 86 | \ pos: 'topright', |
| 87 | \ textprop: 'popupMarker', |
| 88 | \ padding: [0,1,0,1], |
| 89 | \ }) |
| 90 | END |
| 91 | call writefile(lines, 'XtestTextpropPopupCorners') |
| 92 | let buf = RunVimInTerminal('-S XtestTextpropPopupCorners', #{rows: 12}) |
| 93 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_1', {}) |
| 94 | |
| 95 | call term_sendkeys(buf, "0dw") |
| 96 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_2', {}) |
| 97 | |
| 98 | call term_sendkeys(buf, "46Goextra\<Esc>") |
| 99 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_3', {}) |
| 100 | |
| 101 | call term_sendkeys(buf, "u") |
Bram Moolenaar | 57441d6 | 2019-08-28 22:38:07 +0200 | [diff] [blame] | 102 | call term_sendkeys(buf, ":\<CR>") |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 103 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_4', {}) |
| 104 | |
Bram Moolenaar | 1fb0831 | 2019-08-29 20:02:11 +0200 | [diff] [blame] | 105 | call term_sendkeys(buf, ":vsplit foo\<CR>") |
| 106 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_5', {}) |
| 107 | |
| 108 | call term_sendkeys(buf, ":only!\<CR>") |
| 109 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_6', {}) |
| 110 | |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 111 | " clean up |
| 112 | call StopVimInTerminal(buf) |
| 113 | call delete('XtestTextpropPopupCorners') |
| 114 | endfunc |
| 115 | |
Bram Moolenaar | 1fb0831 | 2019-08-29 20:02:11 +0200 | [diff] [blame] | 116 | func Test_textprop_popup_offsets() |
| 117 | let lines =<< trim END |
| 118 | call setline(1, range(1, 100)) |
| 119 | call setline(50, 'now working with some longer text here') |
| 120 | 50 |
| 121 | normal zz |
| 122 | set scrolloff=0 |
| 123 | call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) |
| 124 | call prop_add(50, 23, #{ |
| 125 | \ length: 6, |
| 126 | \ type: 'popupMarker', |
| 127 | \ }) |
| 128 | let winid = popup_create('bottom left', #{ |
| 129 | \ pos: 'botleft', |
| 130 | \ line: -1, |
| 131 | \ col: 2, |
| 132 | \ textprop: 'popupMarker', |
| 133 | \ padding: [0,1,0,1], |
| 134 | \ }) |
| 135 | let winid = popup_create('bottom right', #{ |
| 136 | \ pos: 'botright', |
| 137 | \ line: -1, |
| 138 | \ col: -2, |
| 139 | \ textprop: 'popupMarker', |
| 140 | \ border: [], |
| 141 | \ padding: [0,1,0,1], |
| 142 | \ }) |
| 143 | let winid = popup_create('top left', #{ |
| 144 | \ pos: 'topleft', |
| 145 | \ line: 1, |
| 146 | \ col: 2, |
| 147 | \ textprop: 'popupMarker', |
| 148 | \ border: [], |
| 149 | \ padding: [0,1,0,1], |
| 150 | \ }) |
| 151 | let winid = popup_create('top right', #{ |
| 152 | \ pos: 'topright', |
| 153 | \ line: 1, |
| 154 | \ col: -2, |
| 155 | \ textprop: 'popupMarker', |
| 156 | \ padding: [0,1,0,1], |
| 157 | \ }) |
| 158 | END |
| 159 | call writefile(lines, 'XtestTextpropPopupOffset') |
| 160 | let buf = RunVimInTerminal('-S XtestTextpropPopupOffset', #{rows: 12}) |
| 161 | call VerifyScreenDump(buf, 'Test_popup_textprop_off_1', {}) |
| 162 | |
| 163 | " test that removing the text property closes the popups |
| 164 | call term_sendkeys(buf, ":call prop_clear(50)\<CR>") |
| 165 | call VerifyScreenDump(buf, 'Test_popup_textprop_off_2', {}) |
| 166 | |
| 167 | " clean up |
| 168 | call StopVimInTerminal(buf) |
| 169 | call delete('XtestTextpropPopupOffset') |
| 170 | endfunc |
| 171 | |
Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 172 | |
| 173 | " vim: shiftwidth=2 sts=2 |