OSDN Git Service

Updated to tk 8.4.1
[pf3gnuchains/sourceware.git] / tk / tests / unixSelect.test
index 9a29d0a..775ca88 100644 (file)
 #
 # RCS: @(#) $Id$
 
-if {[lsearch [namespace children] ::tcltest] == -1} {
-    source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {$tcl_platform(platform) != "unix"} {
-    puts "skipping: Unix only tests..."
-    ::tcltest::cleanupTests
-    return
-}
-
-eval destroy [winfo child .]
+package require tcltest 2.1
+namespace import -force tcltest::configure
+namespace import -force tcltest::testsDirectory
+configure -testdir [file join [pwd] [file dirname [info script]]]
+configure -loadfile [file join [testsDirectory] constraints.tcl]
+tcltest::loadTestedCommands
 
 global longValue selValue selInfo
 
@@ -238,6 +233,121 @@ test unixSelect-1.10 {TkSelGetSelection procedure: INCR i18n text} {unixOnly} {
     list [string equal [string repeat x 3999]\u00fc[string repeat x 4000] $x] \
            [string length $x] [string bytelength $x]
 } {1 8000 8001}
+# Now some tests to make sure that the right thing is done when
+# transferring UTF8 selections, to prevent [Bug 614650] and its ilk
+# from rearing its ugly head again.
+test unixSelect-1.11 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       entry .e; pack .e; update
+       .e insert 0 [string repeat x 3999]\u00fc
+       .e selection range 0 end
+    }
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal [string repeat x 3999]\u00fc $x] \
+           [string length $x] [string bytelength $x]
+} {1 4000 4001}
+test unixSelect-1.12 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       entry .e; pack .e; update
+       .e insert 0 \u00fc[string repeat x 3999]
+       .e selection range 0 end
+    }
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal \u00fc[string repeat x 3999] $x] \
+           [string length $x] [string bytelength $x]
+} {1 4000 4001}
+test unixSelect-1.13 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       entry .e; pack .e; update
+       .e insert 0 [string repeat x 3999]\u00fc[string repeat x 4000]
+       .e selection range 0 end
+    }
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal [string repeat x 3999]\u00fc[string repeat x 4000] $x] \
+           [string length $x] [string bytelength $x]
+} {1 8000 8001}
+test unixSelect-1.14 {TkSelGetSelection procedure: simple i18n text, utf-8} {unixOnly} {
+    setupbg
+    entry .e
+    pack .e
+    update
+    .e insert 0 [encoding convertfrom identity \u00fcber\u0444]
+    .e selection range 0 end
+    set result [dobg {string bytelength [selection get -type UTF8_STRING]}]
+    cleanupbg
+    destroy .e
+    set result
+} {5}
+test unixSelect-1.15 {TkSelGetSelection procedure: simple i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       entry .e; pack .e; update
+       .e insert 0 \u00fc\u0444
+       .e selection range 0 end
+    }
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal \u00fc\u0444 $x] \
+           [string length $x] [string bytelength $x]
+} {1 2 4}
+test unixSelect-1.16 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       entry .e; pack .e; update
+       .e insert 0 [string repeat [string repeat \u00c4\u00e4 50]\n 21]
+       .e selection range 0 end
+    }
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal [string repeat [string repeat \u00c4\u00e4 50]\n 21] $x] \
+           [string length $x] [string bytelength $x]
+} {1 2121 4221}
+test unixSelect-1.17 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       entry .e; pack .e; update
+       .e insert 0 i[string repeat [string repeat \u00c4\u00e4 50]\n 21]
+       .e selection range 0 end
+    }
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal i[string repeat [string repeat \u00c4\u00e4 50]\n 21] $x] \
+           [string length $x] [string bytelength $x]
+} {1 2122 4222}
+test unixSelect-1.18 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       text .t; pack .t; update
+       .t insert 1.0 [string repeat [string repeat \u00c4\u00e4 50]\n 21]
+       # Has to be selected in a separate stage
+       .t tag add sel 1.0 21.end+1c
+    }
+    after 10
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal [string repeat [string repeat \u00c4\u00e4 50]\n 21] $x] \
+           [string length $x] [string bytelength $x]
+} {1 2121 4221}
+test unixSelect-1.19 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixOnly} {
+    setupbg
+    dobg {
+       text .t; pack .t; update
+       .t insert 1.0 i[string repeat [string repeat \u00c4\u00e4 50]\n 21]
+       # Has to be selected in a separate stage
+       .t tag add sel 1.0 21.end+1c
+    }
+    after 10
+    set x [selection get -type UTF8_STRING]
+    cleanupbg
+    list [string equal i[string repeat [string repeat \u00c4\u00e4 50]\n 21] $x] \
+           [string length $x] [string bytelength $x]
+} {1 2122 4222}
 
 # cleanup
 ::tcltest::cleanupTests