Author: ygrego Date: 2015-03-31 08:03:16 +0000 (Tue, 31 Mar 2015) New Revision: 988 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/988 Log: New method added: "runSectionTest". Some adjustments have been done in mehtod "displayInLineArray" and method "updateTestResult". Modified: oipf/js/test/Test.js Modified: oipf/js/test/Test.js =================================================================== --- oipf/js/test/Test.js 2015-03-31 07:48:04 UTC (rev 987) +++ oipf/js/test/Test.js 2015-03-31 08:03:16 UTC (rev 988) @@ -1,22 +1,206 @@ /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates - * and open the template in the editor. + * and open the template in the editor. */ var Test = Class.extend({ testsObjects: [{ + name : "OipfFactoryTest", + object: new OipfFactoryTest(), + tests: [ + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfApplicationManager'.", + method: "testIsApplicationManagerObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfCapabilities'.", + method: "testIsCapabilitiesObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'channelConfig'.", + method: "testIsChannelConfigSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfCodManager'.", + method: "testIsCodManagerObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfConfiguration'.", + method: "testIsConfigurationObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfDownloadManager'.", + method: "testIsDownloadManagerObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfDownloadTrigger'.", + method: "testIsDownloadTriggerObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfDrmAgent'.", + method: "testIsDrmAgentObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfGatewayInfo'.", + method: "testIsGatewayInfoObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfCommunicationServices'.", + method: "testIsIMSObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfMDTF'.", + method: "testIsMDTFObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/notifsocket'.", + method: "testIsNotifSocketObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfParentalControlManager'.", + method: "testIsParentalControlManagerObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfRecordingScheduler'.", + method: "testIsRecordingSchedulerObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfRemoteControlFunction'.", + method: "testIsRemoteControlFunctionObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfRemoteManagement'.", + method: "testIsRemoteManagementObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfSearchManager'.", + method: "testIsSearchManagerObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'application/oipfStatusView'.", + method: "testIsStatusViewObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'video/broadcast'.", + method: "testIsVideoBroadcastObjectSupported" + }, + { + label: "Call the method 'isObjectSupported' with mime-type 'video/mpeg'.", + method: "testIsVideoMpegObjectSupported" + }, + { + label: "Call the method 'createApplicationManagerObject of oifp factory.", + method: "testCreateApplicationManagerObject" + }, + { + label: "Call the method createCapabilitiesObject of oifp factory.", + method: "testCreateCapabilitiesObject" + }, + { + label: "Call the method createChannelConfig of oifp factory.", + method: "testCreateChannelConfig" + }, + { + label: "Call the method createCodManagerObject of oifp factory.", + method: "testCreateCodManagerObject" + }, + { + label: "Call the method createConfigurationObject of oifp factory.", + method: "testCreateConfigurationObject" + }, + { + label: "Call the method createDownloadManagerObject of oifp factory.", + method: "testCreateDownloadManagerObject" + }, + { + label: "Call the method createDownloadTriggerObject of oifp factory.", + method: "testCreateDownloadTriggerObject" + }, + { + label: "Call the method createDrmAgentObject of oifp factory.", + method: "testCreateDrmAgentObject" + }, + { + label: "Call the method createGatewayInfoObject of oifp factory.", + method: "testCreateGatewayInfoObject" + }, + { + label: "Call the method createImsObject of oifp factory.", + method: "testCreateIMSObject" + }, + { + label: "Call the method createMdtfObject of oifp factory.", + method: "testCreateMDTFObject" + }, + { + label: "Call the method createNotifSocketObject of oifp factory.", + method: "testCreateNotifSocketObject" + }, + { + label: "Call the method createParentalControlManagerObject of oifp factory.", + method: "testCreateParentalControlManagerObject" + }, + { + label: "Call the method createRecordingSchedulerObject of oifp factory.", + method: "testCreateRecordingSchedulerObject" + }, + { + label: "Call the method createRemoteControlFunctionObject of oifp factory.", + method: "testCreateRemoteControlFunctionObject" + }, + { + label: "Call the method createRemoteManagementObject of oifp factory.", + method: "testCreateRemoteManagementObject" + }, + { + label: "Call the method createSearchManagerObject of oifp factory.", + method: "testCreateSearchManagerObject" + }, + { + label: "Call the method createStatusViewObject of oifp factory.", + method: "testCreateStatusViewObject" + }, + { + label: "Call the method createVideoBroadcastObject of oifp factory.", + method: "testCreateVideoBroadcastObject" + }, + { + label: "Call the method createVideoMpegObject of oifp factory.", + method: "testCreateVideoMpegObject" + } + ]},{ name : "VideoBroadcastTest", object: new VideoBroadcastTest(), tests: [ { - label: "Video broadcast creation.", - method: "testBind2Stop" - }, - { label: "Bind the current channel stream with a video broadcast object.", method: "testBindToCurrentChannel" }, { + label: "Call 'bindToCurrentChannel' when there isn't channel presentation.", + method: "testBindToCurrentChannelWhenNoChannelPresentation" + }, + { + label: "Bind the current channel stream with a video broadcast object while this one is in connecting state.", + method: "testBindToCurrentChannelInConnecting" + }, + { + label: "Bind the current channel stream with a video broadcast object while this one is in presenting state.", + method: "testBindToCurrentChannelInPresenting" + }, + { + label: "Bind the current channel stream with a video broadcast object while this one is in stopped state.", + method: "testBindToCurrentChannelInStopped" + }, + { + label: "Bind the current channel stream with a video broadcast object while this one is in stopped state.", + method: "testBindToCurrentChannelInStoppedWhenNoTuner" + }, + { + label: "Call 'bindToCurrentChannel' twice.", + method: "testDoubleBindToCurrentChannel" + }, + { label: "Switch to precedent channel in channel list.", method: "testPrevChannel" }, @@ -31,16 +215,52 @@ { label: "Stop the video and audio presentation of video broadcast object.", method: "testStop" + }, + { + label: "Set the volume of current VideoBroadcastObject to 15.", + method: "testSetVolume" + }, + { + label: "Don't pass argument to method which set the volume of Video-Broadcast Object.", + method: "testSetVolumeWithoutArgument" + }, + { + label: "Set the volume of current VideoBroadcastObject with a float value.", + method: "testSetVolumeWithFloatArgument" + }, + { + label: "Set the volume of current VideoBroadcastObject with a float value superior of bound max.", + method: "testSetVolumeWithFloatUnderBoundMin" + }, + { + label: "Set the volume of current VideoBroadcastObject with a float value inferior of bound min.", + method: "testSetVolumeWithFloatAboveBoundMax" + }, + { + label: "Set the volume of current VideoBroadcastObject inferior to 0.", + method: "testSetVolumeWithValueUnderBoundMin" + }, + { + label: "Set the volume of current VideoBroadcastObject superior to 100.", + method: "testSetVolumeWithValueAboveBoundMax" + }, + { + label: "Get the volume of current VideoBroadcastObject.", + method: "testGetVolume" + }, + { + label: "Set a channel in presenting state.", + method: "testSetChannelInPresenting" + }, + { + label: "Call method 'setChannel' with null in presenting state.", + method: "testSetChannelInPresentingWithNull" } ]},{ name: "SearchManagerTest", object: new SearchManagerTest(), tests: [ { - label: "Search manager creation.", - method: "testSearchManagerInit" - }, - { label: "Obtain current program according to oipf norm.", method: "testGetCurrentProgram" } @@ -74,6 +294,22 @@ .then(loop).catch(loop); }, + runSectionTest : function(indexObject, indexTest) { + var element = this.testsObjects[indexObject]; + var object = element.object; + var tests = element.tests; + + var self = this; + var loop = function() { + if (indexTest < tests.length - 1) { + self.runSectionTest(indexObject, indexTest + 1); + } + }; + + this.updateTestResult(tests[indexTest], object) + .then(loop).catch(loop); + }, + run: function(indexObject, indexTest) { var element = this.testsObjects[indexObject]; var object = element.object; @@ -83,29 +319,34 @@ }, displayInLineArray: function() { - var content = "<div id='testsDisplay'>Test Page <button id='runAllBtn'>Run All</button>"; + var content = "<div id='testsDisplay'><button id='runAllBtn'>Run All</button>"; var testsObjects = this.testsObjects; content += "<div id=AllTestDiv>"; - content += "<table id=AllTestTable>"; - - content += "<tbody>"; - - content += "<thead>"; - content += "<tr>"; - content += "<th>Tested Method</th>"; - content += "<th>Label</th>"; - content += "<th>Test duration</th>"; - content += "<th>Result</th>"; - content += "<th>Lauching</th>"; - content += "</tr>"; - content += "</thead>"; for (var i = 0; i < testsObjects.length; i++) { - var currentObject = testsObjects[i]; + content += "<div id='" + currentObject.name + "Title'>" + + "Section " + currentObject.name + + "<button id='" + currentObject.name + "HideShowBtn'>Hide/Show</button>" + + "<button id='runAll" + currentObject.name + "Btn'>Run tests of this section</button>"; + content += "</div>"; + content += "<div id='" + currentObject.name + "Section' style='display:none;'>"; + content += "<table id='" + currentObject.name + "Table'>"; + content += "<tbody>"; + content += "<thead>"; + content += "<tr>"; + content += "<th>Tested Method</th>"; + content += "<th>Label</th>"; + content += "<th>Test duration</th>"; + content += "<th>Result</th>"; + content += "<th>Lauching</th>"; + content += "</tr>"; + content += "</thead>"; + + var currentObject = testsObjects[i]; var tests = currentObject["tests"]; for (var j = 0; j < tests.length; j++) { - + var currentTest = tests[j]; content += "<tr id='" + currentTest["method"] + "'>"; content += "<td>" + currentTest["method"] + "</td>"; @@ -113,41 +354,47 @@ content += "<td id='" + currentTest["method"] + "Duration'>None</td>"; content += "<td id='" + currentTest["method"] + "Result'>None</td>"; content += "<td><button id='" + currentTest["method"] + "Btn" + "'>Run</button></td>"; + content += "</tr>"; } - content += "</tr>"; + content += "</tbody>"; + content += "</table>"; + content += "</div>"; } - content += "</tbody>"; - - content += "</table>"; content += "</div>"; content += "</div>"; document.body.innerHTML = content; }, + + updateTestResult: function(currentTest, object) { console.group(currentTest["label"]); - var timeStart = performance.now(); + var timeStart = new Date(); var self = this; return new Promise(function(resolve, reject) { try { + timeout(5000) + .then(reject.bind(this, "No result returned.")) + .then(object.afterTest.bind(object)); object.beforeTest && object.beforeTest(resolve, reject); - object[currentTest["method"]](resolve, reject); - timeout(5000).then(reject("No result returned.")); + object[currentTest["method"]] && object[currentTest["method"]](resolve, reject); } catch (error) { reject(error); } }) .then(function(val) { console.groupEnd(currentTest["label"]); - var timeEnd = performance.now(); - self.updateTestResultSuccess(timeStart, timeEnd, currentTest, val); + var timeEnd = new Date(); + self.updateTestResultSuccess(timeStart, timeEnd, currentTest, val); + object.afterTest && object.afterTest(); }) .catch(function(val) { console.log(val); console.groupEnd(currentTest["label"]); - var timeEnd = performance.now(); + var timeEnd = new Date(); self.updateTestResultError(timeStart, timeEnd, currentTest, val); + object.afterTest && object.afterTest(); }); }, @@ -155,7 +402,7 @@ document.getElementById(currentTest["method"] + "Result").textContent = message || "Success"; document.getElementById(currentTest["method"] + "Result").style.backgroundColor = "limegreen"; document.getElementById(currentTest["method"] + "Duration").textContent = (timeEnd - timeStart).toFixed(2) + " ms"; -}, + }, updateTestResultError: function(timeStart, timeEnd, currentTest, message) { document.getElementById(currentTest["method"] + "Result").textContent = message || "Error";
participants (1)
-
ygregoï¼ users.nuiton.org