Author: ygrego Date: 2015-03-11 16:27:32 +0000 (Wed, 11 Mar 2015) New Revision: 939 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/939 Log: Addition of block try catch around code subject to cause errors in each test method. Modified: oipf/js/test/VideoBroadcastTest.js Modified: oipf/js/test/VideoBroadcastTest.js =================================================================== --- oipf/js/test/VideoBroadcastTest.js 2015-03-11 15:05:24 UTC (rev 938) +++ oipf/js/test/VideoBroadcastTest.js 2015-03-11 16:27:32 UTC (rev 939) @@ -6,64 +6,83 @@ var VideoBroadcastTest = TestCase.extend({ error: { - 0: "channel not supported by tuner", - 1: "cannot tune to given transport stream (e.g. no signal)", - 2: "tuner locked by other object.", - 3: "parental lock on channel.", - 4: "encrypted channel, key/module missing.", - 5: "unknown channel (e.g. can’t resolve DVB or ISDB triplet).", - 6: "channel switch interrupted (e.g. because another channel switch was activated before the previous one completed).", - 7: "channel cannot be changed, because it is currently being recorded.", - 8: "cannot resolve URI of referenced IP channel.", - 9: "insufficient bandwidth.", - 10: "channel cannot be changed by nextChannel()/prevChannel() methods either because the OITF does not maintain a favourites or channel list or because the video/broadcast object is in the Unrealized state.", - 11: "insufficient resources are available to present the given channel (e.g. a lack of available codec resources).", - 12: "specified channel not found in transport stream.", - 100: "unidentified error." + 0: "Channel not supported by tuner.", + 1: "Cannot tune to given transport stream (e.g. no signal).", + 2: "Tuner locked by other object.", + 3: "Parental lock on channel.", + 4: "Encrypted channel, key/module missing.", + 5: "Unknown channel (e.g. can’t resolve DVB or ISDB triplet).", + 6: "Channel switch interrupted (e.g. because another channel switch was activated before the previous one completed).", + 7: "Channel cannot be changed, because it is currently being recorded.", + 8: "Cannot resolve URI of referenced IP channel.", + 9: "Insufficient bandwidth.", + 10: "Channel cannot be changed by nextChannel()/prevChannel() methods either because the OITF does not maintain a favourites or channel list or because the video/broadcast object is in the Unrealized state.", + 11: "Insufficient resources are available to present the given channel (e.g. a lack of available codec resources).", + 12: "Specified channel not found in transport stream.", + 100: "Unidentified error." }, + init: function () { }, + /* * Descrtiption: * This method test the initialization of video broadcast object. */ testInstanceCreation: function (resolve, reject) { console.log("***************************************************************************************************************************"); - console.log("[TEST-RUNNING][Info] Id: vbTestInstanceCreation, Label: Object creation, State: Pending"); - var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); + + try { + + var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); - if (this.assertNotNull(videoBroadcastObject) && this.assertNotUndefined(videoBroadcastObject)) { - console.log("[TEST-RUNNING][Info] Id: vbTestInstanceCreation, Label: Object creation, State: Successfull"); - resolve("Successfull"); - } else { - console.log("[TEST-RUNNING][Info] Id: vbTestInstanceCreation, Label: Object creation, State: Failure"); - reject("Failure"); + if (this.assertNotNull(videoBroadcastObject) && this.assertNotUndefined(videoBroadcastObject)) { + console.log("[TEST-RUNNING][Info] Id: vbTestInstanceCreation, Label: Object creation, State: Successfull"); + resolve("Successfull"); + } else { + console.log("[TEST-RUNNING][Info] Id: vbTestInstanceCreation, Label: Object creation, State: Failure"); + reject("Failure"); + } + console.log("***************************************************************************************************************************"); + } catch (error) { + console.log(error.message, "Here"); + throw error; } - console.log("***************************************************************************************************************************"); }, + /* * Descrtiption: * This method test the binding between the video broadcast object and the current program stream. * ToDO: Extraction of method onPlayStateChange out. */ testBindToCurrentChannel: function (resolve, reject) { + console.log("***************************************************************************************************************************"); + console.log("[TEST-RUNNING][Info] Id: vbTestBindToCurrentChannel, Label: Bind the current channel stream with a video broadcast objectBind the current channel stream with a video broadcast object, State: Pending"); - console.log("[TEST-RUNNING][Info] Id: vbTestBindToCurrentChannel, Label: Bind the current channel stream with a video broadcast objectBind the current channel stream with a video broadcast object, State: Pending"); + try { + + var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); + var currentChann = videoBroadcastObject.bindToCurrentChannel(); + + } catch (error) { + console.log(error.message); + throw error; + } + var self = this; - var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); - videoBroadcastObject.onPlayStateChange = function (state, error) { - + videoBroadcastObject.onPlayStateChange = function(state, error) { + var wantedPlayState; var VerifWantedPlayStateRes; switch (videoBroadcastObject.playstate) { case 0: wantedPlayState = 2; - VerifWantedPlayStateRes = self.verifWantedPlayState(self, videoBroadcastObject, state, wantedPlayState); - //TODO Verfication of binding to the necesssary ressources have achieved with success. + VerifWantedPlayStateRes = self.verifWantedPlayState(self, state, wantedPlayState); + //TODO Verification of binding to the necesssary ressources have achieved with success. break; case 1: @@ -76,21 +95,19 @@ case 3: wantedPlayState = 1; - VerifWantedPlayStateRes = self.verifWantedPlayState(self, videoBroadcastObject, state, wantedPlayState); + VerifWantedPlayStateRes = self.verifWantedPlayState(self, state, wantedPlayState); //TODO Verify that video and audio presentation is enabled break; } - + var success; success = VerifWantedPlayStateRes[0]; var errorPlayState = " "; if (!success) { - errorPlayState = VerifWantedPlayStateRes[1]; - } else { - videoBroadcastObject.playstate = 2; + errorPlayState = VerifWantedPlayStateRes[1]; } - + var errorBind = " "; if (self.assertEquals(videoBroadcastObject.currentChannel, currentChann)) { console.log("[TEST-RUNNING][Info] Id: vbTestBindToCurrentChannel, Label: Bind the current channel stream with a video broadcast objectBind the current channel stream with a video broadcast object, State: Successfull"); @@ -100,7 +117,7 @@ success = false; errorBind = " In binding to current channel."; } - + if (error || (!success)) { var errorText = self.error[error]; reject("Failure:" + errorBind + " " + errorText + " " + errorPlayState); @@ -111,24 +128,26 @@ }; - var currentChann = videoBroadcastObject.bindToCurrentChannel(); - }, testPrevChannel: function(resolve, reject) { console.log("***************************************************************************************************************************"); - console.log("[TEST-RUNNING][Info] Id: vbTestPrevChannel, Label: Switch to precedent channel in channel list, State: Pending"); - var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); - videoBroadcastObject.playstate = 2; - videoBroadcastObject.currentChannel = videoBroadcastObject.getChannelConfig().currentChannel; - videoBroadcastObject.prevChannel(); + try { + + var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); + videoBroadcastObject.playstate = 2; + videoBroadcastObject.currentChannel = videoBroadcastObject.getChannelConfig().currentChannel; + videoBroadcastObject.prevChannel(); + + } catch (error) { + console.log(error.message); + throw error; + } + var self = this; videoBroadcastObject.onPlayStateChange = function(state, error) { - - videoBroadcastObject.playstate = state; - if (error) { var errorText = self.error[error]; console.log("[TEST-RUNNING][Info] Id: vbTestPrevChannel, Label: Switch to precedent channel in channel list, State: Failure"); @@ -148,7 +167,7 @@ videoBroadcastObject.onChannelChangeSucceeded = function(channel) { if (self.assertNotNull(channel)) { console.log("[TEST-RUNNING][Info] Id: vbTestPrevChannel, Label: Switch to precedent channel in channel list, State: Successful"); - console.log(channel.name); + console.log(channel); resolve("Successfull"); } else { console.log("[TEST-RUNNING][Info] Id: vbTestPrevChannel, Label: Switch to precedent channel in channel list, State: Failure"); @@ -163,18 +182,22 @@ testNextChannel: function(resolve, reject) { console.log("***************************************************************************************************************************"); - console.log("[TEST-RUNNING][Info] Id: vbTestNextChannel, Label: Switch to next channel in channel list, State: Pending"); - var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); - videoBroadcastObject.playstate = 2; - videoBroadcastObject.currentChannel = videoBroadcastObject.getChannelConfig().currentChannel; - videoBroadcastObject.nextChannel(); + try { + + var videoBroadcastObject = oipfObjectFactory.createVideoBroadcastObject(); + videoBroadcastObject.playstate = 2; + videoBroadcastObject.currentChannel = videoBroadcastObject.getChannelConfig().currentChannel; + videoBroadcastObject.nextChannel(); + + } catch (error) { + console.log(error.message); + throw error; + } + var self = this; videoBroadcastObject.onPlayStateChange = function(state, error) { - - videoBroadcastObject.playstate = state; - if (error) { var errorText = self.error[error]; console.log("[TEST-RUNNING][Info] Id: vbTestNextChannel, Label: Switch to next channel in channel list, State: Failure"); @@ -203,19 +226,18 @@ }; console.log("***************************************************************************************************************************"); - }, - verifWantedPlayState: function (currentObject, object,receivedPlayState, wantedPlayState) { + verifWantedPlayState: function (currentObject, receivedPlayState, wantedPlayState) { if (currentObject.assertEquals(receivedPlayState, wantedPlayState)) { - object.playstate = receivedPlayState; return true; + } else { console.log("[TEST-RUNNING][Info] Id: vbTestBindToCurrentChannel, Label: Bind the current channel stream with a video broadcast objectBind the current channel stream with a video broadcast object, State: Failure"); return [false, "Wrong play state changement."]; + } } - });