source: subversion/applications/rendering/osmarender-frontend/trunk/cmyk/structures/features/tests/cmyk.structures.features.tests.html @ 9802

Revision 9802, 4.8 KB checked in by merio, 6 years ago (diff)

Osmarender Frontend:
/* New feature */
In the rules panel now an experimental/read only tree with all the rules parsed is shown

/* Refactoring */
Created new cmyk and osmarender_frontend directory which will contain the modules externalised step by step. Now they contains a few of them

/* Documentation */
Created some documentation for new modules, and a shell script which will generate it from the code with JSDoc Toolkit in jsdoctoolkit directory

/* Test Suite */
cmykTestSuite.html file contains some testsuites for the new refactored modules

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4<title>CMYK library structures.features Tests</title>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6    <script type="text/javascript" src="../../../../jsunit/app/jsUnitCore.js"></script>
7    <script type="text/javascript" src="../../../../dojotoolkit/dojo/dojo.js"></script>
8<script type="text/javascript">
9
10function setUpPage() {
11        dojo.registerModulePath("cmyk","../../cmyk");
12        dojo.require("cmyk.structures.features.Feature");
13        dojo.require("cmyk.structures.features.Facet");
14        var wiki_facet;
15        var wiki_facet_physical;
16        var wiki_facet_physical_highway;
17        var other_facet;
18        var other_facet_category;
19        var other_facet_subcategory;
20        setUpPageStatus="complete";
21}
22
23function testDojo() {
24        assertNotUndefined("Dojo need to be defined",dojo);
25}
26
27function testFacet() {
28        info("Testing facet");
29       
30        var error=false;
31       
32        try {
33                wiki_facet = new cmyk.structures.features.Facet(2);
34                error=true;
35        }
36        catch (e) {
37                debug(e);
38        }
39       
40        if (error) fail ("Facet should have thrown an error");
41
42        wiki_facet = new cmyk.structures.features.Facet("wiki");
43        assertTrue("wiki_facet must be an instance of cmyk.structures.features.Facet", wiki_facet instanceof cmyk.structures.features.Facet);
44        other_facet = new cmyk.structures.features.Facet("other");
45        assertTrue("other_facet must be an instance of cmyk.structures.features.Facet", other_facet instanceof cmyk.structures.features.Facet);
46        assertTrue("first facet must be named 'wiki'", wiki_facet.getName()=="wiki");
47        assertTrue("second facet must be named 'other'", other_facet.getName()=="other");
48}
49
50function testCategory() {
51        info("Testing category");
52       
53        wiki_facet = new cmyk.structures.features.Facet("wiki");       
54
55        var category_parameters = new Array(new Array(2,null),new Array(null,2),new Array(2,3),new Array("category",5),new Array(2,wiki_facet));
56        var error=false;
57        var error_in_number;
58        for (var i in category_parameters) {
59                try {
60                        wiki_facet_physical = new cmyk.structures.features.Category(category_parameters[i][0],category_parameters[i][1]);
61                        error=true;
62                }
63                catch (e) {
64                        debug(e);
65                }
66        }
67        if (error) fail ("Category should have thrown an error for parameter number "+error_in_number);
68       
69        info("Creating a category without a supercategory");
70       
71        var wiki_facet_physical = new cmyk.structures.features.Category("physical",wiki_facet);
72        assertTrue("wiki_facet_physical should be an instance of cmyk.structures.features.Category",wiki_facet_physical instanceof cmyk.structures.features.Category);
73        assertTrue("wiki_facet_physical name should be 'physical'",wiki_facet_physical.getName()=="physical");
74        assertUndefined("wiki_facet_physical supercategory should be undefined",wiki_facet_physical.getSuperCategory());
75        assertObjectEquals("Facet retrieved should be the same as the original",wiki_facet_physical.getFacet(),wiki_facet);
76        assertTrue("Facet name for wiki_facet_physical should be 'wiki'",wiki_facet_physical.getFacet().getName()=="wiki");
77       
78        info("Creating a category with a supercategory");
79       
80        var category_parameters = new Array("undefined",wiki_facet,2)
81        var error=false;
82        var error_in_number;
83        for (var i in category_parameters) {
84                try {
85                        wiki_facet_physical_highway = new cmyk.structures.features.Category("physical",wiki_facet,category_parameters[i]);
86                        error=true;
87                        error_in_number=i;
88                }
89                catch (e) {
90                        debug(e);
91                }
92        }
93
94        if (error) fail ("Category should have thrown an error for parameter number "+error_in_number);
95       
96        var wiki_facet_physical_highway = new cmyk.structures.features.Category("highway",wiki_facet,wiki_facet_physical);
97        assertTrue("wiki_facet_physical_highway should be an instance of cmyk.structures.features.Category",wiki_facet_physical_highway instanceof cmyk.structures.features.Category);
98        assertTrue("wiki_facet_physical_highway name should be 'highway'",wiki_facet_physical_highway.getName()=="highway");
99        assertTrue("wiki_facet_physical_highway supercategory should be an instance of cmyk.structures.features.Category",wiki_facet_physical_highway.getSuperCategory() instanceof cmyk.structures.features.Category);
100        assertObjectEquals("Supercategory should be the same as the original",wiki_facet_physical_highway.getSuperCategory(),wiki_facet_physical);
101        assertObjectEquals("Facet retrieved should be the same as the original",wiki_facet_physical_highway.getFacet(),wiki_facet);
102        assertTrue("Supercategory name should be 'physical'",wiki_facet_physical_highway.getSuperCategory().getName()=="physical");
103        assertTrue("Facet name should be 'wiki'",wiki_facet_physical_highway.getFacet().getName()=="wiki");
104}
105
106//TODO: Test for Features and adding categories/facets, this will be done when the templates section will be completed
107
108</script>
109</head>
110
111<body>
112<h1>CMYK library structures.base Tests</h1>
113
114<p>This page contains tests for the structures.base CMYK functions. To see them, take a look at the source.</p>
115</body>
116</html>
117 
Note: See TracBrowser for help on using the repository browser.