3 <script src="../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_initialize(t) {
9 var strategy = new OpenLayers.Strategy(options);
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");
19 function test_activate(t) {
22 activate: function() {
23 t.ok(true, "OpenLayer.Map.addLayer calls activate");
27 var layer = new OpenLayers.Layer.Vector("Vector Layer", {
28 strategies: [new OpenLayers.Strategy(options)]
31 var map = new OpenLayers.Map('map');
35 function test_destroy(t) {
38 var strategy = new OpenLayers.Strategy({
39 deactivate: function() {
40 t.ok(true, "destroy calls deactivate");
43 options: {foo: 'bar'},
48 t.eq(strategy.layer, null, "destroy nullify protocol.layer");
49 t.eq(strategy.options, null, "destroy nullify protocol.options");
52 function test_activate(t) {
54 var strategy = new OpenLayers.Strategy({
59 ret = strategy.activate();
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");
64 ret = strategy.activate();
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");
70 function test_deactivate(t) {
72 var strategy = new OpenLayers.Strategy({
78 ret = strategy.deactivate();
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");
83 ret = strategy.deactivate();
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");