summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Style2.html
blob: 87ab5844808f52ccd3bb1a1308f608346c354e7a (plain)
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
<html> 
<head> 
    <script src="OLLoader.js"></script> 
    <script type="text/javascript">

    function test_constructor(t) { 
        t.plan(4); 

        var rules = [
            new OpenLayers.Rule({
                symbolizer: {fillColor: "red"},
                filter: new OpenLayers.Filter.Comparison({
                    type: OpenLayers.Filter.Comparison.EQUAL_TO,
                    property: "type",
                    value: "fire engine"
                })
            }),
            new OpenLayers.Rule({
                symbolizer: {fillColor: "yellow"},
                filter: new OpenLayers.Filter.Comparison({
                    type: OpenLayers.Filter.Comparison.EQUAL_TO,
                    property: "type",
                    value: "sports car"
                })
            })
        ];
        var style = new OpenLayers.Style2({rules: rules}); 
        t.ok(style instanceof OpenLayers.Style2, "correct type"); 
        t.eq(style.rules.length, 2, "correct number of rules added");
        t.ok(style.rules[0] === rules[0], "correct first rule added");
        t.ok(style.rules[1] === rules[1], "correct second rule added");
    }
    
    function test_destroy(t) {
        t.plan(1);
        
        var style = new OpenLayers.Style2({
            rules: [
                new OpenLayers.Rule({
                    symbolizers: [
                        new OpenLayers.Symbolizer.Point({
                            fillColor: "fuchsia"
                        })
                    ]
                })
            ]
        });
        style.destroy();
        t.ok(!style.rules, "rules array gone");
    }


    </script> 
</head>
<body></body> 
</html>