1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
" Test for the OSC 52 plugin
CheckFeature clipboard_provider
CheckRunMNVInTerminal
source util/screendump.mnv
" Check if plugin correctly detects OSC 52 support if possible
func Test_osc52_detect()
let lines =<< trim END
let g:osc52_no_da1 = 1
packadd osc52
set clipmethod=osc52
END
call writefile(lines, "Xosc52.mnv", "D")
defer delete("Xosc52result")
let buf = RunMNVInTerminal("-S Xosc52.mnv", {})
" The plugin creates an autocmd listening for DA1 responses
" No support
call term_sendkeys(buf, "\<Esc>[?62;22;c")
call TermWait(buf)
call term_sendkeys(buf,
\ "\<Esc>:call writefile([v:termda1, v:clipmethod], 'Xosc52result')\<CR>")
call TermWait(buf)
call WaitForAssert({->
\ assert_equal(["\<Esc>[?62;22;c", "none"], readfile('Xosc52result'))})
" Yes support
call term_sendkeys(buf, "\<Esc>[?62;2;3;4;1;52;c")
call TermWait(buf)
call term_sendkeys(buf,
\ "\<Esc>:call writefile([v:termda1, v:clipmethod], 'Xosc52result')\<CR>")
call TermWait(buf)
call WaitForAssert({-> assert_equal(["\<Esc>[?62;2;3;4;1;52;c", "osc52"],
\ readfile('Xosc52result'))})
call StopMNVInTerminal(buf)
endfunc
" Test if pasting works
func Test_osc52_paste()
CheckScreendump
let lines =<< trim END
let g:osc52_no_da1 = 1
packadd osc52
set clipmethod=osc52
redraw!
END
call writefile(lines, "Xosc52.mnv", "D")
let buf = RunMNVInTerminal("-S Xosc52.mnv", {})
call term_sendkeys(buf, "\<Esc>[?52;c")
call TermWait(buf)
call term_sendkeys(buf, "\"+p")
call TermWait(buf)
" Check to see if message is shown after a second of waiting for a response
sleep 1500m
call VerifyScreenDump(buf, 'Test_osc52_paste_01', {})
call term_sendkeys(buf, "\<Esc>]52;c;" ..
\ base64_encode(str2blob(["hello", "world!"])) .. "\<Esc>\\")
call TermWait(buf)
" Check if message is gone
call VerifyScreenDump(buf, 'Test_osc52_paste_02', {})
" Test when invalid base64 content received (should emit a message)
call term_sendkeys(buf, "\"+p")
call TermWait(buf)
call term_sendkeys(buf, "\<Esc>]52;c;abc\<Esc>\\")
call TermWait(buf)
call VerifyScreenDump(buf, 'Test_osc52_paste_03', {})
" Test if interrupt is handled and message is outputted
call term_sendkeys(buf, "\"+p")
call TermWait(buf)
call term_sendkeys(buf, "\<C-c>")
call TermWait(buf)
call VerifyScreenDump(buf, 'Test_osc52_paste_04', {})
call StopMNVInTerminal(buf)
endfunc
" mnv: shiftwidth=2 sts=2 expandtab
|