Author: ygrego Date: 2015-02-27 16:59:15 +0000 (Fri, 27 Feb 2015) New Revision: 888 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/888 Log: Addition of method "displayArrayLayout" to display tests cases as a table. Modify method "display" in order to all tests sections are contained into one tag "div". Modified: oipf/js/test/Test.js Modified: oipf/js/test/Test.js =================================================================== --- oipf/js/test/Test.js 2015-02-27 16:53:24 UTC (rev 887) +++ oipf/js/test/Test.js 2015-02-27 16:59:15 UTC (rev 888) @@ -25,13 +25,13 @@ label: "Switch to precedent channel in channel list.", method: "testPrevChannel", impl: true - }/*, + }, { id: "vbTestNextChannel", label: "Switch to next channel in channel list.", method:"testNextChannel", impl: false - }*/ + } ]},{ name: "SearchManagerTest", object: new SearchManagerTest(), @@ -50,10 +50,10 @@ } ] }], - init: function () { + init: function() { }, - runAll: function () { + runAll: function() { for (var i = 0; i < this.testsObjects.length; i++) { var element = this.testsObjects[i]; @@ -70,8 +70,8 @@ } }, //Use the innerHTML property to achieve display - display: function () { - var content = "<div id='testsDisplay'>Test Page <button id='runAllBtn'>Run All</button></div>"; + display: function() { + var content = "<div id='testsDisplay'>Test Page <button id='runAllBtn'>Run All</button>"; var testsObjects = this.testsObjects; for (var i = 0; i < testsObjects.length; i++) { @@ -102,8 +102,50 @@ content += "</div>"; document.body.innerHTML = content; }, - updateTestResult: function (currentTest, object) { + + //Use the innerHTML property to achieve display + displayArrayLayout: function() { + var content = "<div id='testsDisplay'>Test Page <button id='runAllBtn'>Run All</button>"; + var testsObjects = this.testsObjects; + for (var i = 0; i < testsObjects.length; i++) { + var currentObject = testsObjects[i]; + var sectionName = currentObject["name"]; + content += "<div id='" + sectionName + "SectionTitle" + "'>" + sectionName + " <button id='" + sectionName + "Btn' onclick='hideOrShowTestSection(\"" + sectionName + "\")'>Hide/Show</button>"; + 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 += "<table id='" + currentTest["id"] + "Table'>"; + content += "<caption>" + currentTest["id"] + "<caption/>"; + content += "<tbody>"; + content += "<tr><th>Tested method</th><td>" + currentTest["method"] + "</td></tr>"; + content += "<tr><th>Label</th><td>" + currentTest["label"] + "</td></tr>"; + var impl = currentTest["impl"]; + content += "<tr><th>Implementation State</th><td>" + impl + "</td></tr>"; + content += "</tbody>"; + ////TFOOT + content += "<tfoot>"; + if (impl) { + content += "<tr><th>Result</th><td id='" + currentTest["id"] + "Res'>Test has not been launch. Click on button \"Run\" below.</td></tr>"; + content += "<tr><th>Test launching</th><td><button id='" + currentTest["id"] + "Btn" + "'>Run</button></td></tr>"; + } else { + content += "<tr><th>Result</th><td id='" + currentTest["id"] + "Res'>Any result will be available for the moment, test has not been implemented.</td></tr>"; + content += "<tr><th>Test launching</th><td><button id='" + currentTest["id"] + "Btn" + "' disabled>Run</button></td></tr>"; + } + content += "</tfoot>"; + content += "</table>"; + } + + content += "</div>"; + } + content += "</div>"; + document.body.innerHTML = content; + }, + updateTestResult: function(currentTest, object) { + var promise = new Promise(object[currentTest["method"]].bind(object)); promise.then(function (val) { document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val;