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

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/openlayers/tests/Strategy.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
<html>
 
2
<head>
 
3
  <script src="../lib/OpenLayers.js"></script>
 
4
  <script type="text/javascript">
 
5
 
 
6
    function test_initialize(t) {
 
7
        t.plan(5);
 
8
        var options = {};
 
9
        var strategy = new OpenLayers.Strategy(options);
 
10
 
 
11
        t.ok(strategy instanceof OpenLayers.Strategy,
 
12
             "new OpenLayers.Strategy returns object" );
 
13
        t.eq(strategy.options, options, "constructor sets this.options");
 
14
        t.eq(strategy.active, false, "constructor sets this.active to false");
 
15
        t.eq(strategy.autoActivate, true, "constructor does not modify this.autoActivate");
 
16
        t.eq(strategy.autoDestroy, true, "constructor does not modify this.autoDestroy");
 
17
    }
 
18
 
 
19
    function test_activate(t) {
 
20
        t.plan(1);
 
21
        var options = {
 
22
            activate: function() {
 
23
                t.ok(true, "OpenLayer.Map.addLayer calls activate");
 
24
            }
 
25
        };
 
26
        
 
27
        var layer = new OpenLayers.Layer.Vector("Vector Layer", {
 
28
            strategies: [new OpenLayers.Strategy(options)]
 
29
        });
 
30
 
 
31
        var map = new OpenLayers.Map('map');
 
32
        map.addLayer(layer);
 
33
    }
 
34
    
 
35
    function test_destroy(t) {
 
36
        t.plan(3);
 
37
 
 
38
        var strategy = new OpenLayers.Strategy({
 
39
            deactivate: function() {
 
40
                t.ok(true, "destroy calls deactivate");
 
41
            },
 
42
            
 
43
            options: {foo: 'bar'},
 
44
            layer: 'foo'
 
45
        });
 
46
        strategy.destroy();
 
47
 
 
48
        t.eq(strategy.layer, null, "destroy nullify protocol.layer");
 
49
        t.eq(strategy.options, null, "destroy nullify protocol.options");
 
50
    }
 
51
 
 
52
    function test_activate(t) {
 
53
        t.plan(4);
 
54
        var strategy = new OpenLayers.Strategy({
 
55
            layer: 'foo'
 
56
        });
 
57
 
 
58
        var ret;
 
59
        ret = strategy.activate();
 
60
 
 
61
        t.eq(strategy.active, true, "activate sets this.active to true on first call");
 
62
        t.eq(ret, true, "activate returns true on first call");
 
63
 
 
64
        ret = strategy.activate();
 
65
 
 
66
        t.eq(strategy.active, true, "activate does not modify this.active on second call");
 
67
        t.eq(ret, false, "activate returns false on second call");
 
68
    }
 
69
 
 
70
    function test_deactivate(t) {
 
71
        t.plan(4);
 
72
        var strategy = new OpenLayers.Strategy({
 
73
            layer: 'foo'
 
74
        });
 
75
        strategy.activate();
 
76
 
 
77
        var ret;
 
78
        ret = strategy.deactivate();
 
79
 
 
80
        t.eq(strategy.active, false, "deactivate sets this.active to false on first call");
 
81
        t.eq(ret, true, "deactivate returns true on first call");
 
82
 
 
83
        ret = strategy.deactivate();
 
84
 
 
85
        t.eq(strategy.active, false, "deactivate does not modify this.active on second call");
 
86
        t.eq(ret, false, "deactivate returns false on second call");
 
87
    }
 
88
 
 
89
  </script>
 
90
</head>
 
91
<body>
 
92
    <div id="map"/>
 
93
</body>
 
94
</html>