1 |
3032
|
perry
|
<html>
|
2 |
|
|
<head>
|
3 |
|
|
<script src="../lib/OpenLayers.js"></script>
|
4 |
|
|
<script type="text/javascript"><!--
|
5 |
|
|
var popup;
|
6 |
|
|
|
7 |
|
|
function test_01_Popup_default_constructor(t) {
|
8 |
|
|
t.plan( 8 );
|
9 |
|
|
|
10 |
|
|
var size = new OpenLayers.Size(OpenLayers.Popup.WIDTH,
|
11 |
|
|
OpenLayers.Popup.HEIGHT);
|
12 |
|
|
popup = new OpenLayers.Popup();
|
13 |
|
|
|
14 |
|
|
t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" );
|
15 |
|
|
t.ok(popup.id.startsWith("Popup"), "good default popup.id");
|
16 |
|
|
t.ok(popup.size.equals(size), "good default popup.size");
|
17 |
|
|
t.eq(popup.contentHTML, "", "good default popup.contentHTML");
|
18 |
|
|
t.eq(popup.backgroundColor, OpenLayers.Popup.COLOR, "good default popup.backgroundColor");
|
19 |
|
|
t.eq(popup.opacity, OpenLayers.Popup.OPACITY, "good default popup.opacity");
|
20 |
|
|
t.eq(popup.border, OpenLayers.Popup.BORDER, "good default popup.border");
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
var oldIndex = parseInt(popup.id.slice("Popup".length));
|
24 |
|
|
|
25 |
|
|
popup = new OpenLayers.Popup();
|
26 |
|
|
var newIndex = parseInt(popup.id.slice("Popup".length));
|
27 |
|
|
|
28 |
|
|
t.eq(newIndex, oldIndex + 1, "default id generator incrementing correctly");
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
function test_02_Popup_constructor (t) {
|
32 |
|
|
t.plan( 5 );
|
33 |
|
|
|
34 |
|
|
var id = "chicken";
|
35 |
|
|
var w = 500;
|
36 |
|
|
var h = 400;
|
37 |
|
|
var sz = new OpenLayers.Size(w,h);
|
38 |
|
|
var lon = 5;
|
39 |
|
|
var lat = 40;
|
40 |
|
|
var ll = new OpenLayers.LonLat(lon, lat);
|
41 |
|
|
var content = "foo";
|
42 |
|
|
|
43 |
|
|
popup = new OpenLayers.Popup(id,
|
44 |
|
|
ll,
|
45 |
|
|
sz,
|
46 |
|
|
content);
|
47 |
|
|
|
48 |
|
|
t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" );
|
49 |
|
|
t.eq(popup.id, id, "popup.id set correctly");
|
50 |
|
|
t.ok(popup.lonlat.equals(ll), "popup.lonlat set correctly");
|
51 |
|
|
t.ok(popup.size.equals(sz), "popup.size set correctly");
|
52 |
|
|
t.eq(popup.contentHTML, content, "contentHTML porpoerty of set correctly");
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
function test_03_Popup_draw(t) {
|
56 |
|
|
|
57 |
|
|
t.plan( 11 );
|
58 |
|
|
|
59 |
|
|
var id = "chicken";
|
60 |
|
|
var x = 50;
|
61 |
|
|
var y = 100;
|
62 |
|
|
var w = 500;
|
63 |
|
|
var h = 400;
|
64 |
|
|
var content = "charlie";
|
65 |
|
|
var color = "red";
|
66 |
|
|
var opacity = 0.5;
|
67 |
|
|
var border = "1px solid";
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
popup = new OpenLayers.Popup(id);
|
71 |
|
|
popup.setSize(new OpenLayers.Size(w, h));
|
72 |
|
|
popup.setContentHTML(content);
|
73 |
|
|
popup.setBackgroundColor(color);
|
74 |
|
|
popup.setOpacity(opacity);
|
75 |
|
|
popup.setBorder(border);
|
76 |
|
|
popup.draw(new OpenLayers.Pixel(x, y));
|
77 |
|
|
|
78 |
|
|
t.eq(popup.div.id, id + "_div", "popup.div.id set correctly");
|
79 |
|
|
t.eq(popup.div.style.left, x + "px", "left position of popup.div set correctly");
|
80 |
|
|
t.eq(popup.div.style.top, y + "px", "top position of popup.div set correctly");
|
81 |
|
|
t.eq(popup.div.style.width, w + "px", "width position of popup.div set correctly");
|
82 |
|
|
t.eq(popup.div.style.height, h + "px", "heightposition of popup.div set correctly");
|
83 |
|
|
t.eq(popup.div.innerHTML, content, "good default popup.contentHTML");
|
84 |
|
|
t.eq(popup.div.style.backgroundColor, color, "good default popup.backgroundColor");
|
85 |
|
|
|
86 |
|
|
if (navigator.appName.indexOf("Microsoft") == -1) {
|
87 |
|
|
t.eq(parseFloat(popup.div.style.opacity), opacity, "good default popup.opacity");
|
88 |
|
|
} else {
|
89 |
|
|
t.eq(popup.div.style.filter, "alpha(opacity=" + opacity*100 + ")", "good default popup.opacity");
|
90 |
|
|
}
|
91 |
|
|
t.ok(popup.div.style.border.indexOf(border) != -1, "good default popup.border");
|
92 |
|
|
|
93 |
|
|
x += 50;
|
94 |
|
|
popup.moveTo(new OpenLayers.Pixel(x, y));
|
95 |
|
|
t.eq(popup.div.style.left, x + "px", "moveTo updates left position of popup.div correctly");
|
96 |
|
|
t.eq(popup.div.style.top, y + "px", "moveTo updates top position of popup.div correctly");
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
// -->
|
103 |
|
|
</script>
|
104 |
|
|
</head>
|
105 |
|
|
<body>
|
106 |
|
|
</body>
|
107 |
|
|
</html>
|