File: Strategy.html

package info (click to toggle)
openlayers 2.13.1%2Bds2-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 67,180 kB
  • ctags: 11,977
  • sloc: xml: 7,435; python: 891; sh: 44; makefile: 23
file content (94 lines) | stat: -rw-r--r-- 2,787 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<html>
<head>
  <script src="OLLoader.js"></script>
  <script type="text/javascript">

    function test_initialize(t) {
        t.plan(5);
        var options = {};
        var strategy = new OpenLayers.Strategy(options);

        t.ok(strategy instanceof OpenLayers.Strategy,
             "new OpenLayers.Strategy returns object" );
        t.eq(strategy.options, options, "constructor sets this.options");
        t.eq(strategy.active, false, "constructor sets this.active to false");
        t.eq(strategy.autoActivate, true, "constructor does not modify this.autoActivate");
        t.eq(strategy.autoDestroy, true, "constructor does not modify this.autoDestroy");
    }

    function test_activate(t) {
        t.plan(1);
        var options = {
            activate: function() {
                t.ok(true, "OpenLayer.Map.addLayer calls activate");
            }
        };
        
        var layer = new OpenLayers.Layer.Vector("Vector Layer", {
            strategies: [new OpenLayers.Strategy(options)]
        });

        var map = new OpenLayers.Map('map');
        map.addLayer(layer);
    }
    
    function test_destroy(t) {
        t.plan(3);

        var strategy = new OpenLayers.Strategy({
            deactivate: function() {
                t.ok(true, "destroy calls deactivate");
            },
            
            options: {foo: 'bar'},
            layer: 'foo'
        });
        strategy.destroy();

        t.eq(strategy.layer, null, "destroy nullify protocol.layer");
        t.eq(strategy.options, null, "destroy nullify protocol.options");
    }

    function test_activate(t) {
        t.plan(4);
        var strategy = new OpenLayers.Strategy({
            layer: 'foo'
        });

        var ret;
        ret = strategy.activate();

        t.eq(strategy.active, true, "activate sets this.active to true on first call");
        t.eq(ret, true, "activate returns true on first call");

        ret = strategy.activate();

        t.eq(strategy.active, true, "activate does not modify this.active on second call");
        t.eq(ret, false, "activate returns false on second call");
    }

    function test_deactivate(t) {
        t.plan(4);
        var strategy = new OpenLayers.Strategy({
            layer: 'foo'
        });
        strategy.activate();

        var ret;
        ret = strategy.deactivate();

        t.eq(strategy.active, false, "deactivate sets this.active to false on first call");
        t.eq(ret, true, "deactivate returns true on first call");

        ret = strategy.deactivate();

        t.eq(strategy.active, false, "deactivate does not modify this.active on second call");
        t.eq(ret, false, "deactivate returns false on second call");
    }

  </script>
</head>
<body>
    <div id="map"/>
</body>
</html>