diff options
author | dgp <dgp@users.sourceforge.net> | 2001-08-24 16:44:19 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2001-08-24 16:44:19 (GMT) |
commit | 35f07899335f4b82bc1cf0b433da395c254d5163 (patch) | |
tree | 5caf9e1bc069a382bc0abbebc4c1f4519bb377d4 | |
parent | 22d41e3fca776345fb97d8a4156c224b380423e2 (diff) | |
download | tk-35f07899335f4b82bc1cf0b433da395c254d5163.zip tk-35f07899335f4b82bc1cf0b433da395c254d5163.tar.gz tk-35f07899335f4b82bc1cf0b433da395c254d5163.tar.bz2 |
* New file: tests/dialog.test for testing [tk_dialog].
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | tests/dialog.test | 66 |
2 files changed, 70 insertions, 0 deletions
@@ -1,3 +1,7 @@ +2001-08-24 Don Porter <dgp@users.sourceforge.net> + + * tests/dialog.test: New file testing [tk_dialog]. + 2001-08-23 Jeff Hobbs <jeffh@ActiveState.com> * unix/configure: diff --git a/tests/dialog.test b/tests/dialog.test new file mode 100644 index 0000000..c9aed1b --- /dev/null +++ b/tests/dialog.test @@ -0,0 +1,66 @@ +# This file is a Tcl script to test out Tk's "tk_dialog" command. +# It is organized in the standard fashion for Tcl tests. +# +# RCS: @(#) $Id: dialog.test,v 1.2.2.1 2001/08/24 16:44:19 dgp Exp $ +# + +if {[lsearch [namespace children] ::tcltest] == -1} { + source [file join [pwd] [file dirname [info script]] defs.tcl] +} + +# Some tests require user interaction on non-unix platform + +set ::tcltest::testConfig(nonUnixUserInteraction) \ + [expr {$::tcltest::testConfig(userInteraction) || \ + $::tcltest::testConfig(unixOnly)}] + +test dialog-1.1 {tk_dialog command} { + list [catch {tk_dialog} msg] $msg +} {1 {no value given for parameter "w" to "tk_dialog"}} +test dialog-1.2 {tk_dialog command} { + list [catch {tk_dialog foo foo foo foo foo} msg] $msg +} {1 {bad window path name "foo"}} +test dialog-1.3 {tk_dialog command} { + set res [list [catch {tk_dialog .d foo foo foo foo} msg] $msg] + destroy .d + set res +} {1 {bitmap "foo" not defined}} + +proc PressButton {btn} { + if {![winfo ismapped $btn]} { + update + } + event generate $btn <Enter> + event generate $btn <1> -x 5 -y 5 + event generate $btn <ButtonRelease-1> -x 5 -y 5 +} + +proc HitReturn {w} { + event generate $w <Enter> + focus -force $w + event generate $w <KeyPress> -keysym Return +} + +test dialog-2.0 {tk_dialog operation} { + set x [after 5000 [list set tk::Priv(button) "no response"]] + after 100 PressButton .d.button0 + set res [tk_dialog .d foo foo info 0 click] + after cancel $x + set res +} {0} +test dialog-2.1 {tk_dialog operation} { + set x [after 5000 [list set tk::Priv(button) "no response"]] + after 100 HitReturn .d + set res [tk_dialog .d foo foo info 1 click default] + after cancel $x + set res +} {1} +test dialog-2.2 {tk_dialog operation} { + set x [after 5000 [list set tk::Priv(button) "no response"]] + after 100 destroy .d + set res [tk_dialog .d foo foo info 0 click] + after cancel $x + set res +} {-1} + + |