Author: ygrego Date: 2015-03-05 10:47:38 +0000 (Thu, 05 Mar 2015) New Revision: 914 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/914 Log: For the return of test result, setting up of timer in order to know when a test result didn't return in method "updateResult". Modified: oipf/js/test/Test.js Modified: oipf/js/test/Test.js =================================================================== --- oipf/js/test/Test.js 2015-03-04 15:01:46 UTC (rev 913) +++ oipf/js/test/Test.js 2015-03-05 10:47:38 UTC (rev 914) @@ -170,6 +170,7 @@ content += "<td><button id='" + currentTest["id"] + "Btn" + "'>Run</button></td>"; } content += "</tr>"; + content += "<tr><td></td><td></td><td></td><td></td></tr>"; //Make a seperation between 2 test section (VideoBroadcast and SearchManager for example) } content += "</tbody>"; content += "</table>"; @@ -179,18 +180,40 @@ }, updateTestResult: function(currentTest, object) { - var timeStart = performance.now(); - var promise = new Promise(object[currentTest["method"]].bind(object)); - promise.then(function (val) { - var timeEnd = performance.now(); - document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val + " Test-duration: " + ((timeEnd - timeStart)/1000).toFixed(3); + try { + var timeStart = performance.now(); + var promise = new Promise(object[currentTest["method"]].bind(object)); + var result = false; - }); - promise.catch(function (val) { - var timeEnd = performance.now(); - document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val + " Test-duration: " + ((timeEnd - timeStart)/1000).toFixed(3); + promise.then(function (val) { + result = true; + var timeEnd = performance.now(); + document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val + " Test-duration: " + (timeEnd - timeStart).toFixed(2) +" ms"; + + }); - }); + promise.catch(function (val) { + result = true; + var timeEnd = performance.now(); + document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + val + " Test-duration: " + (timeEnd - timeStart).toFixed(2) +" ms"; + + }); + + setTimeout(function () { + console.log("HERE", timeStart); + if (!result) { + var message = "Any result have been return."; + var timeEnd = performance.now(); + document.getElementById(currentTest["id"] + "Res").textContent = "Result: " + message + " Test-duration: " + (timeEnd - timeStart).toFixed(2) +" ms"; + throw new Error(message); + + } + }, 10000); + + } catch (error) { + console.log("[INFO]", error.message); + + } } });
participants (1)
-
ygregoï¼ users.nuiton.org