# This file is a Tcl script to test out [incr Widgets] Disjointlistbox 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: disjointlistbox.test,v 1.5 2017/07/07 18:29:13 dgp Exp $

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

if [catch {package require Iwidgets 4.0}] {
  # Let's try modifying the auto_path.  Note that the IWIDGETS_LIBRARY
  # env var is initialized in the Makefile when doing a 'make test'.
  # If sourcing this file independently, this variable must be set manually.
  if ![info exists env(IWIDGETS_LIBRARY)] {
    error "Unable to locate Iwidgets package.  Set your IWIDGETS_LIBRARY\
      environment\nvariable to the directory that contains iwidgets.tcl"
  }
  lappend auto_path $env(IWIDGETS_LIBRARY)
  package require Iwidgets 4.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 Disjointlistbox-1.$c {Disjointlistbox construction} {
    iwidgets::Disjointlistbox .lf
    pack .lf -fill both -expand yes
    update 
} {}

incr c

#
# Option tests which are successful.
#
test Disjointlistbox-2.$o {configuration option} {
    llength [.lf configure]
} {30}

incr o

foreach test {
    {-lhslabeltext "LHS" "LHS"}
    {-lhslabeltext "Available" "Available"}
    {-lhslabeltext "Don't Print" "Don't Print"}
    {-rhslabeltext "RHS" "RHS"}
    {-rhslabeltext "Current" "Current"}
    {-rhslabeltext "Print" "Print"}
    {-lhssortoption "none" "none"}
    {-rhssortoption "none" "none"}
    {-buttonplacement bottom bottom}
    {-buttonplacement center center}
    } {
	set option [lindex $test 0]
	test Disjointlistbox-1.$o "configuration options, $option" {
	    .lf configure $option [lindex $test 1]
	    lindex [.lf configure $option] 4
	} [lindex $test 2]
        update 
	incr o
    }

#
# Method tests which are successful.
#
test Disjointlistbox-1.$c {Disjointlistbox destruction} {
    destroy .lf
    update 
} {}

incr c

test Disjointlistbox-1.$c {Disjointlistbox construction} {
    iwidgets::disjointlistbox .lf -lhslabeltext "Don't Print" -rhslabeltext "Print"
    pack .lf -fill both -expand yes
    update 
} {}

incr c

test Disjointlistbox-1.$c {Disjointlistbox destruction} {
    destroy .lf
    update 
} {}

incr c

test Disjointlistbox-1.$c {Disjointlistbox construction} {
    iwidgets::disjointlistbox .lf 
    pack .lf 
    destroy .lf
    update 
} {}

::tcltest::cleanupTests
exit
