source: branches/geomap/gui/test/geomapdataprovidertfs.test @ 5949

Last change on this file since 5949 was 5949, checked in by dkearney, 7 years ago

adding data provider and layer objects, updating mapviewer to remove layers from client and server.

File size: 6.7 KB
Line 
1# Commands covered:
2#   Rappture::GeoMapDataProviderTFS
3#
4# This file contains a collection of tests for one of the Rappture Tcl
5# commands.  Sourcing this file into Tcl runs the tests and
6# generates output for errors.  No output means no errors were found.
7#
8# ======================================================================
9# AUTHOR:  Derrick Kearney, Purdue University
10# Copyright (c) 2004-2015  HUBzero Foundation, LLC
11#
12# See the file "license.terms" for information on usage and redistribution
13# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14
15
16if {[lsearch [namespace children] ::tcltest] == -1} {
17    package require tcltest
18    package require RapptureGUI
19    namespace import -force ::tcltest::*
20}
21catch {unset lib}
22
23proc check {var size} {
24    set l [llength $var]
25    if {$l != $size} {
26        return "length mismatch: should have been $size, was $l"
27    }
28    for {set i 0} {$i < $size} {set i [expr $i+1]} {
29        set j [lindex $var $i]
30        if {$j != "item $i"} {
31            return "element $i should have been \"item $i\", was \"$j\""
32        }
33    }
34    return ok
35}
36
37# temporary class for testing protected methods
38itcl::class TestDataProviderTFS {
39    inherit Rappture::GeoMapDataProviderTFS
40
41    constructor {type url format args} {
42        Rappture::GeoMapDataProviderTFS::constructor $type $url $format
43    } {
44        eval configure $args
45    }
46    destructor {
47        # empty
48    }
49    public method do { args } {eval $args}
50}
51
52#----------------------------------------------------------
53#----------------------------------------------------------
54# constructor command
55# Rappture::GeoMapDataProviderTFS <name> <type> <url> <format>
56#----------------------------------------------------------
57test geomapdataprovidertfs-1.1 {Rappture::GeoMapDataProviderTFS, 0 arguments} {
58    list [catch {Rappture::GeoMapDataProviderTFS} msg] $msg
59} {0 {}}
60
61
62test geomapdataprovidertfs-1.2 {Rappture::GeoMapDataProviderTFS, 1 arguments} {
63    list [catch {Rappture::GeoMapDataProviderTFS name "line"} msg] $msg
64} {1 {wrong # args: should be "::Rappture::GeoMapDataProviderTFS name type url format ?arg arg ...?"}}
65
66
67test geomapdataprovidertfs-1.3 {Rappture::GeoMapDataProviderTFS, 2 arguments} {
68    list [catch {Rappture::GeoMapDataProviderTFS name "line" "http://myurl.com/"} msg] $msg
69} {1 {wrong # args: should be "::Rappture::GeoMapDataProviderTFS name type url format ?arg arg ...?"}}
70
71
72test geomapdataprovidertfs-1.4 {
73    Rappture::GeoMapDataProviderTFS, name type url format
74} -body {
75    list [catch {Rappture::GeoMapDataProviderTFS name "line" "http://myurl.com/" "json"} msg] $msg
76} -cleanup {
77    catch {itcl::delete object name} err
78} -result {0 name}
79
80
81#----------------------------------------------------------
82# Type command
83# $dp Type
84# $dp Type <type>
85#----------------------------------------------------------
86test geomapdataprovidertfs-2.1 {Type, 0 arguments} {
87    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
88    list [catch {$dp do Type} msg] $msg
89} {0 line}
90
91test geomapdataprovidertfs-2.2 {Type, set type to "icon"} {
92    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
93    list [catch {$dp do Type "icon"} msg] $msg
94} {0 icon}
95
96test geomapdataprovidertfs-2.3 {Type, set type to "line"} {
97    set dp [TestDataProviderTFS #auto "icon" {http://myurl.com/} "json"]
98    list [catch {$dp do Type "line"} msg] $msg
99} {0 line}
100
101test geomapdataprovidertfs-2.4 {Type, set type to "point"} {
102    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
103    list [catch {$dp do Type "point"} msg] $msg
104} {0 point}
105
106test geomapdataprovidertfs-2.5 {Type, set type to "polygon"} {
107    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
108    list [catch {$dp do Type "polygon"} msg] $msg
109} {0 polygon}
110
111test geomapdataprovidertfs-2.6 {Type, set type to "text"} {
112    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
113    list [catch {$dp do Type "text"} msg] $msg
114} {0 text}
115
116test geomapdataprovidertfs-2.7 {Type, set type to "image"} {
117    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
118    list [catch {$dp do Type "image"} msg] $msg
119} {1 {bad value "image": should be one of "icon line point polygon text"}}
120
121test geomapdataprovidertfs-2.8 {Type, set type to "elevation"} {
122    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
123    list [catch {$dp do Type "elevation"} msg] $msg
124} {1 {bad value "elevation": should be one of "icon line point polygon text"}}
125
126test geomapdataprovidertfs-2.9 {Type, set type to "feature"} {
127    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
128    list [catch {$dp do Type "feature"} msg] $msg
129} {1 {bad value "feature": should be one of "icon line point polygon text"}}
130
131test geomapdataprovidertfs-2.10 {Type, set type to "badname"} {
132    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
133    list [catch {$dp do Type "badname"} msg] $msg
134} {1 {bad value "badname": should be one of "icon line point polygon text"}}
135
136test geomapdataprovidertfs-2.11 {Type, set type to ""} {
137    set dp [TestDataProviderTFS #auto "line" {http://myurl.com/} "json"]
138    list [catch {$dp do Type ""} msg] $msg
139} {1 {bad value "": should be a non-empty string}}
140
141test geomapdataprovidertfs-2.12 {Type, set type to "line" and retrieve type} {
142    set dp [TestDataProviderTFS #auto "icon" {http://myurl.com/} "json"]
143    $dp do Type "line"
144    list [catch {$dp do Type} msg] $msg
145} {0 line}
146
147
148#----------------------------------------------------------
149# format command
150# $dp format
151# $dp format <name>
152#----------------------------------------------------------
153test geomapdataprovidertfs-3.1 {format, 0 arguments} {
154    set dp [Rappture::GeoMapDataProviderTFS #auto "line" "http://myurl.com/" "json"]
155    list [catch {$dp format} msg] $msg
156} {0 json}
157
158test geomapdataprovidertfs-3.2 {format, 1 arguments} {
159    set dp [Rappture::GeoMapDataProviderTFS #auto "line" "http://myurl.com/" "json"]
160    list [catch {$dp format "gml"} msg] $msg
161} {0 gml}
162
163test geomapdataprovidertfs-3.3 {format, empty string} {
164    set dp [Rappture::GeoMapDataProviderTFS #auto "line" "http://myurl.com/" "json"]
165    list [catch {$dp format ""} msg] $msg
166} {1 {bad value "": should be a non-empty string}}
167
168
169#----------------------------------------------------------
170# exportToBltTree
171# $dp exportToBltTree $tree
172#----------------------------------------------------------
173
174test geomapdataprovidertfs-4.1 {exportToBltTree, } {
175    set dp [Rappture::GeoMapDataProviderTFS #auto "line" {http://myurl.com/} "json"]
176    set tree [blt::tree create]
177    $dp exportToBltTree $tree
178    $tree dump root
179} {-1 0 ::tree0 {type line driver tfs cache true attribution {} tfs.url http://myurl.com/ tfs.format json} {}
180}
181
182
183# TODO:
184
185::tcltest::cleanupTests
186return
Note: See TracBrowser for help on using the repository browser.