OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [tests/] [general/] [filebox.tcl] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# filebox.tcl --
2
#
3
#       Tests the File selection box and dialog widget.
4
#
5
# Copyright (c) 1996, Expert Interface Technologies
6
#
7
# See the file "license.terms" for information on usage and redistribution
8
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9
#
10
 
11
proc About {} {
12
    return "Testing the (Ex)FileSelectBox and (Ex)FileSelectDialog widgets."
13
}
14
 
15
proc FdTest_GetFile {args} {
16
    global fdTest_selected
17
 
18
    set fdTest_selected [tixEvent value]
19
}
20
 
21
proc Test {} {
22
    global fdTest_fullPath
23
 
24
    if [tixStrEq [tix platform] "unix"] {
25
        set fdTest_fullPath /etc/passwd
26
    } else {
27
        set fdTest_fullPath C:\\Windows\\System.ini
28
    }
29
 
30
    Test_FileSelectBox
31
    Test_FileSelectDialog
32
 
33
    Test_ExFileSelectBox
34
    Test_ExFileSelectDialog
35
}
36
 
37
proc Test_FileSelectBox {} {
38
    global fdTest_selected fdTest_fullPath
39
 
40
    TestBlock filebox-1.1 {FileSelectBox} {
41
        set w [tixFileSelectBox .f -command FdTest_GetFile]
42
        pack $w -expand yes -fill both
43
        update
44
 
45
        InvokeComboBoxByKey [$w subwidget selection] "$fdTest_fullPath"
46
        Assert {[tixStrEq $fdTest_selected "$fdTest_fullPath"]}
47
    }
48
    catch {
49
        destroy $w
50
    }
51
}
52
 
53
proc Test_FileSelectDialog {} {
54
    global fdTest_selected fdTest_fullPath
55
 
56
    TestBlock filebox-2.1 {FileSelectDialog} {
57
        set w [tixFileSelectDialog .f -command FdTest_GetFile]
58
        $w popup
59
        update
60
 
61
        InvokeComboBoxByKey [$w subwidget fsbox subwidget selection] \
62
            "$fdTest_fullPath"
63
        Assert {[tixStrEq $fdTest_selected "$fdTest_fullPath"]}
64
    }
65
    catch {
66
        destroy $w
67
    }
68
}
69
 
70
proc Test_ExFileSelectBox {} {
71
    global fdTest_selected fdTest_fullPath
72
 
73
    TestBlock filebox-3.1 {ExFileSelectBox} {
74
        set w [tixExFileSelectBox .f -command FdTest_GetFile]
75
        pack $w -expand yes -fill both
76
        update
77
 
78
        $w subwidget file config -selection "$fdTest_fullPath" \
79
            -value "$fdTest_fullPath"
80
        Assert {[tixStrEq $fdTest_selected "$fdTest_fullPath"]}
81
    }
82
 
83
    TestBlock filebox-3.2 {Keyboard input in ExFileSelectBox entry subwidget} {
84
        set dirCbx  [$w subwidget dir]
85
        set fileCbx [$w subwidget file]
86
        set okBtn   [$w subwidget ok]
87
 
88
        foreach file {Foo bar "Foo Bar"} {
89
            set fdTest_selected ""
90
 
91
            InvokeComboBoxByKey $fileCbx $file
92
            set fullPath [tixFSJoin [$dirCbx cget -value] $file]
93
            update
94
 
95
            Assert {[tixStrEq "$fdTest_selected" "$fullPath"]}
96
        }
97
    }
98
 
99
    TestBlock filebox-3.3 {Keyboard and then press OK} {
100
        foreach file {bar "Foo Bar"} {
101
            set fdTest_selected ""
102
 
103
            SetComboBoxByKey $fileCbx $file
104
            Click $okBtn
105
            set fullPath [tixFSJoin [$dirCbx cget -value] $file]
106
            update
107
 
108
            Assert {[tixStrEq "$fdTest_selected" "$fullPath"]}
109
        }
110
    }
111
 
112
    catch {
113
        destroy $w
114
    }
115
}
116
 
117
proc Test_ExFileSelectDialog {} {
118
    global fdTest_selected fdTest_fullPath
119
 
120
    TestBlock filebox-4.1 {ExFileSelectDialog} {
121
        set w [tixExFileSelectDialog .f -command FdTest_GetFile]
122
        $w popup
123
        update
124
 
125
        InvokeComboBoxByKey [$w subwidget fsbox subwidget file] \
126
            $fdTest_fullPath
127
        Assert {[tixStrEq $fdTest_selected "$fdTest_fullPath"]}
128
    }
129
 
130
    catch {
131
        destroy $w
132
    }
133
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.