3 <script src="../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
7 function test_Icon_constructor (t) {
9 var size = new OpenLayers.Size(5,6);
10 icon = new OpenLayers.Icon("", size);
11 t.ok( icon instanceof OpenLayers.Icon, "new OpenLayers.Icon returns Icon object" );
12 t.ok( icon.size instanceof OpenLayers.Size, "icon.size returns Size object" );
13 t.ok( icon.size.equals(size), "icon.size returns correct value" );
14 t.eq( icon.url, "", "icon.url returns str object" );
16 function test_Icon_clone (t) {
18 icon = new OpenLayers.Icon("a",new OpenLayers.Size(5,6));
19 t.ok( icon instanceof OpenLayers.Icon, "new OpenLayers.Icon returns Icon object" );
20 var cloned = icon.clone();
21 t.ok( cloned instanceof OpenLayers.Icon, "clone is an OpenLayers.Icon" );
23 t.eq( icon.url, "a", "icon.url doesn't change with clone's url" );
24 t.eq( cloned.url, "b", "cloned.url does change when edited" );
27 function test_Icon_setOpacity(t) {
30 icon = new OpenLayers.Icon("a",new OpenLayers.Size(5,6));
31 t.ok(!icon.imageDiv.style.opacity, "default icon has no opacity");
34 t.eq(parseFloat(icon.imageDiv.style.opacity), 0.5, "icon.setOpacity() works");
37 function test_Icon_isDrawn(t) {
43 var drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []);
44 t.ok(!drawn, "icon with no imageDiv not drawn");
46 //imageDiv no parentNode
48 drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []);
49 t.ok(!drawn, "icon with imageDiv with no parentNode not drawn");
51 //imageDiv with parent
52 icon.imageDiv.parentNode = {};
53 drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []);
54 t.ok(drawn, "icon with imageDiv with parentNode drawn");
56 //imageDiv with parent but nodetype 11
57 icon.imageDiv.parentNode = {'nodeType': 11};
58 drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []);
59 t.ok(!drawn, "imageDiv with parent but nodetype 11 not drawn");