123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- # console tests. -*- tcl -*-
- #
- # Sourcing this file into Tcl runs the tests and
- # generates output for errors. No output means no errors were found.
- #
- # Copyright 2004 Mayo Foundation. All rights reserved.
- # $Id: console.test,v 1.1 2004/02/12 20:56:57 techenti Exp $
- if {[lsearch [namespace children] ::tcltest] == -1} {
- package require tcltest
- namespace import ::tcltest::*
- }
- #-------------------------------------------------------------------------
- # Tell tcltest to log error messages.
- # Since we're using child interps, you don't get much
- # in the way of meaningful test failures - just a return code
- # mismatch.
- #-------------------------------------------------------------------------
- ::tcltest::configure -verbose be
- #-------------------------------------------------------------------------
- # Set the auto_path for the child interps.
- #-------------------------------------------------------------------------
- set auto_path [concat [file dirname [info script]] $auto_path]
- #-------------------------------------------------------------------------
- # Create child interps using this autopath.
- # Add code to load console package, and remove a special
- # tkcon variable which would cause problems with
- # tkcon's checkpointing when run in child interps.
- #-------------------------------------------------------------------------
- proc createInterp {} {
- set c [interp create]
- $c alias parentSet set
- $c eval {
- set argv ""
- set auto_path [parentSet ::auto_path]
- package require console
- unset ::tkcon::CPS(slave,,cmd)
- }
- return $c
- }
- #-------------------------------------------------------------------------
- # Begin tests
- #-------------------------------------------------------------------------
- test console-1.0 {create console, no options} {
- set c [createInterp]
- set result [$c eval {
- console::create
- update
- #::tkcon close
- }]
- interp delete $c
- set result
- } {}
- test console-1.1 {create console, specify window name} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole
- update
- set result [winfo exists .myconsole]
- }]
- interp delete $c
- set result
- } {1}
- test console-1.2 {create console, show on startup} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -showOnStartup 1
- update
- set result [winfo ismapped .myconsole]
- }]
- interp delete $c
- set result
- } {1}
- test console-1.3 {create console, don't show on startup} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -showOnStartup 0
- update
- set result [winfo ismapped .myconsole]
- }]
- interp delete $c
- set result
- } {0}
- test console-1.4 {create console, set title} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -title "console title"
- update
- set result [wm title .myconsole]
- }]
- interp delete $c
- set result
- } {console title}
- test console-1.5 {create console, set protocol script} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -protocol "protocol script"
- update
- set result [wm protocol .myconsole WM_DELETE_WINDOW]
- }]
- interp delete $c
- set result
- } {protocol script}
- test console-1.6 {create console, hide menu} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -showMenu 0
- update
- set result $::tkcon::OPT(showmenu)
- }]
- interp delete $c
- set result
- } {0}
- test console-1.7 {create console, show menu} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -showMenu 1
- update
- set result $::tkcon::OPT(showmenu)
- }]
- interp delete $c
- set result
- } {1}
- #-------------------------------------------------------------------------
- # Test using global variable
- # Note: these tests all fail for some reason. It acts like the
- # package never creates the global variable. Don't know if this
- # is just an artifact of the child interp or the test harness.
- # *sigh*
- #-------------------------------------------------------------------------
- if 0 {
- test console-2.0 {create console with global variable} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -variable ::myglobal
- update
- set result [info exists ::myglobal]
- }]
- interp delete $c
- set result
- } {1}
- test console-2.1 {create console with global variable, show and hide} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -variable ::myglobal
- set ::myglobal 1
- update
- set result [list [winfo ismapped .myconsole]]
- set ::myglobal 0
- update
- lappend result [winfo ismapped .myconsole]
- }]
- interp delete $c
- set result
- } {1 0}
- test console-2.2 {create console with global variable, show and hide} {
- set c [createInterp]
- set result [$c eval {
- console::create -root .myconsole -variable ::myglobal
- console::show
- update
- set result [list $::myglobal]
- console::hide
- lappend result $::myglobal
- }]
- interp delete $c
- set result
- } {1 0}
- }
- ::tcltest::cleanupTests
|