blob: 96899428446f736b233e443fb0d6984aa821999e (
plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
# This file is a Tcl script to test out Tk's clipboard management code,
# especially the "clipboard" command. It is organized in the standard
# fashion for Tcl tests.
#
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# Note: Multiple display clipboard handling will only be tested if the
# environment variable TK_ALT_DISPLAY is set to an alternate display.
#
#################################################################
# Note that some of these tests may fail if another application #
# is grabbing the clipboard (e.g. an X server, or a VNC viewer) #
#################################################################
package require tcltest 2.2
namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
# set up a very large buffer to test INCR retrievals
set longValue ""
foreach i {a b c d e f g j h i j k l m o p q r s t u v w x y z} {
set j $i.1$i.2$i.3$i.4$i.5$i.6$i.7$i.8$i.9$i.10$i.11$i.12$i.13$i.14
append longValue A$j B$j C$j D$j E$j F$j G$j H$j I$j K$j L$j M$j N$j
}
# Now we start the main body of the test code
test clipboard-1.1 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append "test"
clipboard get
} -cleanup {
clipboard clear
} -result {test}
test clipboard-1.2 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append "test"
clipboard append "ing"
clipboard get
} -cleanup {
clipboard clear
} -result {testing}
test clipboard-1.3 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append "t"
clipboard append "e"
clipboard append "s"
clipboard append "t"
clipboard get
} -cleanup {
clipboard clear
} -result {test}
test clipboard-1.4 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append $longValue
clipboard get
} -cleanup {
clipboard clear
} -result "$longValue"
test clipboard-1.5 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append $longValue
clipboard append "test"
clipboard get
} -cleanup {
clipboard clear
} -result "${longValue}test"
test clipboard-1.6 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append -t TEST $longValue
clipboard append -t STRING "test"
list [clipboard get -t STRING] [clipboard get -t TEST]
} -cleanup {
clipboard clear
} -result [list test $longValue]
test clipboard-1.7 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append -t TEST [string range $longValue 1 4000]
clipboard append -t STRING "test"
list [clipboard get -t STRING] [clipboard get -t TEST]
} -cleanup {
clipboard clear
} -result [list test [string range $longValue 1 4000]]
test clipboard-1.8 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append ""
clipboard get
} -cleanup {
clipboard clear
} -result {}
test clipboard-1.9 {ClipboardHandler procedure} -setup {
clipboard clear
} -body {
clipboard append ""
clipboard append "Test"
clipboard get
} -cleanup {
clipboard clear
} -result {Test}
##############################################################################
test clipboard-2.1 {ClipboardAppHandler procedure} -setup {
set oldAppName [tk appname]
clipboard clear
} -body {
tk appname UnexpectedName
clipboard append -type NEW_TYPE Data
selection get -selection CLIPBOARD -type TK_APPLICATION
} -cleanup {
tk appname $oldAppName
clipboard clear
} -result {UnexpectedName}
##############################################################################
test clipboard-3.1 {ClipboardWindowHandler procedure} -setup {
set oldAppName [tk appname]
clipboard clear
} -body {
tk appname UnexpectedName
clipboard append -type NEW_TYPE Data
selection get -selection CLIPBOARD -type TK_WINDOW
} -cleanup {
tk appname $oldAppName
clipboard clear
} -result {.}
##############################################################################
test clipboard-4.1 {ClipboardLostSel procedure} -setup {
clipboard clear
} -body {
clipboard append "Test"
selection clear -s CLIPBOARD
clipboard get
} -cleanup {
clipboard clear
} -returnCodes error -result {CLIPBOARD selection doesn't exist or form "STRING" not defined}
test clipboard-4.2 {ClipboardLostSel procedure} -setup {
clipboard clear
} -body {
clipboard append "Test"
clipboard append -t TEST "Test2"
selection clear -s CLIPBOARD
clipboard get
} -cleanup {
clipboard clear
} -returnCodes error -result {CLIPBOARD selection doesn't exist or form "STRING" not defined}
test clipboard-4.3 {ClipboardLostSel procedure} -setup {
clipboard clear
} -body {
clipboard append "Test"
clipboard append -t TEST "Test2"
selection clear -s CLIPBOARD
clipboard get -t TEST
} -cleanup {
clipboard clear
} -returnCodes error -result {CLIPBOARD selection doesn't exist or form "TEST" not defined}
test clipboard-4.4 {ClipboardLostSel procedure} -setup {
clipboard clear
} -body {
clipboard append "Test"
clipboard append -t TEST "Test2"
clipboard append "Test3"
selection clear -s CLIPBOARD
clipboard get
} -cleanup {
clipboard clear
} -returnCodes error -result {CLIPBOARD selection doesn't exist or form "STRING" not defined}
test clipboard-4.5 {ClipboardLostSel procedure} -setup {
clipboard clear
} -body {
clipboard append "Test"
clipboard append -t TEST "Test2"
clipboard append "Test3"
selection clear -s CLIPBOARD
clipboard get -t TEST
} -cleanup {
clipboard clear
} -returnCodes error -result {CLIPBOARD selection doesn't exist or form "TEST" not defined}
##############################################################################
test clipboard-5.1 {Tk_ClipboardClear procedure} -setup {
clipboard clear
} -body {
clipboard append -t TEST "test"
set result [lsort [clipboard get TARGETS]]
clipboard clear
list $result [lsort [clipboard get TARGETS]]
} -cleanup {
clipboard clear
} -result {{MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}}
test clipboard-5.2 {Tk_ClipboardClear procedure} -setup {
clipboard clear
} -body {
clipboard append -t TEST "test"
set result [lsort [clipboard get TARGETS]]
selection own -s CLIPBOARD .
lappend result [lsort [clipboard get TARGETS]]
clipboard clear
clipboard append -t TEST "test"
lappend result [lsort [clipboard get TARGETS]]
} -cleanup {
clipboard clear
} -result {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}}
##############################################################################
test clipboard-6.1 {Tk_ClipboardAppend procedure} -setup {
clipboard clear
} -body {
clipboard append "first chunk"
selection own -s CLIPBOARD .
clipboard append " second chunk"
clipboard get
} -cleanup {
clipboard clear
} -returnCodes ok -result {first chunk second chunk}
test clipboard-6.2 {Tk_ClipboardAppend procedure} -constraints x11 -setup {
clipboard clear
} -body {
setupbg
clipboard append -f INTEGER -t TEST "16"
set result [dobg {clipboard get TEST}]
return $result
} -cleanup {
clipboard clear
cleanupbg
} -result {0x10 }
test clipboard-6.3 {Tk_ClipboardAppend procedure} -setup {
clipboard clear
} -body {
clipboard append -f INTEGER -t TEST "16"
clipboard append -t TEST "test"
} -cleanup {
clipboard clear
} -returnCodes error -result {format "STRING" does not match current format "INTEGER" for TEST}
##############################################################################
test clipboard-7.1 {Tk_ClipboardCmd procedure} -body {
clipboard
} -returnCodes error -result {wrong # args: should be "clipboard option ?arg ...?"}
test clipboard-7.2 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append --
} -cleanup {
clipboard clear
} -returnCodes ok -result {}
test clipboard-7.3 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append --
selection get -selection CLIPBOARD
} -cleanup {
clipboard clear
} -result {--}
test clipboard-7.4 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append -- information
selection get -selection CLIPBOARD
} -cleanup {
clipboard clear
} -result {information}
test clipboard-7.5 {Tk_ClipboardCmd procedure} -body {
clipboard append --x a b
} -returnCodes error -result {bad option "--x": must be -displayof, -format, or -type}
test clipboard-7.6 {Tk_ClipboardCmd procedure} -body {
clipboard append -- a b
} -returnCodes error -result {wrong # args: should be "clipboard append ?-option value ...? data"}
test clipboard-7.7 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append -format
} -returnCodes ok -result {}
test clipboard-7.8 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append -format
selection get -selection CLIPBOARD
} -cleanup {
clipboard clear
} -result {-format}
test clipboard-7.9 {Tk_ClipboardCmd procedure} -body {
clipboard append -displayofoo f
} -returnCodes error -result {bad option "-displayofoo": must be -displayof, -format, or -type}
test clipboard-7.10 {Tk_ClipboardCmd procedure} -body {
clipboard append -type TEST
} -returnCodes error -result {wrong # args: should be "clipboard append ?-option value ...? data"}
test clipboard-7.11 {Tk_ClipboardCmd procedure} -body {
clipboard append -displayof foo "test"
} -returnCodes error -result {bad window path name "foo"}
test clipboard-7.12 {Tk_ClipboardCmd procedure} -body {
clipboard clear -displayof
} -returnCodes error -result {wrong # args: should be "clipboard clear ?-displayof window?"}
test clipboard-7.13 {Tk_ClipboardCmd procedure} -body {
clipboard clear -displayofoo f
} -returnCodes error -result {bad option "-displayofoo": must be -displayof}
test clipboard-7.14 {Tk_ClipboardCmd procedure} -body {
clipboard clear foo
} -returnCodes error -result {wrong # args: should be "clipboard clear ?-displayof window?"}
test clipboard-7.15 {Tk_ClipboardCmd procedure} -body {
clipboard clear -displayof foo
} -returnCodes error -result {bad window path name "foo"}
test clipboard-7.16 {Tk_ClipboardCmd procedure} -body {
clipboard error
} -returnCodes error -result {bad option "error": must be append, clear, or get}
test clipboard-7.17 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append -displayof
} -cleanup {
clipboard clear
} -returnCodes ok -result {}
test clipboard-7.18 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append -displayof
selection get -selection CLIPBOARD
} -cleanup {
clipboard clear
} -result {-displayof}
test clipboard-7.19 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append -type
} -cleanup {
clipboard clear
} -returnCodes ok -result {}
test clipboard-7.20 {Tk_ClipboardCmd procedure} -setup {
clipboard clear
} -body {
clipboard append -type
selection get -selection CLIPBOARD
} -cleanup {
clipboard clear
} -result {-type}
# cleanup
cleanupTests
return
# Local Variables:
# mode: tcl
# End:
|