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

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/mapfish/tests/core/Searcher/test_Map.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
    function test_Map_initialize(t) {
 
21
        t.plan(6);
 
22
 
 
23
        var searcher, protocol;
 
24
 
 
25
        protocol = new OpenLayers.Protocol();
 
26
 
 
27
        // 3 tests
 
28
        searcher = new mapfish.Searcher.Map({
 
29
            protocol: protocol
 
30
        });
 
31
        t.eq(searcher.mode, mapfish.Searcher.Map.CLICK,
 
32
             "ctor sets mode to CLICK by default");
 
33
        t.eq(searcher.handler.CLASS_NAME, "OpenLayers.Handler.Click",
 
34
             "ctor creates a click handler");
 
35
        t.eq(searcher.protocol.CLASS_NAME, "OpenLayers.Protocol",
 
36
             "ctor sets protocol");
 
37
 
 
38
        // 1 test
 
39
        searcher = new mapfish.Searcher.Map({
 
40
            mode: mapfish.Searcher.Map.HOVER,
 
41
            protocol: protocol
 
42
        });
 
43
        t.eq(searcher.handler.CLASS_NAME, "OpenLayers.Handler.Hover",
 
44
             "ctor creates a hover handler");
 
45
 
 
46
        // 1 test
 
47
        searcher = new mapfish.Searcher.Map({
 
48
            mode: mapfish.Searcher.Map.BOX,
 
49
            protocol: protocol
 
50
        });
 
51
        t.eq(searcher.handler.CLASS_NAME, "OpenLayers.Handler.Box",
 
52
             "ctor creates a box handler");
 
53
 
 
54
        // 1 tests
 
55
        searcher = new mapfish.Searcher.Map({
 
56
            mode: mapfish.Searcher.Map.EXTENT,
 
57
            protocol: protocol
 
58
        });
 
59
        t.eq(searcher.handler, null,
 
60
             "ctor creates no handler");
 
61
    }
 
62
 
 
63
    function test_Map_getFilter(t) {
 
64
        t.plan(5);
 
65
 
 
66
        var protocol, extent, lonlat, res, searcher, filter;
 
67
 
 
68
        protocol = new OpenLayers.Protocol();
 
69
        extent = new OpenLayers.Bounds(1.0,2.0,3.0,4.0);
 
70
        lonlat = new OpenLayers.LonLat(4.0, 5.0);
 
71
        res = 5.0;
 
72
 
 
73
        searcher = new mapfish.Searcher.Map({
 
74
            protocol: protocol,
 
75
            map: {
 
76
                getLonLatFromViewPortPx: function() {
 
77
                    return lonlat;
 
78
                },
 
79
                getResolution: function() {
 
80
                    return res;
 
81
                },
 
82
                getExtent: function() {
 
83
                    return extent;
 
84
                }
 
85
            }
 
86
        });
 
87
 
 
88
        // 1 test
 
89
        searcher.position = new OpenLayers.Bounds(0, 0, 0, 0);
 
90
        filter = searcher.getFilter();
 
91
        t.eq(filter.CLASS_NAME, "OpenLayers.Filter.Spatial",
 
92
             "getFilter returns a spatial filter");
 
93
 
 
94
        // 3 tests
 
95
        searcher.position = new OpenLayers.Pixel(0, 0);
 
96
        filter = searcher.getFilter();
 
97
        t.eq(filter.lon, lonlat.lon,
 
98
             "getFilter returns a object with expected lon property");
 
99
        t.eq(filter.lat, lonlat.lat,
 
100
             "getFilter returns a object with expected lat property");
 
101
        t.eq(filter.tolerance, searcher.searchTolerance * res,
 
102
             "getFilter returns a object with expected tolerance property");
 
103
 
 
104
        // 1 test
 
105
        searcher.mode =  mapfish.Searcher.Map.EXTENT;
 
106
        searcher.position = null;
 
107
        filter = searcher.getFilter();        
 
108
        t.eq(filter.value.toBBOX(), extent.toBBOX(),
 
109
             "getFilter computes position value if null and mode is EXTENT");
 
110
    }
 
111
--></script>
 
112
 
 
113
  </head>
 
114
  <body>
 
115
  </body>
 
116
</html>