summaryrefslogtreecommitdiffstats
path: root/tests/cursor.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cursor.test')
-rw-r--r--tests/cursor.test99
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/cursor.test b/tests/cursor.test
new file mode 100644
index 0000000..21259be
--- /dev/null
+++ b/tests/cursor.test
@@ -0,0 +1,99 @@
+# This file is a Tcl script to test out the procedures in the file
+# tkCursor.c. It is organized in the standard white-box fashion for
+# Tcl tests.
+#
+# Copyright (c) 1998 Sun Microsystems, Inc.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# SCCS: @(#) cursor.test 1.1 97/12/24 15:17:35
+
+if {[info procs test] != "test"} {
+ source defs
+}
+
+if {[info commands testcursor] != "testcursor"} {
+ puts "testcursor command not available; skipping tests"
+ return
+}
+
+eval destroy [winfo children .]
+wm geometry . {}
+raise .
+
+test cursor-1.1 {Tk_AllocCursorFromObj - converting internal reps} {
+ set x watch
+ lindex $x 0
+ destroy .b1
+ button .b1 -cursor $x
+ lindex $x 0
+ testcursor watch
+} {{1 0}}
+test cursor-1.2 {Tk_AllocCursorFromObj - discard stale cursor} {
+ set x watch
+ destroy .b1 .b2
+ button .b1 -cursor $x
+ destroy .b1
+ set result {}
+ lappend result [testcursor watch]
+ button .b2 -cursor $x
+ lappend result [testcursor watch]
+} {{} {{1 1}}}
+test cursor-1.3 {Tk_AllocCursorFromObj - reuse existing cursor} {
+ set x watch
+ destroy .b1 .b2
+ button .b1 -cursor $x
+ set result {}
+ lappend result [testcursor watch]
+ button .b2 -cursor $x
+ pack .b1 .b2 -side top
+ lappend result [testcursor watch]
+} {{1 1}} {{2 1}}
+
+test cursor-2.1 {Tk_GetCursor procedure} {
+ destroy .b1
+ list [catch {button .b1 -cursor bad_name} msg] $msg
+} {1 {bad cursor spec "bad_name"}}
+test cursor-2.2 {Tk_GetCursor procedure} {
+ destroy .b1
+ list [catch {button .b1 -cursor @xyzzy} msg] $msg
+} {1 {bad cursor spec "@xyzzy"}}
+
+test cursor-3.1 {Tk_FreeCursorFromObj - reference counts} {
+ set x arrow
+ destroy .b1 .b2 .b3
+ button .b1 -cursor $x
+ button .b3 -cursor $x
+ button .b2 -cursor $x
+ set result {}
+ lappend result [testcursor arrow]
+ destroy .b1
+ lappend result [testcursor arrow]
+ destroy .b2
+ lappend result [testcursor arrow]
+ destroy .b3
+ lappend result [testcursor arrow]
+} {{{3 1}} {{2 1}} {{1 1}} {}}
+
+test cursor-4.1 {FreeCursorObjProc} {
+ destroy .b
+ set x [format arrow]
+ button .b -cursor $x
+ set y [format arrow]
+ .b configure -cursor $y
+ set z [format arrow]
+ .b configure -cursor $z
+ set result {}
+ lappend result [testcursor arrow]
+ set x red
+ lappend result [testcursor arrow]
+ set z 32
+ lappend result [testcursor arrow]
+ destroy .b
+ lappend result [testcursor arrow]
+ set y bogus
+ set result
+} {{{1 3}} {{1 2}} {{1 1}} {}}
+
+destroy .t