source: branches/geomap/gui/test/geomapdataproviderwms.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: 5.9 KB
Line 
1# Commands covered:
2#   Rappture::GeoMapDataProviderWMS
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 TestDataProviderWMS {
39    inherit Rappture::GeoMapDataProviderWMS
40
41    constructor {url layers format args} {
42        Rappture::GeoMapDataProviderWMS::constructor $url $layers $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::GeoMapDataProviderWMS <name> <url> <layers> <format>
56#----------------------------------------------------------
57test geomapdataproviderwms-1.1 {Rappture::GeoMapDataProviderWMS, 0 arguments} {
58    list [catch {Rappture::GeoMapDataProviderWMS} msg] $msg
59} {0 {}}
60
61test geomapdataproviderwms-1.2 {Rappture::GeoMapDataProviderWMS, 1 arguments} {
62    list [catch {Rappture::GeoMapDataProviderWMS name "http://myurl.com/"} msg] $msg
63} {1 {wrong # args: should be "::Rappture::GeoMapDataProviderWMS name url layers format ?arg arg ...?"}}
64
65test geomapdataproviderwms-1.3 {Rappture::GeoMapDataProviderWMS, 2 arguments} {
66    list [catch {Rappture::GeoMapDataProviderWMS name "http://myurl.com/" "foo:bar"} msg] $msg
67} {1 {wrong # args: should be "::Rappture::GeoMapDataProviderWMS name url layers format ?arg arg ...?"}}
68
69test geomapdataproviderwms-1.4 {
70    Rappture::GeoMapDataProviderWMS, name url layers format
71} -body {
72    list [catch {Rappture::GeoMapDataProviderWMS name \
73        "http://myurl.com/" "foo:bar" "jpeg"} msg] $msg
74} -cleanup {
75    catch {itcl::delete object name} err
76} -result {0 name}
77
78
79#----------------------------------------------------------
80# layers command
81# $dp layers
82# $dp layers <name>
83#----------------------------------------------------------
84test geomapdataproviderwms-2.1 {layers, 0 arguments} {
85    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
86    list [catch {$dp layers} msg] $msg
87} {0 foo:bar}
88
89test geomapdataproviderwms-2.2 {layers, 1 arguments} {
90    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
91    list [catch {$dp layers "ident:name"} msg] $msg
92} {0 ident:name}
93
94test geomapdataproviderwms-2.3 {layers, empty string} {
95    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
96    list [catch {$dp layers ""} msg] $msg
97} {1 {bad value "": should be a non-empty list of strings}}
98
99
100#----------------------------------------------------------
101# format command
102# $dp format
103# $dp format <name>
104#----------------------------------------------------------
105test geomapdataproviderwms-3.1 {format, 0 arguments} {
106    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
107    list [catch {$dp format} msg] $msg
108} {0 jpeg}
109
110test geomapdataproviderwms-3.2 {format, 1 arguments} {
111    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
112    list [catch {$dp format "png"} msg] $msg
113} {0 png}
114
115test geomapdataproviderwms-3.3 {format, empty string} {
116    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
117    list [catch {$dp format ""} msg] $msg
118} {1 {bad value "": should be a non-empty string}}
119
120
121#----------------------------------------------------------
122# exportToBltTree
123# $dp exportToBltTree $tree
124#----------------------------------------------------------
125
126test geomapdataproviderwms-4.1 {exportToBltTree, } {
127    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
128    set tree [blt::tree create]
129    $dp exportToBltTree $tree
130    $tree dump root
131} {-1 0 ::tree0 {type image driver wms cache true attribution {} wms.url http://myurl.com/ wms.layers foo:bar wms.format jpeg wms.transparent false} {}
132}
133
134#----------------------------------------------------------
135# transparent flag
136# $dp configure -transparent <bool>
137# $dp cget -transparent
138#----------------------------------------------------------
139test geomapdataproviderwms-5.1 {transparent, configure true} {
140    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
141    list [catch {$dp configure -transparent true} msg] $msg
142} {0 {}}
143
144test geomapdataproviderwms-5.2 {transparent, configure false} {
145    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
146    list [catch {$dp configure -transparent false} msg] $msg
147} {0 {}}
148
149test geomapdataproviderwms-5.3 {transparent, configure empty string} {
150    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
151    list [catch {$dp configure -transparent ""} msg] $msg
152} {1 {bad value "": should be a non-empty boolean}}
153
154test geomapdataproviderwms-5.4 {transparent, cget} {
155    set dp [Rappture::GeoMapDataProviderWMS #auto "http://myurl.com/" "foo:bar" "jpeg"]
156    list [catch {$dp cget -transparent} msg] $msg
157} {0 false}
158
159
160# TODO:
161
162::tcltest::cleanupTests
163return
164
Note: See TracBrowser for help on using the repository browser.