1# This file is a Tcl script to test out [incr Widgets] Promptdialog class.
2# It is organized in the standard fashion for Tcl tests with the following
3# notation for test case labels:
4#
5#   1.x - Construction/Destruction tests
6#   2.x - Configuration option tests
7#   3.x - Method tests
8#   4.x - Other tests
9#
10# Copyright (c) 1995 DSC Technologies Corporation
11#
12# See the file "license.terms" for information on usage and redistribution
13# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14#
15# @(#) $Id: promptdialog.test,v 1.3 2001/08/07 19:56:48 smithc Exp $
16
17package require tcltest
18namespace import -force ::tcltest::*
19
20if [catch {package require Iwidgets 4.0}] {
21  # Let's try modifying the auto_path.  Note that the IWIDGETS_LIBRARY
22  # env var is initialized in the Makefile when doing a 'make test'.
23  # If sourcing this file independently, this variable must be set manually.
24  if ![info exists env(IWIDGETS_LIBRARY)] {
25    error "Unable to locate Iwidgets package.  Set your IWIDGETS_LIBRARY\
26      environment\nvariable to the directory that contains iwidgets.tcl"
27  }
28  lappend auto_path $env(IWIDGETS_LIBRARY)
29  package require Iwidgets 4.0
30}
31
32if {[string compare test [info procs test]] == 1} {
33    source defs
34}
35
36wm geometry . {}
37raise .
38
39set c 1
40set o 1
41set m 1
42
43#
44# Initial construction test
45#
46test Promptdialog-1.$c {Promptdialog construction} {
47    iwidgets::Promptdialog .pd
48    .pd activate
49} {}
50
51incr c
52
53#
54# Option tests which are successful.
55#
56test Promptdialog-2.$o {configuration option} {
57    llength [.pd configure]
58} {38}
59
60incr o
61
62foreach test {
63    {-background #d9d9d9 #d9d9d9} 
64    {-buttonboxpos n n} 
65    {-buttonboxpadx 10 10} 
66    {-buttonboxpos e e} 
67    {-buttonboxpos w w} 
68    {-buttonboxpady 10 10} 
69    {-buttonboxpos s s} 
70    {-cursor gumby gumby} 
71    {-exportselection 1 1}
72    {-modality global global} 
73    {-modality application application} 
74    {-modality none none} 
75    {-padx 15 15} 
76    {-pady 15 15} 
77    {-separator off off} 
78    {-thickness 5 5} 
79    {-separator on on} 
80    {-title "Prompt Dialog" "Prompt Dialog"}
81    {-foreground Black Black} 
82    {-textbackground GhostWhite GhostWhite} 
83    {-insertbackground Black Black} 
84    {-insertborderwidth 1 1} 
85    {-insertborderwidth 0 0} 
86    {-insertofftime 400 400} 
87    {-insertontime 700 700} 
88    {-insertwidth 3 3} 
89    {-labelpos nw nw}
90    {-labelpos n n}
91    {-labelpos ne ne}
92    {-labelpos en en}
93    {-labelpos e e}
94    {-labelpos es es}
95    {-labelpos sw sw}
96    {-labelpos s s}
97    {-labelpos se se}
98    {-labelpos wn wn}
99    {-labelpos w w}
100    {-labelpos ws ws}
101    {-labeltext Label Label} 
102    {-relief sunken sunken} 
103    {-textbackground GhostWhite GhostWhite} 
104    {-validate numeric numeric} 
105    {-validate alphabetic alphabetic} 
106    {-validate alphanumeric alphanumeric}} {
107	set option [lindex $test 0]
108	test Promptdialog-2.$o "configuration options, $option" {
109	    .pd configure $option [lindex $test 1]
110	    lindex [.pd configure $option] 4
111	} [lindex $test 2]
112	update 
113	incr o
114}
115
116#
117# Method tests which are successful.
118#
119foreach test {
120    {{.pd childsite} {.pd.shellchildsite.dschildsite}}
121    {{.pd insert end "Test String"} {}}
122    {{.pd get} {Test String}}
123    {{.pd delete 0 end} {}}
124    {{.pd insert end "Another Test"} {}}
125    {{.pd icursor end} {}}
126    {{.pd index end} 12}
127    {{.pd selection from 0} {}}
128    {{.pd selection to end} {}}
129    {{.pd xview 3} {}}
130    {{.pd clear} {}}
131    {{.pd hide Help} {}}
132    {{.pd hide Cancel} {}}
133    {{.pd default Apply} {}}
134    {{.pd show Cancel} {}}
135    {{.pd deactivate} {}}} {
136	set method [lindex [lindex $test 0] 1]
137	test Promptdialog-3.$m "object methods, $method" {
138	    list [catch {eval [lindex $test 0]} msg] $msg
139	} [list 0 [lindex $test 1]]
140	update 
141	incr m
142}
143
144#
145# Conclusion of constrcution/destruction tests
146#
147test Promptdialog-1.$c {Promptdialog destruction} {
148    destroy .pd
149    update 
150} {}
151
152incr c
153
154test Promptdialog-1.$c {Promptdialog construction} {
155    iwidgets::promptdialog .pd
156    update 
157} {}
158
159incr c
160
161test Promptdialog-1.$c {Promptdialog destruction} {
162    destroy .pd
163    update 
164} {}
165
166incr c
167
168test Promptdialog-1.$c {Promptdialog destruction} {
169    iwidgets::promptdialog .pd
170    destroy .pd
171    update 
172} {}
173
174::tcltest::cleanupTests
175exit
176