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
95
96
|
<html>
<head>
<script src="OLLoader.js"></script>
<script type="text/javascript">
function test_Renderer_constructor(t) {
t.plan(2);
var el = document.body;
el.id = "foo";
var r = new OpenLayers.Renderer(el.id);
t.ok(r instanceof OpenLayers.Renderer, "new OpenLayers.Renderer returns Renderer object" );
t.ok(r.container == el, "renderer container is correctly set");
}
function test_Renderer_supported(t) {
t.plan(1);
var r = new OpenLayers.Renderer();
t.eq(r.supported(), false, "supported returns false by default");
}
function test_Renderer_setextent(t) {
t.plan(2);
var r = new OpenLayers.Renderer();
r.map = {};
var extent = new OpenLayers.Bounds(1,2,3,4);
r.resolution = 1;
r.setExtent(extent, true);
t.ok(r.extent.equals(extent), "extent is correctly set");
t.eq(r.resolution, null, "resolution nullified");
}
function test_Renderer_setsize(t) {
t.plan(2);
var r = new OpenLayers.Renderer();
var size = new OpenLayers.Size(1,2);
r.resolution = 1;
r.setSize(size);
t.ok(r.size.equals(size), "size is correctly set");
t.eq(r.resolution, null, "resolution nullified");
}
function test_Renderer_getresolution(t) {
t.plan(2);
var r = new OpenLayers.Renderer();
var map = new OpenLayers.Map("map");
r.map = map;
var resolution = r.getResolution();
t.eq(resolution, map.getResolution(), "resolution matches the map resolution");
t.eq(r.resolution, resolution, "resolution is correctly set");
}
function test_calculateFeatureDx(t) {
t.plan(4);
var r = new OpenLayers.Renderer();
r.extent = new OpenLayers.Bounds(177, -2, 183, 2);
var worldBounds = new OpenLayers.Bounds(-180,-90,180,90);
r.calculateFeatureDx(new OpenLayers.Bounds(179,-1,181,1), worldBounds);
t.eq(r.featureDx, 0, "no offset for feature inside extent");
r.calculateFeatureDx(new OpenLayers.Bounds(-181,-1,-179,1), worldBounds);
t.eq(r.featureDx, -360, "negative offset for feature on other end of world");
r.calculateFeatureDx(new OpenLayers.Bounds(359,-1,361,1), worldBounds);
t.eq(r.featureDx, 360, "positive offset for feature that is one world away");
r.calculateFeatureDx(new OpenLayers.Bounds(719,-1,721,1), worldBounds);
t.eq(r.featureDx, 720, "correct offset for feature that is two worlds away");
}
function test_Renderer_destroy(t) {
t.plan(5);
var r = new OpenLayers.Renderer();
r.container = document.createElement("div");
r.extent = new OpenLayers.Bounds(1,2,3,4);
r.size = new OpenLayers.Size(1,2);
r.resolution = 1;
r.map = {};
r.destroy();
t.eq(r.container, null, "container nullified");
t.eq(r.extent, null, "extent nullified");
t.eq(r.size, null, "size nullified");
t.eq(r.resolution, null, "resolution nullified");
t.eq(r.map, null, "map nullified");
}
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>
|