~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/mapfish/tests/core/test_Util.html

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html>
 
2
<html debug="true">
 
3
  <head>
 
4
    <link rel="stylesheet" type="text/css" href="../../ext/resources/css/ext-all.css" />
 
5
 
 
6
    <script type="text/javascript" src="../../../openlayers/lib/Firebug/firebug.js"></script>
 
7
    <script type="text/javascript" src="../../../openlayers/lib/OpenLayers.js"></script>
 
8
 
 
9
    <script type="text/javascript" src="../../../ext/adapter/ext/ext-base.js"></script>
 
10
    <script type="text/javascript" src="../../../ext/ext-all-debug.js"></script>
 
11
 
 
12
    <script type="text/javascript">
 
13
      // Because of a bug in Firefox 2 we need to specify the MapFish base path.
 
14
      // See https://bugzilla.mozilla.org/show_bug.cgi?id=351282
 
15
      var gMfLocation = "../../../mapfish/";
 
16
    </script>
 
17
    <script type="text/javascript" src="../../../mapfish/MapFish.js"></script>
 
18
 
 
19
    <script type="text/javascript"><!--
 
20
       
 
21
    function test_Util_getIconUrl(t) {
 
22
        t.plan(4);
 
23
 
 
24
        t.eq(
 
25
            mapfish.Util.getIconUrl("mapserv", {
 
26
                'layer': 'world'
 
27
            }),
 
28
            "mapserv?LAYER=world&RULE=world&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&WIDTH=16&HEIGHT=16",
 
29
            "getIconUrl correctly sets the ? if not present and correctly sets the default RULE parameter"
 
30
        );
 
31
 
 
32
        t.eq(
 
33
            mapfish.Util.getIconUrl("mapserv?", {
 
34
                'layer': 'world'
 
35
            }),
 
36
            "mapserv?LAYER=world&RULE=world&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&WIDTH=16&HEIGHT=16",
 
37
            "getIconUrl correctly uses the original WMS url if the ? is present"
 
38
        );
 
39
 
 
40
        t.eq(
 
41
            mapfish.Util.getIconUrl("mapserv?", {
 
42
                'layer': 'world',
 
43
                'rule': 'world_class'
 
44
            }),
 
45
            "mapserv?LAYER=world&RULE=world_class&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&WIDTH=16&HEIGHT=16",
 
46
            "getIconUrl correctly uses the rule parameter if present"
 
47
        );
 
48
        t.eq(
 
49
            mapfish.Util.getIconUrl("mapserv?map=toto", {
 
50
                'layer': 'world',
 
51
                'rule': 'world_class'
 
52
            }),
 
53
            "mapserv?map=toto&LAYER=world&RULE=world_class&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&WIDTH=16&HEIGHT=16",
 
54
            "getIconUrl creates a correct url if a ? was embedded"
 
55
        );
 
56
 
 
57
    }
 
58
 
 
59
 
 
60
    function test_Util_arrayEqual(t) {
 
61
        t.plan(9);
 
62
 
 
63
        var array1 = ['a', 'b', 'c'];
 
64
        var array2 = ['a', 'b', 'c'];
 
65
        t.eq(mapfish.Util.arrayEqual(array1, array2), true,
 
66
                     'arrayEqual correctly compares string arrays');
 
67
 
 
68
        var array1 = [1, 2, 3];
 
69
        var array2 = [1, 2, 3];
 
70
        t.eq(mapfish.Util.arrayEqual(array1, array2), true,
 
71
                     'arrayEqual correctly compares integer arrays');
 
72
 
 
73
        var array1 = ['1', '2', '3'];
 
74
        var array2 = [1, 2, 3];
 
75
        t.eq(mapfish.Util.arrayEqual(array1, array2), false,
 
76
                     'arrayEqual correctly compares arrays contents types');
 
77
 
 
78
        var array1 = null;
 
79
        var array2 = [1, 2, 3];
 
80
        t.eq(mapfish.Util.arrayEqual(array1, array2), false,
 
81
                     'arrayEqual correctly compares null with an array');
 
82
 
 
83
        var array1 = '123';
 
84
        var array2 = [1, 2, 3];
 
85
        t.eq(mapfish.Util.arrayEqual(array1, array2), false,
 
86
                     'arrayEqual correctly compares a string with an array');
 
87
 
 
88
        var array1 = ['a', 'b', 'c'];
 
89
        var array2 = ['a', 'b'];
 
90
        t.eq(mapfish.Util.arrayEqual(array1, array2), false,
 
91
                     'arrayEqual correctly compares arrays length');
 
92
 
 
93
        var array1 = ['a', 'b', 'c'];
 
94
        var array2 = ['a', 'b', 'd'];
 
95
        t.eq(mapfish.Util.arrayEqual(array1, array2), false,
 
96
                     'arrayEqual correctly compares arrays values');
 
97
 
 
98
        var array1 = [1, 2, [1, 2]];
 
99
        var array2 = [1, 2, [1, 2]];
 
100
        t.eq(mapfish.Util.arrayEqual(array1, array2), false,
 
101
                     'arrayEqual correctly returns false when comparing ' +
 
102
                     'nested arrays');
 
103
 
 
104
        var array1 = [1, 2, {a: 1}];
 
105
        var array2 = [1, 2, {a: 1}];
 
106
        t.eq(mapfish.Util.arrayEqual(array1, array2), false,
 
107
                     'arrayEqual correctly returns false when comparing ' +
 
108
                     'arrays contaning objects');
 
109
    }
 
110
 
 
111
--></script>
 
112
 
 
113
  </head>
 
114
  <body>
 
115
  </body>
 
116
</html>