summaryrefslogtreecommitdiffstats
path: root/tests/fontchooser.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fontchooser.test')
-rw-r--r--tests/fontchooser.test40
1 files changed, 32 insertions, 8 deletions
diff --git a/tests/fontchooser.test b/tests/fontchooser.test
index 7a7c37d..4f920d1 100644
--- a/tests/fontchooser.test
+++ b/tests/fontchooser.test
@@ -2,16 +2,43 @@
#
# Copyright © 2008 Pat Thoyts
-package require tcltest 2.2
-eval tcltest::configure $argv
-tcltest::loadTestedCommands
+#
+# TESTFILE INITIALIZATION
+#
+
+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 dialog
set applyFontCmd [list set testDialogFont]
-# -------------------------------------------------------------------------
+#
+# LOCAL TEST CONSTRAINTS
+#
+
+# The tk fontchooser call below autoloads fontchooser.tcl on platforms
+# that don't provide a native implementation of the font selection dialog.
+# This will make ::tk::fontchooser::Configure exist, and scriptImpl become true,
+# indicating use of the scripted implementation of the dialog. Platforms using
+# the native dialog do not define a ::tk::fontchooser::Configure proc.
+catch {tk fontchooser}
+testConstraint scriptImpl [llength [info proc ::tk::fontchooser::Configure]]
+
+#
+# TESTS
+#
test fontchooser-1.1 {tk fontchooser: usage} -returnCodes error -body {
tk fontchooser -z
@@ -49,14 +76,12 @@ test fontchooser-1.9 {tk fontchooser: usage} -returnCodes error -body {
tk fontchooser configure -visible 1
} -match glob -result {*}
-# -------------------------------------------------------------------------
#
# The remaining tests in this file are only relevant for the script
# implementation. They can be tested by sourcing the script file but
# the Tk tests are run with -singleproc 1 and doing this affects the
# result of later attempts to test the native implementations.
#
-testConstraint scriptImpl [llength [info proc ::tk::fontchooser::Configure]]
test fontchooser-2.0 {fontchooser -title} -constraints scriptImpl -body {
testDialog launch {
@@ -161,13 +186,12 @@ test fontchooser-5.1 {fontchooser multiple configure} -constraints {scriptImpl}
} -result {TestTitle}
#
-# CLEANUP
+# TESTFILE CLEANUP
#
unset applyFontCmd
testutils forget dialog
cleanupTests
-return
# Local Variables:
# mode: tcl