blob: 2a4eb2cd0d6449c9b6d3a6a0e4196102be4e8b5b [file] [log] [blame]
Bram Moolenaar8e956362019-08-25 23:08:17 +02001" Tests for popup windows for text properties
2
3source check.vim
4CheckFeature textprop
5
6source screendump.vim
7CheckScreendump
8
9func 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')
51endfunc
52
Bram Moolenaarbc2d4c12019-08-28 22:18:30 +020053func 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 Moolenaar57441d62019-08-28 22:38:07 +020099 call term_sendkeys(buf, ":\<CR>")
Bram Moolenaarbc2d4c12019-08-28 22:18:30 +0200100 call VerifyScreenDump(buf, 'Test_popup_textprop_corn_4', {})
101
102 " clean up
103 call StopVimInTerminal(buf)
104 call delete('XtestTextpropPopupCorners')
105endfunc
106
Bram Moolenaar8e956362019-08-25 23:08:17 +0200107
108" vim: shiftwidth=2 sts=2