1 |
578 |
markom |
# This file is a Tcl script to test out Tk's selection management code,
|
2 |
|
|
# especially the "selection" command. It is organized in the standard
|
3 |
|
|
# fashion for Tcl tests.
|
4 |
|
|
#
|
5 |
|
|
# Copyright (c) 1994 Sun Microsystems, Inc.
|
6 |
|
|
#
|
7 |
|
|
# See the file "license.terms" for information on usage and redistribution
|
8 |
|
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
9 |
|
|
#
|
10 |
|
|
# RCS: @(#) $Id: select.test,v 1.1.1.1 2002-01-16 10:25:59 markom Exp $
|
11 |
|
|
|
12 |
|
|
#
|
13 |
|
|
# Note: Multiple display selection handling will only be tested if the
|
14 |
|
|
# environment variable TK_ALT_DISPLAY is set to an alternate display.
|
15 |
|
|
#
|
16 |
|
|
|
17 |
|
|
if {[string compare test [info procs test]] == 1} {
|
18 |
|
|
source defs
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
eval destroy [winfo child .]
|
22 |
|
|
|
23 |
|
|
global longValue selValue selInfo
|
24 |
|
|
|
25 |
|
|
set selValue {}
|
26 |
|
|
set selInfo {}
|
27 |
|
|
|
28 |
|
|
proc handler {type offset count} {
|
29 |
|
|
global selValue selInfo
|
30 |
|
|
lappend selInfo $type $offset $count
|
31 |
|
|
set numBytes [expr {[string length $selValue] - $offset}]
|
32 |
|
|
if {$numBytes <= 0} {
|
33 |
|
|
return ""
|
34 |
|
|
}
|
35 |
|
|
string range $selValue $offset [expr $numBytes+$offset]
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
proc errIncrHandler {type offset count} {
|
39 |
|
|
global selValue selInfo pass
|
40 |
|
|
if {$offset == 4000} {
|
41 |
|
|
if {$pass == 0} {
|
42 |
|
|
# Just sizing the selection; don't do anything here.
|
43 |
|
|
set pass 1
|
44 |
|
|
} else {
|
45 |
|
|
# Fetching the selection; wait long enough to cause a timeout.
|
46 |
|
|
after 6000
|
47 |
|
|
}
|
48 |
|
|
}
|
49 |
|
|
lappend selInfo $type $offset $count
|
50 |
|
|
set numBytes [expr {[string length $selValue] - $offset}]
|
51 |
|
|
if {$numBytes <= 0} {
|
52 |
|
|
return ""
|
53 |
|
|
}
|
54 |
|
|
string range $selValue $offset [expr $numBytes+$offset]
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
proc errHandler args {
|
58 |
|
|
error "selection handler aborted"
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
proc badHandler {path type offset count} {
|
62 |
|
|
global selValue selInfo
|
63 |
|
|
selection handle -type $type $path {}
|
64 |
|
|
lappend selInfo $path $type $offset $count
|
65 |
|
|
set numBytes [expr {[string length $selValue] - $offset}]
|
66 |
|
|
if {$numBytes <= 0} {
|
67 |
|
|
return ""
|
68 |
|
|
}
|
69 |
|
|
string range $selValue $offset [expr $numBytes+$offset]
|
70 |
|
|
}
|
71 |
|
|
proc reallyBadHandler {path type offset count} {
|
72 |
|
|
global selValue selInfo pass
|
73 |
|
|
if {$offset == 4000} {
|
74 |
|
|
if {$pass == 0} {
|
75 |
|
|
set pass 1
|
76 |
|
|
} else {
|
77 |
|
|
selection handle -type $type $path {}
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
lappend selInfo $path $type $offset $count
|
81 |
|
|
set numBytes [expr {[string length $selValue] - $offset}]
|
82 |
|
|
if {$numBytes <= 0} {
|
83 |
|
|
return ""
|
84 |
|
|
}
|
85 |
|
|
string range $selValue $offset [expr $numBytes+$offset]
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
# Eliminate any existing selection on the screen. This is needed in case
|
89 |
|
|
# there is a selection in some other application, in order to prevent races
|
90 |
|
|
# from causing false errors in the tests below.
|
91 |
|
|
|
92 |
|
|
selection clear .
|
93 |
|
|
after 1500
|
94 |
|
|
|
95 |
|
|
# common setup code
|
96 |
|
|
proc setup {{path .f1} {display {}}} {
|
97 |
|
|
catch {destroy $path}
|
98 |
|
|
if {$display == {}} {
|
99 |
|
|
frame $path
|
100 |
|
|
} else {
|
101 |
|
|
toplevel $path -screen $display
|
102 |
|
|
wm geom $path +0+0
|
103 |
|
|
}
|
104 |
|
|
selection own $path
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
# set up a very large buffer to test INCR retrievals
|
108 |
|
|
set longValue ""
|
109 |
|
|
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} {
|
110 |
|
|
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
|
111 |
|
|
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
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
# Now we start the main body of the test code
|
115 |
|
|
|
116 |
|
|
test select-1.1 {Tk_CreateSelHandler procedure} {
|
117 |
|
|
setup
|
118 |
|
|
lsort [selection get TARGETS]
|
119 |
|
|
} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}
|
120 |
|
|
test select-1.2 {Tk_CreateSelHandler procedure} {
|
121 |
|
|
setup
|
122 |
|
|
selection handle .f1 {handler TEST} TEST
|
123 |
|
|
lsort [selection get TARGETS]
|
124 |
|
|
} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}
|
125 |
|
|
test select-1.3 {Tk_CreateSelHandler procedure} {
|
126 |
|
|
global selValue selInfo
|
127 |
|
|
setup
|
128 |
|
|
selection handle .f1 {handler TEST} TEST
|
129 |
|
|
set selValue "Test value"
|
130 |
|
|
set selInfo ""
|
131 |
|
|
list [selection get TEST] $selInfo
|
132 |
|
|
} {{Test value} {TEST 0 4000}}
|
133 |
|
|
test select-1.4 {Tk_CreateSelHandler procedure} {
|
134 |
|
|
setup
|
135 |
|
|
selection handle .f1 {handler TEST} TEST
|
136 |
|
|
selection handle .f1 {handler STRING}
|
137 |
|
|
lsort [selection get TARGETS]
|
138 |
|
|
} {MULTIPLE STRING TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}
|
139 |
|
|
test select-1.5 {Tk_CreateSelHandler procedure} {
|
140 |
|
|
global selValue selInfo
|
141 |
|
|
setup
|
142 |
|
|
selection handle .f1 {handler TEST} TEST
|
143 |
|
|
selection handle .f1 {handler STRING}
|
144 |
|
|
set selValue ""
|
145 |
|
|
set selInfo ""
|
146 |
|
|
list [selection get] $selInfo
|
147 |
|
|
} {{} {STRING 0 4000}}
|
148 |
|
|
test select-1.6 {Tk_CreateSelHandler procedure} {
|
149 |
|
|
global selValue selInfo
|
150 |
|
|
setup
|
151 |
|
|
selection handle .f1 {handler TEST} TEST
|
152 |
|
|
selection handle .f1 {handler STRING}
|
153 |
|
|
set selValue ""
|
154 |
|
|
set selInfo ""
|
155 |
|
|
selection get
|
156 |
|
|
selection get -type TEST
|
157 |
|
|
selection handle .f1 {handler TEST2} TEST
|
158 |
|
|
selection get -type TEST
|
159 |
|
|
list [set selInfo] [lsort [selection get TARGETS]]
|
160 |
|
|
} {{STRING 0 4000 TEST 0 4000 TEST2 0 4000} {MULTIPLE STRING TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}}
|
161 |
|
|
test select-1.7 {Tk_CreateSelHandler procedure} {
|
162 |
|
|
setup
|
163 |
|
|
selection own -selection CLIPBOARD .f1
|
164 |
|
|
selection handle -selection CLIPBOARD .f1 {handler TEST} TEST
|
165 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST2} STRING
|
166 |
|
|
list [lsort [selection get -selection PRIMARY TARGETS]] \
|
167 |
|
|
[lsort [selection get -selection CLIPBOARD TARGETS]]
|
168 |
|
|
} {{MULTIPLE STRING TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}}
|
169 |
|
|
test select-1.8 {Tk_CreateSelHandler procedure} {
|
170 |
|
|
setup
|
171 |
|
|
selection handle -format INTEGER -type TEST .f1 {handler TEST}
|
172 |
|
|
lsort [selection get TARGETS]
|
173 |
|
|
} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}
|
174 |
|
|
|
175 |
|
|
##############################################################################
|
176 |
|
|
|
177 |
|
|
test select-2.1 {Tk_DeleteSelHandler procedure} {
|
178 |
|
|
setup
|
179 |
|
|
selection handle .f1 {handler STRING}
|
180 |
|
|
selection handle -type TEST .f1 {handler TEST}
|
181 |
|
|
selection handle -type USER .f1 {handler USER}
|
182 |
|
|
set result [list [lsort [selection get TARGETS]]]
|
183 |
|
|
selection handle -type TEST .f1 {}
|
184 |
|
|
lappend result [lsort [selection get TARGETS]]
|
185 |
|
|
} {{MULTIPLE STRING TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW USER} {MULTIPLE STRING TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW USER}}
|
186 |
|
|
test select-2.2 {Tk_DeleteSelHandler procedure} {
|
187 |
|
|
setup
|
188 |
|
|
selection handle .f1 {handler STRING}
|
189 |
|
|
selection handle -type TEST .f1 {handler TEST}
|
190 |
|
|
selection handle -type USER .f1 {handler USER}
|
191 |
|
|
set result [list [lsort [selection get TARGETS]]]
|
192 |
|
|
selection handle -type USER .f1 {}
|
193 |
|
|
lappend result [lsort [selection get TARGETS]]
|
194 |
|
|
} {{MULTIPLE STRING TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW USER} {MULTIPLE STRING TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}}
|
195 |
|
|
test select-2.3 {Tk_DeleteSelHandler procedure} {
|
196 |
|
|
setup
|
197 |
|
|
selection own -selection CLIPBOARD .f1
|
198 |
|
|
selection handle -selection PRIMARY .f1 {handler STRING}
|
199 |
|
|
selection handle -selection CLIPBOARD .f1 {handler STRING}
|
200 |
|
|
selection handle -selection CLIPBOARD .f1 {}
|
201 |
|
|
list [lsort [selection get TARGETS]] \
|
202 |
|
|
[lsort [selection get -selection CLIPBOARD TARGETS]]
|
203 |
|
|
} {{MULTIPLE STRING TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}}
|
204 |
|
|
test select-2.4 {Tk_DeleteSelHandler procedure} {
|
205 |
|
|
setup
|
206 |
|
|
selection handle .f1 {handler STRING}
|
207 |
|
|
list [selection handle .f1 {}] [selection handle .f1 {}]
|
208 |
|
|
} {{} {}}
|
209 |
|
|
|
210 |
|
|
##############################################################################
|
211 |
|
|
|
212 |
|
|
test select-3.1 {Tk_OwnSelection procedure} {
|
213 |
|
|
setup
|
214 |
|
|
selection own
|
215 |
|
|
} {.f1}
|
216 |
|
|
test select-3.2 {Tk_OwnSelection procedure} {
|
217 |
|
|
setup .f1
|
218 |
|
|
set result [selection own]
|
219 |
|
|
setup .f2
|
220 |
|
|
lappend result [selection own]
|
221 |
|
|
} {.f1 .f2}
|
222 |
|
|
test select-3.3 {Tk_OwnSelection procedure} {
|
223 |
|
|
setup .f1
|
224 |
|
|
setup .f2
|
225 |
|
|
selection own -selection CLIPBOARD .f1
|
226 |
|
|
list [selection own] [selection own -selection CLIPBOARD]
|
227 |
|
|
} {.f2 .f1}
|
228 |
|
|
test select-3.4 {Tk_OwnSelection procedure} {
|
229 |
|
|
global lostSel
|
230 |
|
|
setup
|
231 |
|
|
set lostSel {owned}
|
232 |
|
|
selection own -command { set lostSel {lost} } .f1
|
233 |
|
|
selection clear .f1
|
234 |
|
|
set lostSel
|
235 |
|
|
} {lost}
|
236 |
|
|
test select-3.5 {Tk_OwnSelection procedure} {
|
237 |
|
|
global lostSel
|
238 |
|
|
setup .f1
|
239 |
|
|
setup .f2
|
240 |
|
|
set lostSel {owned}
|
241 |
|
|
selection own -command { set lostSel {lost1} } .f1
|
242 |
|
|
selection own -command { set lostSel {lost2} } .f2
|
243 |
|
|
list $lostSel [selection own]
|
244 |
|
|
} {lost1 .f2}
|
245 |
|
|
test select-3.6 {Tk_OwnSelection procedure} {
|
246 |
|
|
global lostSel
|
247 |
|
|
setup
|
248 |
|
|
set lostSel {owned}
|
249 |
|
|
selection own -command { set lostSel {lost1} } .f1
|
250 |
|
|
selection own -command { set lostSel {lost2} } .f1
|
251 |
|
|
set result $lostSel
|
252 |
|
|
selection clear .f1
|
253 |
|
|
lappend result $lostSel
|
254 |
|
|
} {owned lost2}
|
255 |
|
|
test select-3.7 {Tk_OwnSelection procedure} {unixOnly} {
|
256 |
|
|
global lostSel
|
257 |
|
|
setup
|
258 |
|
|
setupbg
|
259 |
|
|
set lostSel {owned}
|
260 |
|
|
selection own -command { set lostSel {lost1} } .f1
|
261 |
|
|
update
|
262 |
|
|
set result {}
|
263 |
|
|
lappend result [dobg { selection own . }]
|
264 |
|
|
lappend result [dobg {selection own}]
|
265 |
|
|
update
|
266 |
|
|
cleanupbg
|
267 |
|
|
lappend result $lostSel
|
268 |
|
|
} {{} . lost1}
|
269 |
|
|
# check reentrancy on selection replacement
|
270 |
|
|
test select-3.8 {Tk_OwnSelection procedure} {
|
271 |
|
|
setup
|
272 |
|
|
selection own -selection CLIPBOARD -command { destroy .f1 } .f1
|
273 |
|
|
selection own -selection CLIPBOARD .
|
274 |
|
|
} {}
|
275 |
|
|
test select-3.9 {Tk_OwnSelection procedure} {
|
276 |
|
|
setup .f2
|
277 |
|
|
setup .f1
|
278 |
|
|
selection own -selection CLIPBOARD -command { destroy .f2 } .f1
|
279 |
|
|
selection own -selection CLIPBOARD .f2
|
280 |
|
|
} {}
|
281 |
|
|
|
282 |
|
|
# multiple display tests
|
283 |
|
|
if {[info exists env(TK_ALT_DISPLAY)]} {
|
284 |
|
|
|
285 |
|
|
test select-3.10 {Tk_OwnSelection procedure} {
|
286 |
|
|
setup .f1
|
287 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
288 |
|
|
list [selection own -displayof .f1] [selection own -displayof .f2]
|
289 |
|
|
} {.f1 .f2}
|
290 |
|
|
test select-3.11 {Tk_OwnSelection procedure} {
|
291 |
|
|
setup .f1
|
292 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
293 |
|
|
setupbg
|
294 |
|
|
update
|
295 |
|
|
set result ""
|
296 |
|
|
lappend result [dobg "toplevel .t -screen $env(TK_ALT_DISPLAY); wm geom .t +0+0; selection own .t; update"]
|
297 |
|
|
lappend result [selection own -displayof .f1] \
|
298 |
|
|
[selection own -displayof .f2]
|
299 |
|
|
cleanupbg
|
300 |
|
|
set result
|
301 |
|
|
} {{} .f1 {}}
|
302 |
|
|
|
303 |
|
|
}
|
304 |
|
|
##############################################################################
|
305 |
|
|
|
306 |
|
|
test select-4.1 {Tk_ClearSelection procedure} {
|
307 |
|
|
setup
|
308 |
|
|
set result [selection own]
|
309 |
|
|
selection clear .f1
|
310 |
|
|
lappend result [selection own]
|
311 |
|
|
} {.f1 {}}
|
312 |
|
|
test select-4.2 {Tk_ClearSelection procedure} {
|
313 |
|
|
setup
|
314 |
|
|
selection own -selection CLIPBOARD .f1
|
315 |
|
|
selection clear .f1
|
316 |
|
|
selection own -selection CLIPBOARD
|
317 |
|
|
} {.f1}
|
318 |
|
|
test select-4.3 {Tk_ClearSelection procedure} {
|
319 |
|
|
setup
|
320 |
|
|
list [selection clear .f1] [selection clear .f1]
|
321 |
|
|
} {{} {}}
|
322 |
|
|
test select-4.4 {Tk_ClearSelection procedure} {unixOnly} {
|
323 |
|
|
global lostSel
|
324 |
|
|
setup
|
325 |
|
|
setupbg
|
326 |
|
|
set lostSel {owned}
|
327 |
|
|
selection own -command { set lostSel {lost1} } .f1
|
328 |
|
|
update
|
329 |
|
|
set result {}
|
330 |
|
|
lappend result [dobg {selection clear; update}]
|
331 |
|
|
update
|
332 |
|
|
cleanupbg
|
333 |
|
|
lappend result [selection own]
|
334 |
|
|
} {{} {}}
|
335 |
|
|
|
336 |
|
|
# multiple display tests
|
337 |
|
|
if {[info exists env(TK_ALT_DISPLAY)]} {
|
338 |
|
|
test select-4.5 {Tk_ClearSelection procedure} {
|
339 |
|
|
global lostSel lostSel2
|
340 |
|
|
setup .f1
|
341 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
342 |
|
|
set lostSel {owned}
|
343 |
|
|
set lostSel2 {owned2}
|
344 |
|
|
selection own -command { set lostSel {lost1} } .f1
|
345 |
|
|
selection own -command { set lostSel2 {lost2} } .f2
|
346 |
|
|
update
|
347 |
|
|
selection clear -displayof .f2
|
348 |
|
|
update
|
349 |
|
|
list $lostSel $lostSel2
|
350 |
|
|
} {owned lost2}
|
351 |
|
|
test select-4.6 {Tk_ClearSelection procedure} {unixOnly} {
|
352 |
|
|
setup .f1
|
353 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
354 |
|
|
setupbg
|
355 |
|
|
set lostSel {owned}
|
356 |
|
|
set lostSel2 {owned2}
|
357 |
|
|
selection own -command { set lostSel {lost1} } .f1
|
358 |
|
|
selection own -command { set lostSel2 {lost2} } .f2
|
359 |
|
|
update
|
360 |
|
|
set result ""
|
361 |
|
|
lappend result [dobg "toplevel .t -screen $env(TK_ALT_DISPLAY); wm geom .t +0+0; selection own .t; update"]
|
362 |
|
|
lappend result [selection own -displayof .f1] \
|
363 |
|
|
[selection own -displayof .f2] $lostSel $lostSel2
|
364 |
|
|
cleanupbg
|
365 |
|
|
set result
|
366 |
|
|
} {{} .f1 {} owned lost2}
|
367 |
|
|
|
368 |
|
|
}
|
369 |
|
|
##############################################################################
|
370 |
|
|
|
371 |
|
|
test select-5.1 {Tk_GetSelection procedure} {
|
372 |
|
|
setup
|
373 |
|
|
list [catch {selection get TEST} msg] $msg
|
374 |
|
|
} {1 {PRIMARY selection doesn't exist or form "TEST" not defined}}
|
375 |
|
|
test select-5.2 {Tk_GetSelection procedure} {
|
376 |
|
|
setup
|
377 |
|
|
selection get TK_WINDOW
|
378 |
|
|
} {.f1}
|
379 |
|
|
test select-5.3 {Tk_GetSelection procedure} {
|
380 |
|
|
setup
|
381 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST} TEST
|
382 |
|
|
set selValue "Test value"
|
383 |
|
|
set selInfo ""
|
384 |
|
|
list [selection get TEST] $selInfo
|
385 |
|
|
} {{Test value} {TEST 0 4000}}
|
386 |
|
|
test select-5.4 {Tk_GetSelection procedure} {
|
387 |
|
|
setup
|
388 |
|
|
selection handle .f1 ERROR errHandler
|
389 |
|
|
list [catch {selection get ERROR} msg] $msg
|
390 |
|
|
} {1 {PRIMARY selection doesn't exist or form "ERROR" not defined}}
|
391 |
|
|
test select-5.5 {Tk_GetSelection procedure} {
|
392 |
|
|
setup
|
393 |
|
|
set selValue $longValue
|
394 |
|
|
set selInfo ""
|
395 |
|
|
selection handle .f1 {handler STRING}
|
396 |
|
|
list [selection get] $selInfo
|
397 |
|
|
} "$longValue {STRING 0 4000 STRING 4000 4000 STRING 8000 4000 STRING 12000 4000 STRING 16000 4000}"
|
398 |
|
|
test select-5.6 {Tk_GetSelection procedure} {
|
399 |
|
|
proc weirdHandler {type offset count} {
|
400 |
|
|
selection handle .f1 {}
|
401 |
|
|
handler $type $offset $count
|
402 |
|
|
}
|
403 |
|
|
setup
|
404 |
|
|
set selValue $longValue
|
405 |
|
|
set selInfo ""
|
406 |
|
|
selection handle .f1 {weirdHandler STRING}
|
407 |
|
|
list [catch {selection get} msg] $msg
|
408 |
|
|
} {1 {PRIMARY selection doesn't exist or form "STRING" not defined}}
|
409 |
|
|
test select-5.7 {Tk_GetSelection procedure} {
|
410 |
|
|
proc weirdHandler {type offset count} {
|
411 |
|
|
destroy .f1
|
412 |
|
|
handler $type $offset $count
|
413 |
|
|
}
|
414 |
|
|
setup
|
415 |
|
|
set selValue "Test Value"
|
416 |
|
|
set selInfo ""
|
417 |
|
|
selection handle .f1 {weirdHandler STRING}
|
418 |
|
|
list [catch {selection get} msg] $msg
|
419 |
|
|
} {1 {PRIMARY selection doesn't exist or form "STRING" not defined}}
|
420 |
|
|
test select-5.8 {Tk_GetSelection procedure} {
|
421 |
|
|
proc weirdHandler {type offset count} {
|
422 |
|
|
selection clear
|
423 |
|
|
handler $type $offset $count
|
424 |
|
|
}
|
425 |
|
|
setup
|
426 |
|
|
set selValue $longValue
|
427 |
|
|
set selInfo ""
|
428 |
|
|
selection handle .f1 {weirdHandler STRING}
|
429 |
|
|
list [selection get] $selInfo [catch {selection get} msg] $msg
|
430 |
|
|
} "$longValue {STRING 0 4000 STRING 4000 4000 STRING 8000 4000 STRING 12000 4000 STRING 16000 4000} 1 {PRIMARY selection doesn't exist or form \"STRING\" not defined}"
|
431 |
|
|
test select-5.9 {Tk_GetSelection procedure} {unixOnly} {
|
432 |
|
|
setup
|
433 |
|
|
setupbg
|
434 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST} TEST
|
435 |
|
|
update
|
436 |
|
|
set selValue "Test value"
|
437 |
|
|
set selInfo ""
|
438 |
|
|
set result ""
|
439 |
|
|
lappend result [dobg {selection get TEST}]
|
440 |
|
|
cleanupbg
|
441 |
|
|
lappend result $selInfo
|
442 |
|
|
} {{Test value} {TEST 0 4000}}
|
443 |
|
|
test select-5.10 {Tk_GetSelection procedure} {unixOnly} {
|
444 |
|
|
setup
|
445 |
|
|
setupbg
|
446 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST} TEST
|
447 |
|
|
update
|
448 |
|
|
set selValue "Test value"
|
449 |
|
|
set selInfo ""
|
450 |
|
|
selection own .f1
|
451 |
|
|
set result ""
|
452 |
|
|
fileevent $fd readable {}
|
453 |
|
|
puts $fd {catch {selection get TEST} msg; update; puts $msg; flush stdout}
|
454 |
|
|
flush $fd
|
455 |
|
|
lappend result [gets $fd]
|
456 |
|
|
cleanupbg
|
457 |
|
|
lappend result $selInfo
|
458 |
|
|
} {{selection owner didn't respond} {}}
|
459 |
|
|
|
460 |
|
|
# multiple display tests
|
461 |
|
|
if {[info exists env(TK_ALT_DISPLAY)]} {
|
462 |
|
|
test select-5.11 {Tk_GetSelection procedure} {
|
463 |
|
|
setup .f1
|
464 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
465 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST} TEST
|
466 |
|
|
selection handle -selection PRIMARY .f2 {handler TEST2} TEST
|
467 |
|
|
set selValue "Test value"
|
468 |
|
|
set selInfo ""
|
469 |
|
|
set result [list [selection get TEST] $selInfo]
|
470 |
|
|
set selValue "Test value2"
|
471 |
|
|
set selInfo ""
|
472 |
|
|
lappend result [selection get -displayof .f2 TEST] $selInfo
|
473 |
|
|
} {{Test value} {TEST 0 4000} {Test value2} {TEST2 0 4000}}
|
474 |
|
|
test select-5.12 {Tk_GetSelection procedure} {
|
475 |
|
|
global lostSel lostSel2
|
476 |
|
|
setup .f1
|
477 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
478 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST} TEST
|
479 |
|
|
selection handle -selection PRIMARY .f2 {} TEST
|
480 |
|
|
set selValue "Test value"
|
481 |
|
|
set selInfo ""
|
482 |
|
|
set result [list [catch {selection get TEST} msg] $msg $selInfo]
|
483 |
|
|
set selValue "Test value2"
|
484 |
|
|
set selInfo ""
|
485 |
|
|
lappend result [catch {selection get -displayof .f2 TEST} msg] $msg \
|
486 |
|
|
$selInfo
|
487 |
|
|
} {0 {Test value} {TEST 0 4000} 1 {PRIMARY selection doesn't exist or form "TEST" not defined} {}}
|
488 |
|
|
test select-5.13 {Tk_GetSelection procedure} {unixOnly} {
|
489 |
|
|
setup .f1
|
490 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
491 |
|
|
setupbg
|
492 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST} TEST
|
493 |
|
|
selection own .f1
|
494 |
|
|
selection handle -selection PRIMARY .f2 {handler TEST2} TEST
|
495 |
|
|
selection own .f2
|
496 |
|
|
set selValue "Test value"
|
497 |
|
|
set selInfo ""
|
498 |
|
|
update
|
499 |
|
|
set result ""
|
500 |
|
|
lappend result [dobg "toplevel .t -screen $env(TK_ALT_DISPLAY); wm geom .t +0+0; selection get -displayof .t TEST"]
|
501 |
|
|
set selValue "Test value2"
|
502 |
|
|
lappend result [dobg "selection get TEST"]
|
503 |
|
|
cleanupbg
|
504 |
|
|
lappend result $selInfo
|
505 |
|
|
} {{Test value} {Test value2} {TEST2 0 4000 TEST 0 4000}}
|
506 |
|
|
test select-5.14 {Tk_GetSelection procedure} {unixOnly} {
|
507 |
|
|
setup .f1
|
508 |
|
|
setup .f2 $env(TK_ALT_DISPLAY)
|
509 |
|
|
setupbg
|
510 |
|
|
selection handle -selection PRIMARY .f1 {handler TEST} TEST
|
511 |
|
|
selection own .f1
|
512 |
|
|
selection handle -selection PRIMARY .f2 {} TEST
|
513 |
|
|
selection own .f2
|
514 |
|
|
set selValue "Test value"
|
515 |
|
|
set selInfo ""
|
516 |
|
|
update
|
517 |
|
|
set result ""
|
518 |
|
|
lappend result [dobg "toplevel .t -screen $env(TK_ALT_DISPLAY); wm geom .t +0+0; selection get -displayof .t TEST"]
|
519 |
|
|
set selValue "Test value2"
|
520 |
|
|
lappend result [dobg "selection get TEST"]
|
521 |
|
|
cleanupbg
|
522 |
|
|
lappend result $selInfo
|
523 |
|
|
} {{PRIMARY selection doesn't exist or form "TEST" not defined} {Test value2} {TEST 0 4000}}
|
524 |
|
|
|
525 |
|
|
}
|
526 |
|
|
##############################################################################
|
527 |
|
|
|
528 |
|
|
test select-6.1 {Tk_SelectionCmd procedure} {
|
529 |
|
|
list [catch {selection} cmd] $cmd
|
530 |
|
|
} {1 {wrong # args: should be "selection option ?arg arg ...?"}}
|
531 |
|
|
|
532 |
|
|
# selection clear
|
533 |
|
|
test select-6.2 {Tk_SelectionCmd procedure} {
|
534 |
|
|
list [catch {selection clear -selection} cmd] $cmd
|
535 |
|
|
} {1 {value for "-selection" missing}}
|
536 |
|
|
test select-6.3 {Tk_SelectionCmd procedure} {
|
537 |
|
|
setup
|
538 |
|
|
selection own .
|
539 |
|
|
set result [selection own]
|
540 |
|
|
selection clear -displayof .f1
|
541 |
|
|
lappend result [selection own]
|
542 |
|
|
} {. {}}
|
543 |
|
|
test select-6.4 {Tk_SelectionCmd procedure} {
|
544 |
|
|
setup
|
545 |
|
|
selection own -selection CLIPBOARD .f1
|
546 |
|
|
set result [list [selection own] [selection own -selection CLIPBOARD]]
|
547 |
|
|
selection clear -selection CLIPBOARD .f1
|
548 |
|
|
lappend result [selection own] [selection own -selection CLIPBOARD]
|
549 |
|
|
} {.f1 .f1 .f1 {}}
|
550 |
|
|
test select-6.5 {Tk_SelectionCmd procedure} {
|
551 |
|
|
setup
|
552 |
|
|
selection own -selection CLIPBOARD .
|
553 |
|
|
set result [list [selection own] [selection own -selection CLIPBOARD]]
|
554 |
|
|
selection clear -selection CLIPBOARD -displayof .f1
|
555 |
|
|
lappend result [selection own] [selection own -selection CLIPBOARD]
|
556 |
|
|
} {.f1 . .f1 {}}
|
557 |
|
|
test select-6.6 {Tk_SelectionCmd procedure} {
|
558 |
|
|
list [catch {selection clear -badopt foo} cmd] $cmd
|
559 |
|
|
} {1 {unknown option "-badopt"}}
|
560 |
|
|
test select-6.7 {Tk_SelectionCmd procedure} {
|
561 |
|
|
list [catch {selection clear -selectionfoo foo} cmd] $cmd
|
562 |
|
|
} {1 {unknown option "-selectionfoo"}}
|
563 |
|
|
test select-6.8 {Tk_SelectionCmd procedure} {
|
564 |
|
|
catch {destroy .f2}
|
565 |
|
|
list [catch {selection clear -displayof .f2} cmd] $cmd
|
566 |
|
|
} {1 {bad window path name ".f2"}}
|
567 |
|
|
test select-6.9 {Tk_SelectionCmd procedure} {
|
568 |
|
|
catch {destroy .f2}
|
569 |
|
|
list [catch {selection clear .f2} cmd] $cmd
|
570 |
|
|
} {1 {bad window path name ".f2"}}
|
571 |
|
|
test select-6.10 {Tk_SelectionCmd procedure} {
|
572 |
|
|
setup
|
573 |
|
|
set result [selection own -selection PRIMARY]
|
574 |
|
|
selection clear
|
575 |
|
|
lappend result [selection own -selection PRIMARY]
|
576 |
|
|
} {.f1 {}}
|
577 |
|
|
test select-6.11 {Tk_SelectionCmd procedure} {
|
578 |
|
|
setup
|
579 |
|
|
selection own -selection CLIPBOARD .f1
|
580 |
|
|
set result [selection own -selection CLIPBOARD]
|
581 |
|
|
selection clear -selection CLIPBOARD
|
582 |
|
|
lappend result [selection own -selection CLIPBOARD]
|
583 |
|
|
} {.f1 {}}
|
584 |
|
|
test select-6.12 {Tk_SelectionCmd procedure} {
|
585 |
|
|
list [catch {selection clear foo bar} cmd] $cmd
|
586 |
|
|
} {1 {wrong # args: should be "selection clear ?options?"}}
|
587 |
|
|
|
588 |
|
|
# selection get
|
589 |
|
|
test select-6.13 {Tk_SelectionCmd procedure} {
|
590 |
|
|
list [catch {selection get -selection} cmd] $cmd
|
591 |
|
|
} {1 {value for "-selection" missing}}
|
592 |
|
|
test select-6.14 {Tk_SelectionCmd procedure} {
|
593 |
|
|
global selValue selInfo
|
594 |
|
|
setup
|
595 |
|
|
selection handle .f1 {handler TEST}
|
596 |
|
|
set selValue "Test value"
|
597 |
|
|
set selInfo ""
|
598 |
|
|
list [selection get -displayof .f1] $selInfo
|
599 |
|
|
} {{Test value} {TEST 0 4000}}
|
600 |
|
|
test select-6.15 {Tk_SelectionCmd procedure} {
|
601 |
|
|
global selValue selInfo
|
602 |
|
|
setup
|
603 |
|
|
selection handle .f1 {handler STRING}
|
604 |
|
|
selection handle -selection CLIPBOARD .f1 {handler TEST}
|
605 |
|
|
selection own -selection CLIPBOARD .f1
|
606 |
|
|
set selValue "Test value"
|
607 |
|
|
set selInfo ""
|
608 |
|
|
list [selection get -selection CLIPBOARD] $selInfo
|
609 |
|
|
} {{Test value} {TEST 0 4000}}
|
610 |
|
|
test select-6.16 {Tk_SelectionCmd procedure} {
|
611 |
|
|
global selValue selInfo
|
612 |
|
|
setup
|
613 |
|
|
selection handle -type TEST .f1 {handler TEST}
|
614 |
|
|
selection handle -type STRING .f1 {handler STRING}
|
615 |
|
|
set selValue "Test value"
|
616 |
|
|
set selInfo ""
|
617 |
|
|
list [selection get -type TEST] $selInfo
|
618 |
|
|
} {{Test value} {TEST 0 4000}}
|
619 |
|
|
test select-6.17 {Tk_SelectionCmd procedure} {
|
620 |
|
|
list [catch {selection get -badopt foo} cmd] $cmd
|
621 |
|
|
} {1 {unknown option "-badopt"}}
|
622 |
|
|
test select-6.18 {Tk_SelectionCmd procedure} {
|
623 |
|
|
list [catch {selection get -selectionfoo foo} cmd] $cmd
|
624 |
|
|
} {1 {unknown option "-selectionfoo"}}
|
625 |
|
|
test select-6.19 {Tk_SelectionCmd procedure} {
|
626 |
|
|
catch { destroy .f2 }
|
627 |
|
|
list [catch {selection get -displayof .f2} cmd] $cmd
|
628 |
|
|
} {1 {bad window path name ".f2"}}
|
629 |
|
|
test select-6.20 {Tk_SelectionCmd procedure} {
|
630 |
|
|
list [catch {selection get foo bar} cmd] $cmd
|
631 |
|
|
} {1 {wrong # args: should be "selection get ?options?"}}
|
632 |
|
|
test select-6.21 {Tk_SelectionCmd procedure} {
|
633 |
|
|
global selValue selInfo
|
634 |
|
|
setup
|
635 |
|
|
selection handle -type TEST .f1 {handler TEST}
|
636 |
|
|
selection handle -type STRING .f1 {handler STRING}
|
637 |
|
|
set selValue "Test value"
|
638 |
|
|
set selInfo ""
|
639 |
|
|
list [selection get TEST] $selInfo
|
640 |
|
|
} {{Test value} {TEST 0 4000}}
|
641 |
|
|
|
642 |
|
|
# selection handle
|
643 |
|
|
# most of the handle section has been covered earlier
|
644 |
|
|
test select-6.22 {Tk_SelectionCmd procedure} {
|
645 |
|
|
list [catch {selection handle -selection} cmd] $cmd
|
646 |
|
|
} {1 {value for "-selection" missing}}
|
647 |
|
|
test select-6.23 {Tk_SelectionCmd procedure} {
|
648 |
|
|
global selValue selInfo
|
649 |
|
|
setup
|
650 |
|
|
set selValue "Test value"
|
651 |
|
|
set selInfo ""
|
652 |
|
|
list [selection handle -format INTEGER .f1 {handler TEST}] [selection get -displayof .f1] $selInfo
|
653 |
|
|
} {{} {Test value} {TEST 0 4000}}
|
654 |
|
|
test select-6.24 {Tk_SelectionCmd procedure} {
|
655 |
|
|
list [catch {selection handle -badopt foo} cmd] $cmd
|
656 |
|
|
} {1 {unknown option "-badopt"}}
|
657 |
|
|
test select-6.25 {Tk_SelectionCmd procedure} {
|
658 |
|
|
list [catch {selection handle -selectionfoo foo} cmd] $cmd
|
659 |
|
|
} {1 {unknown option "-selectionfoo"}}
|
660 |
|
|
test select-6.26 {Tk_SelectionCmd procedure} {
|
661 |
|
|
list [catch {selection handle} cmd] $cmd
|
662 |
|
|
} {1 {wrong # args: should be "selection handle ?options? window command"}}
|
663 |
|
|
test select-6.27 {Tk_SelectionCmd procedure} {
|
664 |
|
|
list [catch {selection handle .} cmd] $cmd
|
665 |
|
|
} {1 {wrong # args: should be "selection handle ?options? window command"}}
|
666 |
|
|
test select-6.28 {Tk_SelectionCmd procedure} {
|
667 |
|
|
list [catch {selection handle . foo bar baz blat} cmd] $cmd
|
668 |
|
|
} {1 {wrong # args: should be "selection handle ?options? window command"}}
|
669 |
|
|
test select-6.29 {Tk_SelectionCmd procedure} {
|
670 |
|
|
catch { destroy .f2 }
|
671 |
|
|
list [catch {selection handle .f2 dummy} cmd] $cmd
|
672 |
|
|
} {1 {bad window path name ".f2"}}
|
673 |
|
|
|
674 |
|
|
# selection own
|
675 |
|
|
test select-6.30 {Tk_SelectionCmd procedure} {
|
676 |
|
|
list [catch {selection own -selection} cmd] $cmd
|
677 |
|
|
} {1 {value for "-selection" missing}}
|
678 |
|
|
test select-6.31 {Tk_SelectionCmd procedure} {
|
679 |
|
|
setup
|
680 |
|
|
selection own .
|
681 |
|
|
selection own -displayof .f1
|
682 |
|
|
} {.}
|
683 |
|
|
test select-6.32 {Tk_SelectionCmd procedure} {
|
684 |
|
|
setup
|
685 |
|
|
selection own .
|
686 |
|
|
selection own -selection CLIPBOARD .f1
|
687 |
|
|
list [selection own] [selection own -selection CLIPBOARD]
|
688 |
|
|
} {. .f1}
|
689 |
|
|
test select-6.33 {Tk_SelectionCmd procedure} {
|
690 |
|
|
global lostSel
|
691 |
|
|
setup
|
692 |
|
|
set lostSel owned
|
693 |
|
|
selection own -command { set lostSel lost } .
|
694 |
|
|
selection own -selection CLIPBOARD .f1
|
695 |
|
|
set result $lostSel
|
696 |
|
|
selection own .f1
|
697 |
|
|
lappend result $lostSel
|
698 |
|
|
} {owned lost}
|
699 |
|
|
test select-6.34 {Tk_SelectionCmd procedure} {
|
700 |
|
|
list [catch {selection own -badopt foo} cmd] $cmd
|
701 |
|
|
} {1 {unknown option "-badopt"}}
|
702 |
|
|
test select-6.35 {Tk_SelectionCmd procedure} {
|
703 |
|
|
list [catch {selection own -selectionfoo foo} cmd] $cmd
|
704 |
|
|
} {1 {unknown option "-selectionfoo"}}
|
705 |
|
|
test select-6.36 {Tk_SelectionCmd procedure} {
|
706 |
|
|
catch {destroy .f2}
|
707 |
|
|
list [catch {selection own -displayof .f2} cmd] $cmd
|
708 |
|
|
} {1 {bad window path name ".f2"}}
|
709 |
|
|
test select-6.37 {Tk_SelectionCmd procedure} {
|
710 |
|
|
catch {destroy .f2}
|
711 |
|
|
list [catch {selection own .f2} cmd] $cmd
|
712 |
|
|
} {1 {bad window path name ".f2"}}
|
713 |
|
|
test select-6.38 {Tk_SelectionCmd procedure} {
|
714 |
|
|
list [catch {selection own foo bar baz} cmd] $cmd
|
715 |
|
|
} {1 {wrong # args: should be "selection own ?options? ?window?"}}
|
716 |
|
|
|
717 |
|
|
test select-6.39 {Tk_SelectionCmd procedure} {
|
718 |
|
|
list [catch {selection foo} cmd] $cmd
|
719 |
|
|
} {1 {bad option "foo": must be clear, get, handle, or own}}
|
720 |
|
|
|
721 |
|
|
##############################################################################
|
722 |
|
|
|
723 |
|
|
# This test is non-portable because some old X11/News servers ignore
|
724 |
|
|
# a selection request when the window doesn't exist, which causes a
|
725 |
|
|
# different error message.
|
726 |
|
|
|
727 |
|
|
test select-7.1 {TkSelDeadWindow procedure} {nonPortable} {
|
728 |
|
|
setup
|
729 |
|
|
selection handle .f1 { handler TEST }
|
730 |
|
|
set result [selection own]
|
731 |
|
|
destroy .f1
|
732 |
|
|
lappend result [selection own] [catch { selection get } msg] $msg
|
733 |
|
|
} {.f1 {} 1 {PRIMARY selection doesn't exist or form "STRING" not defined}}
|
734 |
|
|
|
735 |
|
|
##############################################################################
|
736 |
|
|
|
737 |
|
|
# Check reentrancy on losing selection
|
738 |
|
|
|
739 |
|
|
test select-8.1 {TkSelEventProc procedure} {unixOnly} {
|
740 |
|
|
setup
|
741 |
|
|
setupbg
|
742 |
|
|
selection own -selection CLIPBOARD -command { destroy .f1 } .f1
|
743 |
|
|
update
|
744 |
|
|
set result [dobg {selection own -selection CLIPBOARD .}]
|
745 |
|
|
cleanupbg
|
746 |
|
|
set result
|
747 |
|
|
} {}
|
748 |
|
|
|
749 |
|
|
##############################################################################
|
750 |
|
|
|
751 |
|
|
test select-9.1 {SelCvtToX and SelCvtFromX procedures} {unixOnly} {
|
752 |
|
|
global selValue selInfo
|
753 |
|
|
setup
|
754 |
|
|
setupbg
|
755 |
|
|
set selValue "1024"
|
756 |
|
|
set selInfo ""
|
757 |
|
|
selection handle -selection PRIMARY -format INTEGER -type TEST \
|
758 |
|
|
.f1 {handler TEST}
|
759 |
|
|
update
|
760 |
|
|
set result ""
|
761 |
|
|
lappend result [dobg {selection get TEST}]
|
762 |
|
|
cleanupbg
|
763 |
|
|
lappend result $selInfo
|
764 |
|
|
} {0x400 {TEST 0 4000}}
|
765 |
|
|
test select-9.2 {SelCvtToX and SelCvtFromX procedures} {unixOnly} {
|
766 |
|
|
global selValue selInfo
|
767 |
|
|
setup
|
768 |
|
|
setupbg
|
769 |
|
|
set selValue "1024 0xffff 2048 -2 "
|
770 |
|
|
set selInfo ""
|
771 |
|
|
selection handle -selection PRIMARY -format INTEGER -type TEST \
|
772 |
|
|
.f1 {handler TEST}
|
773 |
|
|
set result ""
|
774 |
|
|
lappend result [dobg {selection get TEST}]
|
775 |
|
|
cleanupbg
|
776 |
|
|
lappend result $selInfo
|
777 |
|
|
} {{0x400 0xffff 0x800 0xfffffffe} {TEST 0 4000}}
|
778 |
|
|
test select-9.3 {SelCvtToX and SelCvtFromX procedures} {unixOnly} {
|
779 |
|
|
global selValue selInfo
|
780 |
|
|
setup
|
781 |
|
|
setupbg
|
782 |
|
|
set selValue " "
|
783 |
|
|
set selInfo ""
|
784 |
|
|
selection handle -selection PRIMARY -format INTEGER -type TEST \
|
785 |
|
|
.f1 {handler TEST}
|
786 |
|
|
set result ""
|
787 |
|
|
lappend result [dobg {selection get TEST}]
|
788 |
|
|
cleanupbg
|
789 |
|
|
lappend result $selInfo
|
790 |
|
|
} {{} {TEST 0 4000}}
|
791 |
|
|
test select-9.4 {SelCvtToX and SelCvtFromX procedures} {unixOnly} {
|
792 |
|
|
global selValue selInfo
|
793 |
|
|
setup
|
794 |
|
|
setupbg
|
795 |
|
|
set selValue "16 foobar 32"
|
796 |
|
|
set selInfo ""
|
797 |
|
|
selection handle -selection PRIMARY -format INTEGER -type TEST \
|
798 |
|
|
.f1 {handler TEST}
|
799 |
|
|
set result ""
|
800 |
|
|
lappend result [dobg {selection get TEST}]
|
801 |
|
|
cleanupbg
|
802 |
|
|
lappend result $selInfo
|
803 |
|
|
} {{0x10 0x0 0x20} {TEST 0 4000}}
|
804 |
|
|
|
805 |
|
|
##############################################################################
|
806 |
|
|
|
807 |
|
|
# note, we are not testing MULTIPLE style selections
|
808 |
|
|
|
809 |
|
|
# most control paths have been exercised above
|
810 |
|
|
test select-10.1 {ConvertSelection procedure, race with selection clear} {unixOnly} {
|
811 |
|
|
setup
|
812 |
|
|
setupbg
|
813 |
|
|
set selValue "Just a simple test"
|
814 |
|
|
set selInfo ""
|
815 |
|
|
selection handle .f1 {handler STRING}
|
816 |
|
|
update
|
817 |
|
|
puts $fd {puts "[catch {selection get} msg] $msg"; puts **DONE**; flush stdout}
|
818 |
|
|
flush $fd
|
819 |
|
|
after 200
|
820 |
|
|
selection own .
|
821 |
|
|
set bgData {}
|
822 |
|
|
tkwait variable bgDone
|
823 |
|
|
cleanupbg
|
824 |
|
|
list $bgData $selInfo
|
825 |
|
|
} {{1 PRIMARY selection doesn't exist or form "STRING" not defined} {}}
|
826 |
|
|
test select-10.2 {ConvertSelection procedure} {unixOnly} {
|
827 |
|
|
setup
|
828 |
|
|
setupbg
|
829 |
|
|
set selValue [string range $longValue 0 3999]
|
830 |
|
|
set selInfo ""
|
831 |
|
|
selection handle .f1 {handler STRING}
|
832 |
|
|
set result ""
|
833 |
|
|
lappend result [dobg {selection get}]
|
834 |
|
|
cleanupbg
|
835 |
|
|
lappend result $selInfo
|
836 |
|
|
} [list [string range $longValue 0 3999] {STRING 0 4000 STRING 4000 4000 STRING 0 4000 STRING 4000 4000}]
|
837 |
|
|
test select-10.3 {ConvertSelection procedure} {unixOnly} {
|
838 |
|
|
setup
|
839 |
|
|
setupbg
|
840 |
|
|
selection handle .f1 ERROR errHandler
|
841 |
|
|
set result ""
|
842 |
|
|
lappend result [dobg {selection get ERROR}]
|
843 |
|
|
cleanupbg
|
844 |
|
|
set result
|
845 |
|
|
} {{PRIMARY selection doesn't exist or form "ERROR" not defined}}
|
846 |
|
|
# testing timers
|
847 |
|
|
test select-10.4 {ConvertSelection procedure} {unixOnly} {
|
848 |
|
|
setup
|
849 |
|
|
setupbg
|
850 |
|
|
set selValue $longValue
|
851 |
|
|
set selInfo ""
|
852 |
|
|
selection handle .f1 {errIncrHandler STRING}
|
853 |
|
|
set result ""
|
854 |
|
|
set pass 0
|
855 |
|
|
lappend result [dobg {selection get}]
|
856 |
|
|
cleanupbg
|
857 |
|
|
lappend result $selInfo
|
858 |
|
|
} {{selection owner didn't respond} {STRING 0 4000 STRING 4000 4000 STRING 8000 4000 STRING 12000 4000 STRING 16000 4000 STRING 0 4000 STRING 4000 4000}}
|
859 |
|
|
test select-10.5 {ConvertSelection procedure, reentrancy issues} {unixOnly} {
|
860 |
|
|
setup
|
861 |
|
|
setupbg
|
862 |
|
|
set selValue "Test value"
|
863 |
|
|
set selInfo ""
|
864 |
|
|
selection handle -type TEST .f1 { handler TEST }
|
865 |
|
|
selection handle -type STRING .f1 { badHandler .f1 STRING }
|
866 |
|
|
set result ""
|
867 |
|
|
lappend result [dobg {selection get}]
|
868 |
|
|
cleanupbg
|
869 |
|
|
lappend result $selInfo
|
870 |
|
|
} {{PRIMARY selection doesn't exist or form "STRING" not defined} {.f1 STRING 0 4000}}
|
871 |
|
|
test select-10.6 {ConvertSelection procedure, reentrancy issues} {unixOnly} {
|
872 |
|
|
proc weirdHandler {type offset count} {
|
873 |
|
|
destroy .f1
|
874 |
|
|
handler $type $offset $count
|
875 |
|
|
}
|
876 |
|
|
setup
|
877 |
|
|
setupbg
|
878 |
|
|
set selValue $longValue
|
879 |
|
|
set selInfo ""
|
880 |
|
|
selection handle .f1 {weirdHandler STRING}
|
881 |
|
|
set result ""
|
882 |
|
|
lappend result [dobg {selection get}]
|
883 |
|
|
cleanupbg
|
884 |
|
|
lappend result $selInfo
|
885 |
|
|
} {{PRIMARY selection doesn't exist or form "STRING" not defined} {STRING 0 4000}}
|
886 |
|
|
|
887 |
|
|
##############################################################################
|
888 |
|
|
|
889 |
|
|
# testing reentrancy
|
890 |
|
|
test select-11.1 {TkSelPropProc procedure} {unixOnly} {
|
891 |
|
|
setup
|
892 |
|
|
setupbg
|
893 |
|
|
set selValue $longValue
|
894 |
|
|
set selInfo ""
|
895 |
|
|
selection handle -type TEST .f1 { handler TEST }
|
896 |
|
|
selection handle -type STRING .f1 { reallyBadHandler .f1 STRING }
|
897 |
|
|
set result ""
|
898 |
|
|
set pass 0
|
899 |
|
|
lappend result [dobg {selection get}]
|
900 |
|
|
cleanupbg
|
901 |
|
|
lappend result $selInfo
|
902 |
|
|
} {{selection owner didn't respond} {.f1 STRING 0 4000 .f1 STRING 4000 4000 .f1 STRING 8000 4000 .f1 STRING 12000 4000 .f1 STRING 16000 4000 .f1 STRING 0 4000 .f1 STRING 4000 4000}}
|
903 |
|
|
|
904 |
|
|
##############################################################################
|
905 |
|
|
|
906 |
|
|
# Note, this assumes we are using CurrentTtime
|
907 |
|
|
test select-12.1 {DefaultSelection procedure} {unixOnly} {
|
908 |
|
|
setup
|
909 |
|
|
set result [selection get -type TIMESTAMP]
|
910 |
|
|
setupbg
|
911 |
|
|
lappend result [dobg {selection get -type TIMESTAMP}]
|
912 |
|
|
cleanupbg
|
913 |
|
|
set result
|
914 |
|
|
} {0x0 0x0}
|
915 |
|
|
test select-12.2 {DefaultSelection procedure} {unixOnly} {
|
916 |
|
|
setup
|
917 |
|
|
set result [lsort [list [selection get -type TARGETS]]]
|
918 |
|
|
setupbg
|
919 |
|
|
lappend result [dobg {lsort [selection get -type TARGETS]}]
|
920 |
|
|
cleanupbg
|
921 |
|
|
set result
|
922 |
|
|
} {{MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}}
|
923 |
|
|
test select-12.3 {DefaultSelection procedure} {unixOnly} {
|
924 |
|
|
setup
|
925 |
|
|
selection handle .f1 {handler TEST} TEST
|
926 |
|
|
set result [list [lsort [selection get -type TARGETS]]]
|
927 |
|
|
setupbg
|
928 |
|
|
lappend result [dobg {lsort [selection get -type TARGETS]}]
|
929 |
|
|
cleanupbg
|
930 |
|
|
set result
|
931 |
|
|
} {{MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}}
|
932 |
|
|
test select-12.4 {DefaultSelection procedure} {unixOnly} {
|
933 |
|
|
setup
|
934 |
|
|
set result ""
|
935 |
|
|
lappend result [selection get -type TK_APPLICATION]
|
936 |
|
|
setupbg
|
937 |
|
|
lappend result [dobg {selection get -type TK_APPLICATION}]
|
938 |
|
|
cleanupbg
|
939 |
|
|
set result
|
940 |
|
|
} [list [winfo name .] [winfo name .]]
|
941 |
|
|
test select-12.5 {DefaultSelection procedure} {unixOnly} {
|
942 |
|
|
setup
|
943 |
|
|
set result [selection get -type TK_WINDOW]
|
944 |
|
|
setupbg
|
945 |
|
|
lappend result [dobg {selection get -type TK_WINDOW}]
|
946 |
|
|
cleanupbg
|
947 |
|
|
set result
|
948 |
|
|
} {.f1 .f1}
|
949 |
|
|
test select-12.6 {DefaultSelection procedure} {
|
950 |
|
|
global selValue selInfo
|
951 |
|
|
setup
|
952 |
|
|
selection handle .f1 {handler TARGETS.f1} TARGETS
|
953 |
|
|
set selValue "Targets value"
|
954 |
|
|
set selInfo ""
|
955 |
|
|
set result [list [selection get TARGETS] $selInfo]
|
956 |
|
|
selection handle .f1 {} TARGETS
|
957 |
|
|
lappend result [selection get TARGETS]
|
958 |
|
|
} {{Targets value} {TARGETS.f1 0 4000} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}}
|
959 |
|
|
|
960 |
|
|
test select-13.1 {SelectionSize procedure, handler deleted} {unixOnly} {
|
961 |
|
|
proc badHandler {path type offset count} {
|
962 |
|
|
global selValue selInfo abortCount
|
963 |
|
|
incr abortCount -1
|
964 |
|
|
if {$abortCount == 0} {
|
965 |
|
|
selection handle -type $type $path {}
|
966 |
|
|
}
|
967 |
|
|
lappend selInfo $path $type $offset $count
|
968 |
|
|
set numBytes [expr {[string length $selValue] - $offset}]
|
969 |
|
|
if {$numBytes <= 0} {
|
970 |
|
|
return ""
|
971 |
|
|
}
|
972 |
|
|
string range $selValue $offset [expr $numBytes+$offset]
|
973 |
|
|
}
|
974 |
|
|
setup
|
975 |
|
|
setupbg
|
976 |
|
|
set selValue $longValue
|
977 |
|
|
set selInfo ""
|
978 |
|
|
selection handle .f1 {badHandler .f1 STRING}
|
979 |
|
|
set result ""
|
980 |
|
|
set abortCount 2
|
981 |
|
|
lappend result [dobg {selection get}]
|
982 |
|
|
cleanupbg
|
983 |
|
|
lappend result $selInfo
|
984 |
|
|
} {{PRIMARY selection doesn't exist or form "STRING" not defined} {.f1 STRING 0 4000 .f1 STRING 4000 4000}}
|
985 |
|
|
|
986 |
|
|
catch {rename weirdHandler {}}
|
987 |
|
|
concat
|