summaryrefslogtreecommitdiff
path: root/itcl/iwidgets3.0.0/tests/panedwindow.test
blob: 3cb78bb0248fd6dc65fead60811287ff293b153e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# This file is a Tcl script to test out [incr Widgets] Panedwindow class.
# It is organized in the standard fashion for Tcl tests with the following
# notation for test case labels:
#
#   1.x - Construction/Destruction tests
#   2.x - Configuration option tests
#   3.x - Method tests
#
# Copyright (c) 1995 DSC Technologies Corporation
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# @(#) $Id$

package require Iwidgets 3.0

if {[string compare test [info procs test]] == 1} {
    source defs
}

wm geometry . {}
raise .

set c 1
set o 1
set m 1

#
# Initial construction test
#
test Panedwindow-1.$c {Panedwindow construction} {
    iwidgets::Panedwindow .pw -width 200 -height 200
    .pw add top
    .pw add bottom
    pack .pw -fill both -expand yes
    update 
} {}

incr c

#
# Option tests which are successful.
#
test Panedwindow-2.$o {configuration option} {
    llength [.pw configure]
} {12}

incr o

foreach test {
    {-background #d9d9d9 #d9d9d9} 
    {-cursor gumby gumby} 
    {-height 300 300} 
    {-orient vertical vertical} 
    {-sashborderwidth 3 3} 
    {-sashcursor arrow arrow} 
    {-sashheight 12 12} 
    {-sashindent -20 -20} 
    {-sashwidth 12 12} 
    {-thickness 5 5} 
    {-orient horizontal horizontal} 
    {-width 300 300}} {
	set option [lindex $test 0]
	test Panedwindow-2.$o "configuration options, $option" {
	    .pw configure $option [lindex $test 1]
	    lindex [.pw configure $option] 4
	} [lindex $test 2]
	update 
	incr o
}

#
# Method tests which are successful.
#
foreach test {
    {{.pw index 0} {0}}
    {{.pw index end} {1}}
    {{.pw index top} {0}}
    {{.pw index b*} {1}}
    {{.pw childsite 0} {.pw.pane0.childsite}}
    {{.pw childsite end} {.pw.pane1.childsite}}
    {{.pw childsite 1} {.pw.pane1.childsite}}
    {{.pw childsite} {.pw.pane0.childsite .pw.pane1.childsite}}
    {{.pw fraction 25 75} {}}
    {{.pw add middle -margin 10 -minimum 10} {.pw.pane2}}
    {{.pw delete middle} {}}
    {{.pw insert 1 middle} {.pw.pane3}}
    {{.pw fraction 20 30 50} {}}
    {{.pw reset} {}}
    {{.pw hide end} {}}
    {{.pw show bottom} {}}
    {{.pw paneconfigure 0 -minimum} {-minimum minimum Minimum 10 10}}
    {{.pw paneconfigure end -margin 10} {}}} {
	set method [lindex [lindex $test 0] 1]
	test Panedwindow-3.$m "object methods, $method" {
	    list [catch {eval [lindex $test 0]} msg] $msg
	} [list 0 [lindex $test 1]]
	update 
	incr m
}

#
# Method tests which fail and produce errors
#
foreach test {
    {{.pw index 5} {Panedwindow index "5" is out of range}}
    {{.pw index bogus} {bad Panedwindow index "bogus": must be number, end, or pattern}}
    {{.pw fraction 10 20 30} {bad fraction arguments "10 20 30": they should add up to 100}}
    {{.pw fraction 10 20} {wrong # args: should be ".pw fraction percentage percentage ?percentage ...?", where the number of percentages is 3 and equal 100}}} {
	set method [lindex [lindex $test 0] 1]
	test Panedwindow-3.$m "object methods, $method" {
	    list [catch {eval [lindex $test 0]} msg] $msg
	} [list 1 [lindex $test 1]]
	incr m
}

#
# Conclusion of constrcution/destruction tests
#
test Panedwindow-1.$c {Panedwindow destruction} {
    destroy .pw
    update 
} {}

incr c

test Panedwindow-1.$c {Panedwindow construction} {
    iwidgets::panedwindow .pw -width 200 -height 300 
    .pw add pane0
    .pw add pane1
    .pw add pane2
    .pw add pane3
    foreach pane [.pw childsite] {
	button $pane.b -text $pane -relief raised -borderwidth 3
	pack $pane.b -fill both -expand yes
    }
    .pw fraction 20 20 30 30
    pack .pw -fill both -expand yes
    update 
} {}

incr c

test Panedwindow-1.$c {Panedwindow destruction} {
    destroy .pw
    update 
} {}

incr c

test Panedwindow-1.$c {Panedwindow destruction} {
    iwidgets::panedwindow .pw
    pack .pw
    destroy .pw
    update 
} {}