GUIのテストを自動化したい。私は次の投稿を行いましたが、誰かが次の例のサンプルテストコードを投稿できれば、私ははるかに理解しやすくなります。
以下は私の単純なHelloWorldコードです。
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
Command -> Hello ... -> OK
テストして、出力されるかどうかを確認したいと思いますHello world!
。誰かがこれらのクリックをシミュレートして自動的にテストするサンプルコードを投稿できれば素晴らしいと思います。