📄 select.test
字号:
list [catch {selection handle} cmd] $cmd} {1 {wrong # args: should be "selection handle ?options? window command"}}test select-6.27 {Tk_SelectionCmd procedure} { list [catch {selection handle .} cmd] $cmd} {1 {wrong # args: should be "selection handle ?options? window command"}}test select-6.28 {Tk_SelectionCmd procedure} { list [catch {selection handle . foo bar baz blat} cmd] $cmd} {1 {wrong # args: should be "selection handle ?options? window command"}}test select-6.29 {Tk_SelectionCmd procedure} { catch { destroy .f2 } list [catch {selection handle .f2 dummy} cmd] $cmd} {1 {bad window path name ".f2"}}# selection owntest select-6.30 {Tk_SelectionCmd procedure} { list [catch {selection own -selection} cmd] $cmd} {1 {value for "-selection" missing}}test select-6.31 {Tk_SelectionCmd procedure} { setup selection own . selection own -displayof .f1} {.}test select-6.32 {Tk_SelectionCmd procedure} { setup selection own . selection own -selection CLIPBOARD .f1 list [selection own] [selection own -selection CLIPBOARD]} {. .f1}test select-6.33 {Tk_SelectionCmd procedure} { global lostSel setup set lostSel owned selection own -command { set lostSel lost } . selection own -selection CLIPBOARD .f1 set result $lostSel selection own .f1 lappend result $lostSel} {owned lost}test select-6.34 {Tk_SelectionCmd procedure} { list [catch {selection own -badopt foo} cmd] $cmd} {1 {unknown option "-badopt"}}test select-6.35 {Tk_SelectionCmd procedure} { list [catch {selection own -selectionfoo foo} cmd] $cmd} {1 {unknown option "-selectionfoo"}}test select-6.36 {Tk_SelectionCmd procedure} { catch {destroy .f2} list [catch {selection own -displayof .f2} cmd] $cmd} {1 {bad window path name ".f2"}}test select-6.37 {Tk_SelectionCmd procedure} { catch {destroy .f2} list [catch {selection own .f2} cmd] $cmd} {1 {bad window path name ".f2"}}test select-6.38 {Tk_SelectionCmd procedure} { list [catch {selection own foo bar baz} cmd] $cmd} {1 {wrong # args: should be "selection own ?options? ?window?"}}test select-6.39 {Tk_SelectionCmd procedure} { list [catch {selection foo} cmd] $cmd} {1 {bad option "foo": must be clear, get, handle, or own}}############################################################################## # This test is non-portable because some old X11/News servers ignore # a selection request when the window doesn't exist, which causes a # different error message. test select-7.1 {TkSelDeadWindow procedure} {nonPortable} { setup selection handle .f1 { handler TEST } set result [selection own] destroy .f1 lappend result [selection own] [catch { selection get } msg] $msg } {.f1 {} 1 {PRIMARY selection doesn't exist or form "STRING" not defined}}############################################################################### Check reentrancy on losing selectiontest select-8.1 {TkSelEventProc procedure} {unixOnly} { setup setupbg selection own -selection CLIPBOARD -command { destroy .f1 } .f1 update set result [dobg {selection own -selection CLIPBOARD .}] cleanupbg set result} {}##############################################################################test select-9.1 {SelCvtToX and SelCvtFromX procedures} {unixOnly} { global selValue selInfo setup setupbg set selValue "1024" set selInfo "" selection handle -selection PRIMARY -format INTEGER -type TEST \ .f1 {handler TEST} update set result "" lappend result [dobg {selection get TEST}] cleanupbg lappend result $selInfo} {0x400 {TEST 0 4000}}test select-9.2 {SelCvtToX and SelCvtFromX procedures} {unixOnly} { global selValue selInfo setup setupbg set selValue "1024 0xffff 2048 -2 " set selInfo "" selection handle -selection PRIMARY -format INTEGER -type TEST \ .f1 {handler TEST} set result "" lappend result [dobg {selection get TEST}] cleanupbg lappend result $selInfo} {{0x400 0xffff 0x800 0xfffffffe} {TEST 0 4000}}test select-9.3 {SelCvtToX and SelCvtFromX procedures} {unixOnly} { global selValue selInfo setup setupbg set selValue " " set selInfo "" selection handle -selection PRIMARY -format INTEGER -type TEST \ .f1 {handler TEST} set result "" lappend result [dobg {selection get TEST}] cleanupbg lappend result $selInfo} {{} {TEST 0 4000}}test select-9.4 {SelCvtToX and SelCvtFromX procedures} {unixOnly} { global selValue selInfo setup setupbg set selValue "16 foobar 32" set selInfo "" selection handle -selection PRIMARY -format INTEGER -type TEST \ .f1 {handler TEST} set result "" lappend result [dobg {selection get TEST}] cleanupbg lappend result $selInfo} {{0x10 0x0 0x20} {TEST 0 4000}}############################################################################### note, we are not testing MULTIPLE style selections# most control paths have been exercised abovetest select-10.1 {ConvertSelection procedure, race with selection clear} {unixOnly} { setup setupbg set selValue "Just a simple test" set selInfo "" selection handle .f1 {handler STRING} update puts $fd {puts "[catch {selection get} msg] $msg"; puts **DONE**; flush stdout} flush $fd after 200 selection own . set bgData {} tkwait variable bgDone cleanupbg list $bgData $selInfo} {{1 PRIMARY selection doesn't exist or form "STRING" not defined} {}}test select-10.2 {ConvertSelection procedure} {unixOnly} { setup setupbg set selValue [string range $longValue 0 3999] set selInfo "" selection handle .f1 {handler STRING} set result "" lappend result [dobg {selection get}] cleanupbg lappend result $selInfo} [list [string range $longValue 0 3999] {STRING 0 4000 STRING 4000 4000 STRING 0 4000 STRING 4000 4000}]test select-10.3 {ConvertSelection procedure} {unixOnly} { setup setupbg selection handle .f1 ERROR errHandler set result "" lappend result [dobg {selection get ERROR}] cleanupbg set result} {{PRIMARY selection doesn't exist or form "ERROR" not defined}}# testing timerstest select-10.4 {ConvertSelection procedure} {unixOnly} { setup setupbg set selValue $longValue set selInfo "" selection handle .f1 {errIncrHandler STRING} set result "" set pass 0 lappend result [dobg {selection get}] cleanupbg lappend result $selInfo} {{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}}test select-10.5 {ConvertSelection procedure, reentrancy issues} {unixOnly} { setup setupbg set selValue "Test value" set selInfo "" selection handle -type TEST .f1 { handler TEST } selection handle -type STRING .f1 { badHandler .f1 STRING } set result "" lappend result [dobg {selection get}] cleanupbg lappend result $selInfo} {{PRIMARY selection doesn't exist or form "STRING" not defined} {.f1 STRING 0 4000}}test select-10.6 {ConvertSelection procedure, reentrancy issues} {unixOnly} { proc weirdHandler {type offset count} { destroy .f1 handler $type $offset $count } setup setupbg set selValue $longValue set selInfo "" selection handle .f1 {weirdHandler STRING} set result "" lappend result [dobg {selection get}] cleanupbg lappend result $selInfo} {{PRIMARY selection doesn't exist or form "STRING" not defined} {STRING 0 4000}}############################################################################### testing reentrancytest select-11.1 {TkSelPropProc procedure} {unixOnly} { setup setupbg set selValue $longValue set selInfo "" selection handle -type TEST .f1 { handler TEST } selection handle -type STRING .f1 { reallyBadHandler .f1 STRING } set result "" set pass 0 lappend result [dobg {selection get}] cleanupbg lappend result $selInfo} {{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}}############################################################################### Note, this assumes we are using CurrentTtimetest select-12.1 {DefaultSelection procedure} {unixOnly} { setup set result [selection get -type TIMESTAMP] setupbg lappend result [dobg {selection get -type TIMESTAMP}] cleanupbg set result} {0x0 0x0}test select-12.2 {DefaultSelection procedure} {unixOnly} { setup set result [lsort [list [selection get -type TARGETS]]] setupbg lappend result [dobg {lsort [selection get -type TARGETS]}] cleanupbg set result} {{MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}}test select-12.3 {DefaultSelection procedure} {unixOnly} { setup selection handle .f1 {handler TEST} TEST set result [list [lsort [selection get -type TARGETS]]] setupbg lappend result [dobg {lsort [selection get -type TARGETS]}] cleanupbg set result} {{MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}}test select-12.4 {DefaultSelection procedure} {unixOnly} { setup set result "" lappend result [selection get -type TK_APPLICATION] setupbg lappend result [dobg {selection get -type TK_APPLICATION}] cleanupbg set result} [list [winfo name .] [winfo name .]]test select-12.5 {DefaultSelection procedure} {unixOnly} { setup set result [selection get -type TK_WINDOW] setupbg lappend result [dobg {selection get -type TK_WINDOW}] cleanupbg set result} {.f1 .f1}test select-12.6 {DefaultSelection procedure} { global selValue selInfo setup selection handle .f1 {handler TARGETS.f1} TARGETS set selValue "Targets value" set selInfo "" set result [list [selection get TARGETS] $selInfo] selection handle .f1 {} TARGETS lappend result [selection get TARGETS]} {{Targets value} {TARGETS.f1 0 4000} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}}test select-13.1 {SelectionSize procedure, handler deleted} {unixOnly} { proc badHandler {path type offset count} { global selValue selInfo abortCount incr abortCount -1 if {$abortCount == 0} { selection handle -type $type $path {} } lappend selInfo $path $type $offset $count set numBytes [expr {[string length $selValue] - $offset}] if {$numBytes <= 0} { return "" } string range $selValue $offset [expr $numBytes+$offset] } setup setupbg set selValue $longValue set selInfo "" selection handle .f1 {badHandler .f1 STRING} set result "" set abortCount 2 lappend result [dobg {selection get}] cleanupbg lappend result $selInfo} {{PRIMARY selection doesn't exist or form "STRING" not defined} {.f1 STRING 0 4000 .f1 STRING 4000 4000}}catch {rename weirdHandler {}}concat
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -