# This file is a Tcl script to test out [incr Widgets] Extfileselectiondialog 
# 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
#   4.x - Other 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: extfileselectiondialog.test,v 1.2 2000/06/06 01:37:28 wart Exp $

package require tcltest
namespace import -force ::tcltest::*

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 Extfileselectiondialog-1.$c {Extfileselectiondialog construction} {
    iwidgets::Extfileselectiondialog .fsd
    .fsd activate
} {}

incr c

#
# Option tests which are successful.
#
test Extfileselectiondialog-2.$o {configuration option} {
    llength [.fsd configure]
} {51}

incr o

foreach test {
    {-activebackground #ececec #ececec}
    {-borderwidth 2 2}
    {-childsitepos n n} 
    {-childsitepos s s} 
    {-childsitepos e e} 
    {-childsitepos w w} 
    {-childsitepos top top} 
    {-childsitepos bottom bottom} 
    {-cursor gumby gumby} 
    {-directory {..} {..}} 
    {-textbackground GhostWhite GhostWhite} 
    {-foreground Black Black}
    {-insertbackground Black Black} 
    {-insertborderwidth 1 1} 
    {-insertofftime 200 200} 
    {-insertontime  500 500} 
    {-insertwidth 3 3} 
    {-dirslabel "Dirs Label" "Dirs Label"} 
    {-dirson no no} 
    {-dirson yes yes} 
    {-fileslabel "Files Label" "Files Label"} 
    {-fileson no no} 
    {-directory ../tests ../tests} 
    {-mask *.* *.*} 
    {-nomatchstring {No Files} {No Files}} 
    {-fileson yes yes} 
    {-filetype any any} 
    {-filetype directory directory} 
    {-filetype regular regular} 
    {-filterlabel "Filter Label" "Filter Label"} 
    {-filteron no no} 
    {-filteron yes yes} 
    {-selectbackground #c3c3c3 #c3c3c3} 
    {-selectionlabel "Selection Label" "Selection Label"} 
    {-selectionon no no} 
    {-selectionon yes yes} 
    {-textfont -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*} 
    {-background #d9d9d9 #d9d9d9} 
    {-buttonboxpos n n} 
    {-buttonboxpos e e} 
    {-buttonboxpos w w} 
    {-buttonboxpos s s} 
    {-cursor gumby gumby} 
    {-modality global global} 
    {-modality application application} 
    {-modality none none} 
    {-padx 15 15} 
    {-pady 15 15} 
    {-separator off off} 
    {-thickness 4 4} 
    {-separator on on} 
    {-title Extfileselectiondialog Extfileselectiondialog}} {
	set option [lindex $test 0]
	test Extfileselectiondialog-2.$o "configuration options, $option" {
	    .fsd configure $option [lindex $test 1]
	    lindex [.fsd configure $option] 4
	} [lindex $test 2]
	update
	incr o
}

#
# Option tests which fail and produce errors.
#
foreach test {
  {-directory bogus {bad directory option "bogus": directory does not exist}}
  {-filetype bogus {bad filetype option "bogus": should be regular, directory, or any}}} {
	set option [lindex $test 0]
        test FileSelectionBox-2.$o "configuration options, $option" {
	    list [catch {.fsd configure $option [lindex $test 1]} msg] $msg
	} [list 1 [lindex $test 2]]
	incr o
}

#
# Method tests which are successful.
#
foreach test {
    {{.fsd childsite} {.fsd.shellchildsite.dschildsite.fsb.fsbchildsite}}
    {{.fsd hide Help} {}}
    {{.fsd hide Cancel} {}}
    {{.fsd default Apply} {}}
    {{.fsd show Cancel} {}}
    {{.fsd deactivate} {}}} {
	set method [lindex [lindex $test 0] 1]
	test Extfileselectiondialog-3.$m "object methods, $method" {
	    list [catch {eval [lindex $test 0]} msg] $msg
	} [list 0 [lindex $test 1]]
	update
	incr m
}

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

incr c

test Extfileselectiondialog-1.$c {Extfileselectiondialog construction} {
    iwidgets::extfileselectiondialog .fsd
    update
} {}

incr c

test Extfileselectiondialog-1.$c {Extfileselectiondialog destruction} {
    destroy .fsd
    update
} {}

incr c

test Extfileselectiondialog-1.$c {Extfileselectiondialog destruction} {
    iwidgets::extfileselectiondialog .fsd
    destroy .fsd
    update
} {}

#
# Childsite tests
#
incr o

test Extfileselectiondialog-1.$o {Extfileselectiondialog -childsitepos} {
    iwidgets::extfileselectiondialog .fsd
    .fsd activate
    update
    label [.fsd childsite].lb -background red -text CS
    pack [.fsd childsite].lb -fill both -expand yes
    update

    .fsd configure -childsitepos n
    update
    .fsd configure -childsitepos s
    update
    .fsd configure -childsitepos e
    update
    .fsd configure -childsitepos w
    update
    .fsd configure -childsitepos top
    update
    .fsd configure -childsitepos bottom
    update
    .fsd deactivate
    update
    destroy .fsd
} {}

::tcltest::cleanupTests
exit
