# This file is a Tcl script to test out the "image" command and the # other procedures in the file tkImage.c. It is organized in the # standard fashion for Tcl tests. # # Copyright (c) 1994 The Regents of the University of California. # Copyright (c) 1994 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # # RCS: @(#) $Id: image.test,v 1.6 2000/11/29 15:47:05 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] } if {[lsearch [image types] test] < 0} { puts "This application hasn't been compiled with the \"test\" image" puts "type, so I can't run this test. Are you sure you're using" puts "tktest instead of wish?" ::tcltest::cleanupTests return } foreach i [winfo children .] { destroy $i } wm geometry . {} raise . eval image delete [image names] canvas .c -highlightthickness 2 pack .c update test image-1.1 {Tk_ImageCmd procedure, "create" option} { list [catch image msg] $msg } {1 {wrong # args: should be "image option ?args?"}} test image-1.2 {Tk_ImageCmd procedure, "create" option} { list [catch {image gorp} msg] $msg } {1 {bad option "gorp": must be create, delete, height, inuse, names, type, types, or width}} test image-1.3 {Tk_ImageCmd procedure, "create" option} { list [catch {image create} msg] $msg } {1 {wrong # args: should be "image create type ?name? ?options?"}} test image-1.4 {Tk_ImageCmd procedure, "create" option} { list [catch {image c bad_type} msg] $msg } {1 {image type "bad_type" doesn't exist}} test image-1.5 {Tk_ImageCmd procedure, "create" option} { list [image create test myimage] [image names] } {myimage myimage} test image-1.6 {Tk_ImageCmd procedure, "create" option} { scan [image create test] image%d first image create test myimage scan [image create test -variable x] image%d second expr $second-$first } {1} test image-1.7 {Tk_ImageCmd procedure, "create" option} { image delete myimage image create test myimage -variable x .c create image 100 50 -image myimage .c create image 100 150 -image myimage update set x {} image create test myimage -variable x update set x } {{myimage free} {myimage free} {myimage delete} {myimage get} {myimage get} {myimage display 0 0 30 15 30 30} {myimage display 0 0 30 15 30 130}} test image-1.8 {Tk_ImageCmd procedure, "create" option} { .c delete all image create test myimage -variable x .c create image 100 50 -image myimage .c create image 100 150 -image myimage image delete myimage update set x {} image create test myimage -variable x update set x } {{myimage get} {myimage get} {myimage display 0 0 30 15 30 30} {myimage display 0 0 30 15 30 130}} test image-1.9 {Tk_ImageCmd procedure, "create" option} { .c delete all eval image delete [image names] list [catch {image create test -badName foo} msg] $msg [image names] } {1 {bad option name "-badName"} {}} test image-1.10 {Tk_ImageCmd procedure, "create" option with "." as name} { catch {removeFile script} set fd [open script w] puts $fd { update puts [list [catch {image create photo .} msg] $msg] exit } close $fd set x [list [catch {exec $::tcltest::tktest