Author: ygrego Date: 2015-02-17 16:13:40 +0000 (Tue, 17 Feb 2015) New Revision: 818 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/818 Log: Addition of property "testsObject" which contains description of each test for each object of oipf norm(very usefull to build the test page). Addition of method "display" to build the test page (buttons to run tests, descriptions for tests). Addition of method "runAll", launch all tests describe in propperty "testsObject". Modified: oipf/js/test/Test.js Modified: oipf/js/test/Test.js =================================================================== --- oipf/js/test/Test.js 2015-02-17 16:00:54 UTC (rev 817) +++ oipf/js/test/Test.js 2015-02-17 16:13:40 UTC (rev 818) @@ -4,9 +4,117 @@ * and open the template in the editor. */ var Test = Class.extend({ + + testsObjects : [/*{ + name : "VideoBroadcastTest", + object : new VideoBroadcastTest(), + tests : [ + { + id : "vbTestInstanceCreation", + label : "Object creation.", + method : "testInstanceCreation", + impl: "Yes" + }, + { + id : "vbTestBindToCurrentChannel", + label : "Bind the current channel stream with a video broadcast object.", + method :"bindToCurrentChannel", + impl: "Yes" + }, + { + id : "vbTestPrevChannel", + label : "Switch to precedent channel in channel list.", + method :"testPrevChannel", + impl: "No" + }, + { + id : "vbTestNextChannel", + label : "Switch to next channel in channel list.", + method :"testNextChannel", + impl: "No" + } + ] + },*/ + { + name : "SearchManagerTest", + object : new SearchManagerTest(), + tests : [ + { + id : "smTestInstanceCreation", + label : "Object creation.", + method : "testInstanceCreation", + impl : "Yes" + }/*, + { + id : "smTestGetCurrentProgram", + label : "Obtain current program according to oipf norm.", + method :"testGetCurrentProgram", + impl : "Yes" + }*/ + ] + }], init: function() { + }, + + runAll: function() { + + console.log("Result", this); + for (var i = 0; i<this.testsObjects.length; i++) { + var element = this.testsObjects[i]; + var object = element["object"]; + var tests = element["tests"]; + for(var j = 0; j<tests.length; j++) { + + var currentTest = tests[j]; + if (currentTest["impl"] === "Yes") { + if (object[currentTest["method"]]() === true) { + document.getElementById(currentTest["id"]+"Res").innerHTML = "Result: Successful"; + } else { + document.getElementById(currentTest["id"]+"Res").innerHTML = "Result: Failure"; + } + } + + } + + + + } + }, + + //Use the innerHTML property to achieve display + display: function() { + var content = "<div id='testsDisplay'>Test Page <button id='runAllBtn'>Run All</button></div>"; + var testsObjects = this.testsObjects; + for (var i = 0; i<testsObjects.length; i++) { + + var currentObject = testsObjects[i]; + var sectionName = currentObject["name"]; + content += "<div id='"+sectionName+"'>"; + var tests = currentObject["tests"]; + for (var j = 0; j<tests.length; j++) { + + var currentTest = tests[j]; + content += "<div id='"+currentTest["id"]+"'>"; + content += "<div>Label: "+currentTest["label"]+"</div>"; + content += "<div>Tested method: "+currentTest["method"]+"</div>"; + var impl = currentTest["impl"]; + content += "<div>Implementation State: "+impl+"</div>"; + + if (impl === "Yes") { + content += "<div id='"+currentTest["id"]+"Res"+"'>Result: Test has not been launch. Click on button \"Run\" below.</div>"; + content += "<div><button id='"+currentTest["id"]+"Btn"+"'>Run</button></div>"; + } else { + content += "<div id='"+currentTest["id"]+"Res"+"'>Result: Any result will be available for the moment, test has not been implemented.</div>"; + content += "<div><button id='"+currentTest["id"]+"Btn"+"' disabled>Run</button></div>"; + } + content += "</div>"; + } + content += "</div>"; + } + content += "</div>"; + document.body.innerHTML = content; } });
participants (1)
-
ygregoï¼ users.nuiton.org