I want to automate the testing of my GUI. I went through the following post but if someone can post a sample test code for the following example it would be much easier for me to understand.
The following is my simple Hello World code.
namespace eval Gui {
}
proc Gui::hello {} {
toplevel .hello
wm title .hello "Hello"
wm resizable .hello 0 0 ;# not resizable
# create a frame to hold the check widgets
set f [frame .hello.boolean -borderwidth 10]
pack $f -side top
# OK and Cancel buttons
button .hello.ok -text "OK" -command [list Gui::Ok .hello ]
button .hello.cancel -text "Cancel" -command [list Gui::cancel .hello ]
pack .hello.cancel .hello.ok -side right
bind .hello <Return> {Gui::Ok .hello ; break}
bind .hello <Escape> {Gui::cancel .hello ; break}
}
proc Gui::Ok { arg } {
set x [list puts "Hello world!"]
eval $x
destroy $arg
}
proc Gui::cancel { arg } {
destroy $arg
}
#-------------------------------------------------------------------
# Gui main window
#-------------------------------------------------------------------
proc Gui::initialize { } {
# build the frame which contains menu options
frame .mbar -relief raised -bd 2
frame .mdummy -width 200 -height 240
pack .mbar .mdummy -side top -fill x
# menu options
menubutton .mbar.command -text Command -underline 0 -menu .mbar.command.menu
pack .mbar.command -side left
# menu under command options
menu .mbar.command.menu -tearoff 0
.mbar.command.menu add command -label "Hello..." -command [list Gui::hello]
}
#-------------------------------------------------------------------
# main code
#-------------------------------------------------------------------
Gui::initialize
I want to test Command -> Hello ... -> OK
and see if it outputs Hello world!
. It would be great if someone can post a sample code which simulates these clicks and tests it automatically.