# Commands covered: # Rappture::GeoMapDataProviderTFS # # This file contains a collection of tests for one of the Rappture Tcl # commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # ====================================================================== # AUTHOR: Derrick Kearney, Purdue University # Copyright (c) 2004-2015 HUBzero Foundation, LLC # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest package require RapptureGUI namespace import -force ::tcltest::* } catch {unset lib} proc check {var size} { set l [llength $var] if {$l != $size} { return "length mismatch: should have been $size, was $l" } for {set i 0} {$i < $size} {set i [expr $i+1]} { set j [lindex $var $i] if {$j != "item $i"} { return "element $i should have been \"item $i\", was \"$j\"" } } return ok } # temporary class for testing protected methods itcl::class TestDataProviderTFS { inherit Rappture::GeoMapDataProviderTFS constructor {type url format args} { Rappture::GeoMapDataProviderTFS::constructor $type $url $format } { eval configure $args } destructor { # empty } public method do { args } {eval $args} } #---------------------------------------------------------- #---------------------------------------------------------- # constructor command # Rappture::GeoMapDataProviderTFS #---------------------------------------------------------- test geomapdataprovidertfs-1.1 {Rappture::GeoMapDataProviderTFS, 0 arguments} { list [catch {Rappture::GeoMapDataProviderTFS} msg] $msg } {0 {}} test geomapdataprovidertfs-1.2 {Rappture::GeoMapDataProviderTFS, 1 arguments} { list [catch {Rappture::GeoMapDataProviderTFS name "line"} msg] $msg } {1 {wrong # args: should be "::Rappture::GeoMapDataProviderTFS name type url format ?arg arg ...?"}} test geomapdataprovidertfs-1.3 {Rappture::GeoMapDataProviderTFS, 2 arguments} { list [catch {Rappture::GeoMapDataProviderTFS name "line" "http://myurl.com/"} msg] $msg } {1 {wrong # args: should be "::Rappture::GeoMapDataProviderTFS name type url format ?arg arg ...?"}} test geomapdataprovidertfs-1.4 { Rappture::GeoMapDataProviderTFS, name type url format } -body { list [catch {Rappture::GeoMapDataProviderTFS name "line" "http://myurl.com/" "json"} msg] $msg } -cleanup { catch {itcl::delete object name} err } -result {0 name} #---------------------------------------------------------- # Type command # $dp Type # $dp Type #---------------------------------------------------------- test geomapdataprovidertfs-2.1 {Type, 0 arguments} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type} msg] $msg } {0 line} test geomapdataprovidertfs-2.2 {Type, set type to "icon"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "icon"} msg] $msg } {0 icon} test geomapdataprovidertfs-2.3 {Type, set type to "line"} { set dp [TestDataProviderTFS #auto "icon" {http://myurl.com/} "json"] list [catch {$dp do Type "line"} msg] $msg } {0 line} test geomapdataprovidertfs-2.4 {Type, set type to "point"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "point"} msg] $msg } {0 point} test geomapdataprovidertfs-2.5 {Type, set type to "polygon"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "polygon"} msg] $msg } {0 polygon} test geomapdataprovidertfs-2.6 {Type, set type to "text"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "text"} msg] $msg } {0 text} test geomapdataprovidertfs-2.7 {Type, set type to "image"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "image"} msg] $msg } {1 {bad value "image": should be one of "icon line point polygon text"}} test geomapdataprovidertfs-2.8 {Type, set type to "elevation"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "elevation"} msg] $msg } {1 {bad value "elevation": should be one of "icon line point polygon text"}} test geomapdataprovidertfs-2.9 {Type, set type to "feature"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "feature"} msg] $msg } {1 {bad value "feature": should be one of "icon line point polygon text"}} test geomapdataprovidertfs-2.10 {Type, set type to "badname"} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type "badname"} msg] $msg } {1 {bad value "badname": should be one of "icon line point polygon text"}} test geomapdataprovidertfs-2.11 {Type, set type to ""} { set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"] list [catch {$dp do Type ""} msg] $msg } {1 {bad value "": should be a non-empty string}} test geomapdataprovidertfs-2.12 {Type, set type to "line" and retrieve type} { set dp [TestDataProviderTFS #auto "icon" {http://myurl.com/} "json"] $dp do Type "line" list [catch {$dp do Type} msg] $msg } {0 line} #---------------------------------------------------------- # format command # $dp format # $dp format #---------------------------------------------------------- test geomapdataprovidertfs-3.1 {format, 0 arguments} { set dp [Rappture::GeoMapDataProviderTFS #auto "line" "http://myurl.com/" "json"] list [catch {$dp format} msg] $msg } {0 json} test geomapdataprovidertfs-3.2 {format, 1 arguments} { set dp [Rappture::GeoMapDataProviderTFS #auto "line" "http://myurl.com/" "json"] list [catch {$dp format "gml"} msg] $msg } {0 gml} test geomapdataprovidertfs-3.3 {format, empty string} { set dp [Rappture::GeoMapDataProviderTFS #auto "line" "http://myurl.com/" "json"] list [catch {$dp format ""} msg] $msg } {1 {bad value "": should be a non-empty string}} #---------------------------------------------------------- # exportToBltTree # $dp exportToBltTree $tree #---------------------------------------------------------- test geomapdataprovidertfs-4.1 {exportToBltTree, } { set dp [Rappture::GeoMapDataProviderTFS #auto "line" {http://myurl.com/} "json"] set tree [blt::tree create] $dp exportToBltTree $tree $tree dump root } {-1 0 {{}} {type line driver tfs cache true attribution {} tfs.url http://myurl.com/ tfs.format json} {} } # TODO: ::tcltest::cleanupTests return