summaryrefslogtreecommitdiffstats
path: root/tests/menubut.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/menubut.test')
-rw-r--r--tests/menubut.test69
1 files changed, 48 insertions, 21 deletions
diff --git a/tests/menubut.test b/tests/menubut.test
index cbfb977..d1f994f 100644
--- a/tests/menubut.test
+++ b/tests/menubut.test
@@ -1,25 +1,42 @@
-# This file is a Tcl script to test menubuttons in Tk. It is
-# organized in the standard fashion for Tcl tests.
+# This file is a Tcl script to test menubuttons in Tk.
#
# Copyright © 1994 The Regents of the University of California.
# Copyright © 1994-1996 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
# All rights reserved.
-# XXX This test file is woefully incomplete right now. If any part
-# XXX of a procedure has tests then the whole procedure has tests,
-# XXX but many procedures have no tests.
+# NOTE
+#
+# This test file is woefully incomplete right now. Many procedures have no
+# tests. The tests for ConfigureMenuButton are incomplete.
+#
+
+#
+# TESTFILE INITIALIZATION
+#
-package require tcltest 2.2
-eval tcltest::configure $argv
-tcltest::loadTestedCommands
-namespace import -force tcltest::test
+package require tcltest 2.2; # needed in mode -singleproc 0
+
+# Load the main script main.tcl, which takes care of:
+# - setup for the application and the root window
+# - importing commands from the tcltest namespace
+# - loading of the testutils mechanism along with its utility procs
+# - loading of Tk specific test constraints (additionally to constraints
+# provided by the package tcltest)
+source [file join [tcltest::configure -testdir] main.tcl]
+
+# Ensure a pristine initial window state
+resetWindows
# Import utility procs for specific functional areas
testutils import image
imageInit
+#
+# COMMON TEST SETUP
+#
+
# Create entries in the option database to be sure that geometry options
# like border width have predictable values.
@@ -30,10 +47,14 @@ option add *Button.borderWidth 2
option add *Button.highlightThickness 2
option add *Button.font {Helvetica -12 bold}
-
menubutton .mb -text "Test"
pack .mb
update
+
+#
+# TESTS
+#
+
test menubutton-1.1 {configuration options} -body {
.mb configure -activebackground #012345
.mb cget -activebackground
@@ -318,11 +339,14 @@ test menubutton-1.59 {configuration options} -body {
.mb configure -wraplength 6x
} -returnCodes error -result {expected screen distance but got "6x"}
-
+#
+# COMMON TEST SETUP
+#
deleteWindows
menubutton .mb -text "Test"
pack .mb
update
+
test menubutton-2.1 {Tk_MenubuttonCmd procedure} -body {
menubutton
} -returnCodes error -result {wrong # args: should be "menubutton pathName ?-option value ...?"}
@@ -346,10 +370,13 @@ test menubutton-2.5 {Tk_ButtonCmd procedure} -setup {
winfo exists .mb
} -result 0
-
+#
+# COMMON TEST SETUP
+#
deleteWindows
menubutton .mb -text "Test Menu"
pack .mb
+
test menubutton-3.1 {MenuButtonWidgetCmd procedure} -body {
.mb
} -returnCodes error -result {wrong # args: should be ".mb option ?arg ...?"}
@@ -386,10 +413,11 @@ test menubutton-3.10 {ButtonWidgetCmd procedure, "configure" option} -body {
test menubutton-3.11 {ButtonWidgetCmd procedure, "configure" option} -body {
.mb foobar
} -returnCodes error -result {bad option "foobar": must be cget or configure}
-deleteWindows
-# XXX Need to add tests for several procedures here. The tests for XXX
-# XXX ConfigureMenuButton aren't complete either. XXX
+#
+# COMMON TEST CLEANUP
+#
+deleteWindows
test menubutton-4.1 {ConfigureMenuButton procedure} -setup {
deleteWindows
@@ -517,10 +545,6 @@ test menubutton-4.11 {ConfigureMenuButton procedure - bad direction} -setup {
deleteWindows
} -result {below {}}
-
-
-# XXX Need to add tests for several procedures here. XXX
-
test menubutton-5.1 {MenuButtonEventProc procedure} -setup {
deleteWindows
set x {}
@@ -546,11 +570,15 @@ test menubutton-6.1 {MenuButtonCmdDeletedProc procedure} -setup {
deleteWindows
} -result {{} {}}
+#
+# COMMON TEST SETUP
+#
if {[tk windowingsystem] eq "aqua"} {
set extraWidth 36
} else {
set extraWidth 0
}
+
test menubutton-7.1 {ComputeMenuButtonGeometry procedure} -constraints {
testImageType
} -setup {
@@ -784,7 +812,7 @@ test menubutton-9.2 {Bug [5d991b822e]} {
} {}
#
-# CLEANUP
+# TESTFILE CLEANUP
#
deleteWindows
@@ -793,7 +821,6 @@ imageFinish
testutils forget image
cleanupTests
-return
# Local variables:
# mode: tcl