Author: ygrego Date: 2015-03-04 14:32:44 +0000 (Wed, 04 Mar 2015) New Revision: 910 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/910 Log: Addition of a method "displayInLineArray" which displays a test on one line. A new data appear in test informations, the duration. The calculation is performed in method "updateResult". Modified: oipf/js/test/Test.js Modified: oipf/js/test/Test.js =================================================================== --- oipf/js/test/Test.js 2015-03-03 14:49:38 UTC (rev 909) +++ oipf/js/test/Test.js 2015-03-04 14:32:44 UTC (rev 910) @@ -30,7 +30,7 @@ id: "vbTestNextChannel", label: "Switch to next channel in channel list.", method:"testNextChannel", - impl: false + impl: true } ]},{ name: "SearchManagerTest", @@ -50,9 +50,11 @@ } ] }], + init: function() { }, + runAll: function() { for (var i = 0; i < this.testsObjects.length; i++) { var element = this.testsObjects[i]; @@ -69,6 +71,7 @@ } } }, + //Use the innerHTML property to achieve display display: function() { var content = "<div id='testsDisplay'>Test Page <button id='runAllBtn'>Run All</button>"; @@ -144,14 +147,49 @@ content += "</div>"; document.body.innerHTML = content; }, + + displayInLineArray: function() { + var content = "<div id='testsDisplay'>Test Page <button id='runAllBtn'>Run All</button>"; + var testsObjects = this.testsObjects; + content += "<div id=AllTestDiv>"; + content += "<table id=AllTestTable>"; + content += "<tbody>"; + 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>"; + var tests = currentObject["tests"]; + for (var j = 0; j < tests.length; j++) { + + var currentTest = tests[j]; + content += "<tr id='" + currentTest["id"] + "'>"; + content += "<td>Tested method: " + currentTest["method"] + "</td>"; + content += "<td>Label: " + currentTest["label"] + "</td>"; + content += "<td id='" + currentTest["id"] + "Res'>Result: Test has not been launch.</td>"; + content += "<td><button id='" + currentTest["id"] + "Btn" + "'>Run</button></td>"; + } + content += "</tr>"; + } + content += "</tbody>"; + content += "</table>"; + content += "</div>"; + content += "</div>"; + document.body.innerHTML = content; + }, + updateTestResult: function(currentTest, object) { - + var timeStart = performance.now(); var promise = new Promise(object[currentTest["method"]].bind(object)); promise.then(function (val) { - document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val; + var timeEnd = performance.now(); + document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val + " Test-duration: " + ((timeEnd - timeStart)/1000).toFixed(3); + }); promise.catch(function (val) { - document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val; + var timeEnd = performance.now(); + document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val + " Test-duration: " + ((timeEnd - timeStart)/1000).toFixed(3); + }); }
participants (1)
-
ygregoï¼ users.nuiton.org