Author: smaisonneuve Date: 2015-06-09 12:04:48 +0000 (Tue, 09 Jun 2015) New Revision: 1636 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1636 Log: [Test] - moving js files Added: oipf/test/js/ApplicationManagerTest.js oipf/test/js/CapabilitiesTest.js oipf/test/js/ConfigurationTest.js oipf/test/js/OipfFactoryTest.js oipf/test/js/ParentalControlManagerTest.js oipf/test/js/RecordingSchedulerTest.js oipf/test/js/SearchManagerTest.js oipf/test/js/Test.js oipf/test/js/TestCase.js oipf/test/js/VideoBroadcastTest.js Removed: oipf/test/js/test/ Added: oipf/test/js/ApplicationManagerTest.js =================================================================== --- oipf/test/js/ApplicationManagerTest.js (rev 0) +++ oipf/test/js/ApplicationManagerTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,50 @@ +/* + * 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. + */ + +var ApplicationManagerTest = TestCase.extend({ + + init: function() { + this.super.init(); + this.applicationManagerObject = oipfObjectFactory.createApplicationManagerObject(); + this.applicationManagerObject.onApplicationLoaded = this.onApplicationLoaded; + }, + + beforeTest: function(resolve, reject) { + + }, + + afterTest: function(resolve, reject) { + + }, + + onApplicationLoaded: function(application) { + console.log(application); + }, + + testGetOwnerApplicationOfDocumentOfGlobalPropertyWindow: function(resolve, reject) { + var application = this.applicationManagerObject + .getOwnerApplication(window.document); + + if (!this.assertEquals(application, null)) { + resolve(); + } else { + reject(); + } + }, + + testGetOwnerApplicationWithNull: function(resolve, reject) { + var application = this.applicationManagerObject + .getOwnerApplication(null); + + if (this.assertEquals(application, null)) { + resolve(); + } else { + reject(); + } + }, + +}); + Added: oipf/test/js/CapabilitiesTest.js =================================================================== --- oipf/test/js/CapabilitiesTest.js (rev 0) +++ oipf/test/js/CapabilitiesTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,250 @@ +/* + * 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. + */ +var CapabilitiesTest = TestCase.extend({ + init: function() { + this.super.init(); + }, + + beforeTest: function() { + this.capabilitiesObject = oipfObjectFactory.createCapabilitiesObject(); + }, + + afterTest: function() { + + }, + + /* + * FIXME: + * Yannis - 12/05/2015 - Instanciation of variable everyProperties. + */ + testOIFPNormConformityOfObject: function(resolve, reject) { + var everyProperties; + + for (var i = 0, l = everyProperties.length; i < l; i++) { + var currentProperty = everyProperties[i]; + if (!this.capabilitiesObject[currentProperty]) { + reject(); + return; + } + } + resolve(); + }, + + testHasCapabilityWithAnInvalidProfileName: function(resolve, reject) { + var profileName = "Toto"; + var result = this.capabilitiesObject.hasCapability(profileName); + + if (result) { + reject(); + } else { + resolve(); + } + }, + + testHasCapabilityForAtLeastOneBaseProfileName: function(resolve, reject) { + var baseProfileNameList = this.modelFactory + .getCapabilitiesProperties().baseUIProfileName; + var supportedProfileNumber = 0; + + for (var i = 0, l = baseProfileNameList.length; i < l; i++) { + var baseProfileName = baseProfileNameList[i]; + var result = this.capabilitiesObject.hasCapability(baseProfileName); + result && supportedProfileNumber++; + } + + if (supportedProfileNumber > 0) { + resolve(); + } else { + reject(); + } + }, + + testHasCapabilityForAllUIFragmentProfile: function(resolve, reject) { + var UIProfileNameFragmentList = this.modelFactory + .getCapabilitiesProperties().UIProfileNameFragment; + var supportedProfileNumber = 0; + + for (var i = 0, l = UIProfileNameFragmentList.length; i < l; i++) { + var UIProfileNameFragment = UIProfileNameFragmentList[i]; + var result = this.capabilitiesObject + .hasCapability(UIProfileNameFragment); + result && supportedProfileNumber++; + } + + if (supportedProfileNumber == UIProfileNameFragmentList.length) { + resolve(); + } else { + reject(); + } + }, + + getCapabilityAndNotifyResult: function(resolve, reject, profileName) { + var result = this.capabilitiesObject.hasCapability(profileName); + + if (result) { + resolve(); + } else { + reject(); + } + }, + + testHasCapabilityTRICKMODE: function(resolve, reject) { + var profileName = "+TRICKMODE"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityAVCAD: function(resolve, reject) { + var profileName = "+AVCAD"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDL: function(resolve, reject) { + var profileName = "+DL"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityIPTV_SDS: function(resolve, reject) { + var profileName = "+IPTV_SDS"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityIPTV_URI: function(resolve, reject) { + var profileName = "+IPTV_URI"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityANA: function(resolve, reject) { + var profileName = "+ANA"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDVB_C: function(resolve, reject) { + var profileName = "+DVB_C"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDVB_T: function(resolve, reject) { + var profileName = "+DVB_T"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDVB_S: function(resolve, reject) { + var profileName = "+DVB_S"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDVB_C2: function(resolve, reject) { + var profileName = "+DVB_C2"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDVB_T2: function(resolve, reject) { + var profileName = "+DVB_T2"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDVB_S2: function(resolve, reject) { + var profileName = "+DVB_S2"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityISDB_C: function(resolve, reject) { + var profileName = "+ISDB_C"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityISDB_T: function(resolve, reject) { + var profileName = "+ISDB_T"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityISDB_S: function(resolve, reject) { + var profileName = "+ISDB_S"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityMETA_BCG: function(resolve, reject) { + var profileName = "+META_BCG"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityMETA_EIT: function(resolve, reject) { + var profileName = "+META_EIT"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityMETA_SI: function(resolve, reject) { + var profileName = "+META_SI"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityITV_KEYS: function(resolve, reject) { + var profileName = "+ITV_KEYS"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityCONTROLLED: function(resolve, reject) { + var profileName = "+CONTROLLED"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityPVR: function(resolve, reject) { + var profileName = "+PVR"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityDRM: function(resolve, reject) { + var profileName = "+DRM"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityCommunicationServices: function(resolve, reject) { + var profileName = "+CommunicationServices"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilitySVG: function(resolve, reject) { + var profileName = "+SVG"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityPOINTER: function(resolve, reject) { + var profileName = "+POINTER"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityPOLLNOTIF: function(resolve, reject) { + var profileName = "+POLLNOTIF"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityHtml5Media: function(resolve, reject) { + var profileName = "+HTML5_MEDIA"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityWIDGETS: function(resolve, reject) { + var profileName = "+WIDGETS"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityRCF: function(resolve, reject) { + var profileName = "+RCF"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityTELEPHONY: function(resolve, reject) { + var profileName = "+TELEPHONY"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + }, + + testHasCapabilityVIDEOTELEPHONY: function(resolve, reject) { + var profileName = "+VIDEOTELEPHONY"; + this.getCapabilityAndNotifyResult(resolve, reject, profileName); + } + +}); + Added: oipf/test/js/ConfigurationTest.js =================================================================== --- oipf/test/js/ConfigurationTest.js (rev 0) +++ oipf/test/js/ConfigurationTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,315 @@ +/* + * 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. + */ + +var ConfigurationTest = TestCase.extend({ + + init: function() { + this.super.init(); + }, + + beforeTest: function(resolve, reject) { + this.configurationObject = oipfObjectFactory.createConfigurationObject(); + this.localSystem = this.configurationObject.localSystem; + logTest("State: Pending"); + }, + + testSetScreenSize : function(resolve, reject){ + + if (this.localSystem) { + var result = this.localSystem.setScreenSize(1280, 720); + + if (result) { + resolve(); + } else { + throw new Error("Unexpected error"); + } + } else { + throw new Error("Unexpected error"); + } + }, + + testSetScreenSizeWithoutParameters: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError(this.localSystem.setScreenSize, resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetScreenSizeWithUnexpectedTypeParameters: function(resolve, reject) { + + if (this.localSystem) { + + this.waitForError( + this.localSystem.setScreenSize.bind(this.localSystem, "", ""), + resolve); + + } else { + throw new Error("Unexpected error"); + } + }, + + testSetScreenSizeWithExcessiveParametersNumber: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError( + this.localSystem.setScreenSize.bind(this.localSystem, 640, 480, 854), + resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetTvStandard: function(resolve, reject) { + + if (this.localSystem) { + var result = this.localSystem.setTVStandard(4); + if (result) { + resolve(); + } else { + throw new Error("Unexpected error"); + } + } else { + throw new Error("Unexpected error"); + } + }, + + testSetTvStandardWihtoutParameters: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError(this.localSystem.setTVStandard, resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetTvStandardWithUnexpectedTypeParameters: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError( + this.localSystem.setTVStandard.bind(this.localSystem, ""), + resolve); + + } else { + throw new Error("Unexpected error"); + } + }, + + testSetTvStandardWithExcessiveParametersNumber: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError( + this.localSystem.setTVStandard.bind(this.localSystem, 4, 4), + resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPvrSupport: function(resolve, reject) { + + if (this.localSystem) { + var result = this.localSystem.setPvrSupport(1); + if (result) { + resolve(); + } else { + throw new Error("Unexpected error"); + } + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPvrSupportWithoutParameters: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError(this.localSystem.setPvrSupport, resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPvrSupportWithUnexpectedTypeParameters: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError( + this.localSystem.setPvrSupport.bind(this.localSystem, {}), + resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPvrSupportWithExcessiveParametersNumber: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError( + this.localSystem.setPvrSupport.bind(this.localSystem, 0, 0, 0), + resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPowerState: function(resolve, reject) { + + if (this.localSystem) { + var result = this.localSystem.setPowerState(); + if (result) { + resolve(); + } else { + throw new Error("Unexpected error"); + } + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPowerStateWithoutParameters: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError(this.localSystem.setPowerState, resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPowerStateWithUnexpectedTypeParameters: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError( + this.localSystem.setPowerState.bind(this.localSystem, {}), + resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetPowerStateWithExcessiveParametersNumber: function(resolve, reject) { + + if (this.localSystem) { + this.waitForError( + this.localSystem.setPowerState.bind(this.localSystem, 0, 0, 0), + resolve); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetDigestCredentials: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.setDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetDigestCredentialsWithoutParameters: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.setDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetDigestCredentialsWithUnexpectedTypeParameters: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.setDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testSetDigestCredentialsWithExcessiveParametersNumber: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.setDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testClearDigestCredentials: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.clearDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testClearDigestCredentialsWithoutParameters: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.clearDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testClearDigestCredentialsWithUnexpectedTypeParameters: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.clearDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testClearDigestCredentialsWithExcessiveParametersNumber: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.clearDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testHasDigestCredentials: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.hasDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testHasDigestCredentialsWithoutParameters: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.hasDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testHasDigestCredentials: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.hasDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + testHasDigestCredentialsWithExcessiveParametersNumber: function(resolve, reject) { + + if (this.localSystem) { + this.localSystem.hasDigestCredentials(640, 480, 854); + } else { + throw new Error("Unexpected error"); + } + }, + + afterTest: function() { + } + +}); + Added: oipf/test/js/OipfFactoryTest.js =================================================================== --- oipf/test/js/OipfFactoryTest.js (rev 0) +++ oipf/test/js/OipfFactoryTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,69 @@ +/* + * 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. + */ + +var OipfFactoryTest = TestCase.extend({ + init: function() { + this.testIsApplicationManagerObjectSupported = this.testObjectSupported.bind(this, APPLICATION_MANAGER_DAE_MIME_TYPE); + this.testIsCapabilitiesObjectSupported = this.testObjectSupported.bind(this, CAPABILITIES_DAE_MIME_TYPE); + this.testIsChannelConfigSupported = this.testObjectSupported.bind(this, CHANNEL_CONFIG_TYPE); + this.testIsCodManagerObjectSupported = this.testObjectSupported.bind(this, COD_MANAGER_DAE_MIME_TYPE); + this.testIsIMSObjectSupported = this.testObjectSupported.bind(this, COMMUNICATION_SERVICES_DAE_MIME_TYPE); + this.testIsConfigurationObjectSupported = this.testObjectSupported.bind(this, CONFIGURATION_DAE_MIME_TYPE); + this.testIsDownloadManagerObjectSupported = this.testObjectSupported.bind(this, DOWNLOAD_MANAGER_DAE_MIME_TYPE); + this.testIsDownloadTriggerObjectSupported = this.testObjectSupported.bind(this, DOWNLOAD_TRIGGER_DAE_MIME_TYPE); + this.testIsDrmAgentObjectSupported = this.testObjectSupported.bind(this, DRM_AGENT_DAE_MIME_TYPE); + this.testIsGatewayInfoObjectSupported = this.testObjectSupported.bind(this, GATEWAY_INFO_DAE_MIME_TYPE); + this.testIsMDTFObjectSupported = this.testObjectSupported.bind(this, MDTF_DAE_MIME_TYPE); + this.testIsNotifSocketObjectSupported = this.testObjectSupported.bind(this, NOTIF_SOCKET_DAE_MIME_TYPE); + this.testIsParentalControlManagerObjectSupported = this.testObjectSupported.bind(this, PARENTAL_CONTROL_MANAGER_DAE_MIME_TYPE); + this.testIsRecordingSchedulerObjectSupported = this.testObjectSupported.bind(this, RECORDING_SCHEDULER_DAE_MIME_TYPE); + this.testIsRemoteControlFunctionObjectSupported = this.testObjectSupported.bind(this, REMOTE_CONTROL_FUNCTION_DAE_MIME_TYPE); + this.testIsRemoteManagementObjectSupported = this.testObjectSupported.bind(this, REMOTE_MANAGEMENT_DAE_MIME_TYPE); + this.testIsSearchManagerObjectSupported = this.testObjectSupported.bind(this, SEARCH_MANAGER_DAE_MIME_TYPE); + this.testIsStatusViewObjectSupported = this.testObjectSupported.bind(this, STATUS_VIEW_DAE_MIME_TYPE); + this.testIsVideoBroadcastObjectSupported = this.testObjectSupported.bind(this, VIDEO_BROADCAST_DAE_MIME_TYPE); + this.testIsVideoMpegObjectSupported = this.testObjectSupported.bind(this, VIDEO_MPEG_DAE_MIME_TYPE); + + this.testCreateApplicationManagerObject = this.testObjectCreated.bind(this, oipfObjectFactory.createApplicationManagerObject); + this.testCreateCapabilitiesObject = this.testObjectCreated.bind(this, oipfObjectFactory.createCapabilitiesObject); + this.testCreateChannelConfig = this.testObjectCreated.bind(this, oipfObjectFactory.createChannelConfig); + this.testCreateCodManagerObject = this.testObjectCreated.bind(this, oipfObjectFactory.createCodManagerObject); + this.testCreateConfigurationObject = this.testObjectCreated.bind(this, oipfObjectFactory.createConfigurationObject); + this.testCreateDownloadManagerObject = this.testObjectCreated.bind(this, oipfObjectFactory.createDownloadManagerObject); + this.testCreateDownloadTriggerObject = this.testObjectCreated.bind(this, oipfObjectFactory.createDownloadTriggerObject); + this.testCreateDrmAgentObject = this.testObjectCreated.bind(this, oipfObjectFactory.createDrmAgentObject); + this.testCreateGatewayInfoObject = this.testObjectCreated.bind(this, oipfObjectFactory.createGatewayInfoObject); + this.testCreateIMSObject = this.testObjectCreated.bind(this, oipfObjectFactory.createIMSObject); + this.testCreateMDTFObject = this.testObjectCreated.bind(this, oipfObjectFactory.createMDTFObject); + this.testCreateNotifSocketObject = this.testObjectCreated.bind(this, oipfObjectFactory.createNotifSocketObject); + this.testCreateParentalControlManagerObject = this.testObjectCreated.bind(this, oipfObjectFactory.createParentalControlManagerObject); + this.testCreateRecordingSchedulerObject = this.testObjectCreated.bind(this, oipfObjectFactory.createRecordingSchedulerObject); + this.testCreateRemoteControlFunctionObject = this.testObjectCreated.bind(this, oipfObjectFactory.createRemoteControlFunctionObject); + this.testCreateRemoteManagementObject = this.testObjectCreated.bind(this, oipfObjectFactory.createRemoteManagementObject); + this.testCreateSearchManagerObject = this.testObjectCreated.bind(this, oipfObjectFactory.createSearchManagerObject); + this.testCreateStatusViewObject = this.testObjectCreated.bind(this, oipfObjectFactory.createStatusViewObject); + this.testCreateVideoBroadcastObject = this.testObjectCreated.bind(this, oipfObjectFactory.createVideoBroadcastObject); + this.testCreateVideoMpegObject = this.testObjectCreated.bind(this, oipfObjectFactory.createVideoMpegObject); + }, + + testObjectCreated: function(method, resolve, reject) { + var object = method.call(oipfObjectFactory); + + if (this.assertNotNull(object)) { + resolve(); + } else { + reject("The object is null."); + } + }, + + testObjectSupported: function(mimeType, resolve, reject) { + if (oipfObjectFactory.isObjectSupported(mimeType)) { + resolve(); + } else { + reject(); + } + } +}); Added: oipf/test/js/ParentalControlManagerTest.js =================================================================== --- oipf/test/js/ParentalControlManagerTest.js (rev 0) +++ oipf/test/js/ParentalControlManagerTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,279 @@ +/* + * 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. + */ + +var ParentalControlManagerTest = TestCase.extend({ + + init: function() { + this.super.init(); + this.PIN_CORRECT = 0; + this.PIN_INCORRECT = 1; + this.PIN_LOCKED = 2; + this.PIN = "1234"; + }, + + beforeTest: function(resolve, reject) { + this.parentalControlManagerObject = + oipfObjectFactory.createParentalControlManagerObject(); + + }, + + afterTest: function() { + this.parentalControlManagerObject.setParentalControlStatus(this.PIN, false); + this.parentalControlManagerObject.setBlockUnrated(this.PIN, false); + this.parentalControlManagerObject._setCurrentInvalidPINAttempts && + this.parentalControlManagerObject._setCurrentInvalidPINAttempts(0); + + this.newPIN && this.resetOldPIN(); + }, + + resetOldPIN: function() { + this.parentalControlManagerObject + .setParentalControlPIN(this.newPIN, this.PIN); + }, + + renderResultIfTrue: function(resolve, reject, condition) { + if (condition) { + resolve(); + } else { + reject(); + } + }, + + testSetParentalControlStatusWithValidPINAndTrue: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setParentalControlStatus(this.PIN, true); + + console.log(result); + + if (this.assertEquals(result, 0)) { + resolve(); + } else { + reject(); + } + }, + + testSetParentalControlStatusWithValidPINAndFalse: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setParentalControlStatus(this.PIN, false); + + console.log(result); + + if (this.assertEquals(result, 0)) { + resolve(); + } else { + reject(); + } + }, + + testSetParentalControlStatusWithInvalidPINAndTrue: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setParentalControlStatus("5555", true); + + console.log(result); + + this.renderResultIfTrue(resolve, reject, this.assertEquals(result, 1)); + }, + + testSetParentalControlStatusWithInvalidPINAndFalse: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setParentalControlStatus("5555", false); + + console.log(result); + + this.renderResultIfTrue(resolve, reject, this.assertEquals(result, 1)); + }, + + testSetParentalControlStatusWithInvalidOldPINAndValidNewPIN10Times: function(resolve, reject) { + for(var i = 0, li = 10; i < li; i++) { + var result = this.parentalControlManagerObject + .setParentalControlStatus("PIN", false); + + console.log(i+1, ":", result); + } + + this.renderResultIfTrue(resolve, reject, + this.assertEquals(result, this.PIN_LOCKED)); + }, + + testVerifyParentalControlPINWithInvalidPIN10Times: function(resolve, reject) { + for(var i = 0, li = 10; i < li; i++) { + var result = this.parentalControlManagerObject + .verifyParentalControlPIN("0000"); + + console.log(i+1, ":", result); + } + + if (this.assertEquals(result, 2)) { + resolve(); + } else { + reject(); + } + }, + + testVerifyParentalControlPINWithValidPIN: function(resolve, reject) { + var result = this.parentalControlManagerObject + .verifyParentalControlPIN("1234"); + + console.log(result); + + this.renderResultIfTrue(resolve, reject, + this.assertEquals(result, this.PIN_CORRECT)); + }, + + testVerifyParentalControlPINWithInvalidPIN: function(resolve, reject) { + var result = this.parentalControlManagerObject + .verifyParentalControlPIN("68465"); + + console.log(result); + + this.renderResultIfTrue(resolve, reject, + this.assertEquals(result, this.PIN_INCORRECT)); + }, + + testSetBlockUnratedWithInvalidPIN10Times: function(resolve, reject) { + for(var i = 0, li = 10; i < li; i++) { + var result = this.parentalControlManagerObject + .setBlockUnrated("toto", true); + + console.log(i+1, ":", result); + } + + if (this.assertEquals(result, 2)) { + resolve(); + } else { + reject(); + } + }, + + testSetBlockUnratedWithValidPINAndTrue: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setBlockUnrated(this.PIN, true); + + console.log(result); + + if (this.assertEquals(result, 0)) { + resolve(); + } else { + reject(); + } + }, + + testSetBlockUnratedWithValidPINAndFalse: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setBlockUnrated(this.PIN, false); + + console.log(result); + + if (this.assertEquals(result, 0)) { + resolve(); + } else { + reject(); + } + }, + + testSetBlockUnratedWithInvalidPINAndTrue: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setBlockUnrated("5555", true); + + console.log(result); + + this.renderResultIfTrue(resolve, reject, this.assertEquals(result, 1)); + }, + + testSetBlockUnratedWithInvalidPINAndFalse: function(resolve, reject) { + var result = this.parentalControlManagerObject + .setBlockUnrated("5555", false); + + console.log(result); + + this.renderResultIfTrue(resolve, reject, this.assertEquals(result, 1)); + }, + + testGetBlockUnratedWhenUnratedContentsAreNotBlocked: function(resolve, reject) { + if (!this.parentalControlManagerObject.getBlockUnrated()) { + resolve(); + } else { + reject(); + } + }, + + testGetBlockUnratedWhenUnratedContentsAreBlocked: function(resolve, reject) { + this.parentalControlManagerObject.setBlockUnrated("1234", true); + + if (this.parentalControlManagerObject.getBlockUnrated()) { + resolve(); + } else { + reject(); + } + }, + + testSetParentalControlPINWithInvalidOldPINAndValidNewPIN10Times: function(resolve, reject) { + for(var i = 0, li = 10; i < li; i++) { + var resultSetPIN = this.parentalControlManagerObject + .setParentalControlPIN("PIN", "1212"); + + console.log(i+1, ":", resultSetPIN); + } + + this.renderResultIfTrue(resolve, reject, + this.assertEquals(resultSetPIN, this.PIN_LOCKED)); + }, + + testSetParentalControlPINWithValidOldPINAndNewPIN: function(resolve, reject) { + this.newPIN = "1212"; + var resultSetPIN = this.parentalControlManagerObject + .setParentalControlPIN(this.PIN, this.newPIN); + + var resultVerifyPIN = this.parentalControlManagerObject + .verifyParentalControlPIN(this.newPIN); + + if (this.assertEquals(resultSetPIN, this.PIN_CORRECT) && + this.assertEquals(resultVerifyPIN, this.PIN_CORRECT)) { + resolve(); + } else { + reject(); + } + }, + + testSetParentalControlPINWithInvalidOldPINAndValidNewPIN: function(resolve, reject) { + this.newPIN = "1212"; + var resultSetPIN = this.parentalControlManagerObject + .setParentalControlPIN("PIN", this.newPIN); + + console.log(resultSetPIN); + + var resultVerifyPIN = this.parentalControlManagerObject + .verifyParentalControlPIN(this.newPIN); + + console.log(resultVerifyPIN); + + if (this.assertEquals(resultSetPIN, this.PIN_INCORRECT) && + this.assertEquals(resultVerifyPIN, this.PIN_INCORRECT)) { + resolve(); + } else { + reject(); + } + }, + + testGetParentalControlStatusWhenParentalControlStatusDeactivated: function(resolve, reject) { + if (!this.parentalControlManagerObject.getParentalControlStatus()) { + resolve(); + } else { + reject(); + } + }, + + testGetParentalControlStatusWhenParentalControlStatusActivated: function(resolve, reject) { + this.parentalControlManagerObject + .setParentalControlStatus(this.PIN, true); + + if (this.parentalControlManagerObject.getParentalControlStatus()) { + resolve(); + } else { + reject(); + } + } +}); \ No newline at end of file Added: oipf/test/js/RecordingSchedulerTest.js =================================================================== --- oipf/test/js/RecordingSchedulerTest.js (rev 0) +++ oipf/test/js/RecordingSchedulerTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,537 @@ +/* + * 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. + */ + +var RecordingSchedulerTest = TestCase.extend({ + + init: function() { + this.super.init(); + this.timer = 3*60*1000; //3minutes, we had increased timer for unresolved tests. + }, + + createVideoBroadcast: function() { + this.vidBroadObj = oipfObjectFactory.createVideoBroadcastObject(); + }, + + deleteAndStopStartedRecording: function() { + var recordings = this.recordingSchedulerObject.recordings; + + for (var i = 0, l = recordings.length; i < l; i++) { + var recording = recordings[i]; + if (recording.state == this.STARTED) { + this.recordingSchedulerObject.stop(recording); + this.recordingSchedulerObject.remove(recording); + } + } + }, + + beforeTest: function(resolve, reject) { + var self = this; + this.getPromise = function () { + return new Promise(function(resolve, reject) { + self.resolve = resolve; + resolve(); + }); + }; + this.onPVREventCopy = this.onPVREvent.bind(this, resolve, reject); + this.recordingSchedulerObject = + oipfObjectFactory.createRecordingSchedulerObject(); + + this.recordingSchedulerObject + .addEventListener("PVREvent", this.onPVREventCopy, false); + + this.createVideoBroadcast(); + this.onPlayStateChange = this.onChangeState.bind(this, resolve, reject); + this.vidBroadObj + .addEventListener("PlayStateChange", this.onPlayStateChange, false); + + this.deleteAndStopStartedRecording(); + + this.searchManagerObj = oipfObjectFactory.createSearchManagerObject(); + + this.transitions = []; + this.previousState = null; + this.currentIndex = 0; + }, + + afterTest: function(resolve, reject) { + this.recordingSchedulerObject + .removeEventListener("PVREvent", this.onPVREventCopy); + this.recordingSchedulerObject.stop(this.recording); + this.recordingSchedulerObject.remove(this.recording); + }, + + onPVREvent: function(resolve, reject, newState, recordings) { + if (this.currentIndex < this.transitions.length) { + console.log("PVREvent received: State:", newState); + var currentTransition = this.transitions[this.currentIndex]; + var begin = currentTransition.begin; + var end = currentTransition.end; + + if (begin == this.previousState && end == newState) { + currentTransition.callback && currentTransition.callback(); + this.previousState = newState; + this.currentIndex++; + } else { + reject("Invalid state."); + } + } else { + console.log("Any others transitions have been set."); + } + }, + + testRecordAFinishedProgramme: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findAFinishedProgramme.bind(this)) + .then(this.timeout.bind(this)) + .then(function() { + self.recording = self.recordingSchedulerObject.record(self.programme); + if (self.assertEquals(self.recording, null)) { + resolve(); + } else { + reject(); + } + }); + }, + + testRecordCurrentProgramme: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + console.log("Addtion of transition."); + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED); + self.addTransition(self.STARTED, self.COMPLETED, resolve); + + self.recording = self.recordingSchedulerObject.record(self.programme); + console.log("Recording State after scheduling:", self.recording.state); +// console.log("Recording:", self.recording); + }); + }, + + testRecordAtCurrentProgramme: function(resolve, reject) { + this.addTransition(null, this.SCHEDULED); + this.addTransition(this.SCHEDULED, this.BEFORE_STARTED); + this.addTransition(this.BEFORE_STARTED, this.STARTED); + this.addTransition(this.STARTED, this.COMPLETED, resolve); + var channelConfig = this.vidBroadObj.getChannelConfig(); + var randomIndex = oipf.utils + .getRandomNumberBetweenMinMax(0, channelConfig.channelList.length); + var channel = channelConfig.channelList[randomIndex]; + var currentTime = Math.round(this.dateUtils.nowInSeconds()); + this.recording = this.recordingSchedulerObject.recordAt(currentTime, + 1*60, 0x00, channel.ccid); + console.log(this.recording); + }, + + testStopAScheduledRecording: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED, function() { + self.recordingSchedulerObject.stop(self.recording); + self.timeout(2000).then(resolve); + }); + + self.recording = self.recordingSchedulerObject.record(self.programme); + }); + }, + + testStopAnOngoingRecording: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED, function() { + self.recordingSchedulerObject.stop(self.recording); + self.timeout(2000).then(resolve); + }); + + self.recording = self.recordingSchedulerObject.record(self.programme); + }); + }, + + testStopACompletedRecording: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED); + self.addTransition(self.STARTED, self.COMPLETED, function() { + self.recordingSchedulerObject.stop(self.recording); + self.timeout(3000).then(resolve); + }); + + self.recording = self.recordingSchedulerObject.record(self.programme); + }); + }, + + testRemoveAScheduledRecording: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED, function () { + self.recordingSchedulerObject.remove(self.recording); + }); + self.addTransition(self.SCHEDULED, self.REMOVED, resolve); + + self.recording = self.recordingSchedulerObject + .record(self.programme); + }); + }, + + testRemoveAnOngoingRecording: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED, function() { + self.recordingSchedulerObject.remove(self.recording); + }); + self.addTransition(self.STARTED, self.REMOVED, resolve); + + self.recording = self.recordingSchedulerObject + .record(self.programme); + }); + }, + + testRemoveACompletedRecording: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED); + self.addTransition(self.STARTED, self.COMPLETED, function () { + self.recordingSchedulerObject.remove(self.recording); + }); + self.addTransition(self.COMPLETED, self.REMOVED, resolve); + self.recording = self.recordingSchedulerObject.record(self.programme); + }); + }, + + testUpdateAScheduledRecordingOnStartTime: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED, function () { + var twentyMinutes = 20 * 60; + self.recordingSchedulerObject.update(self.recording.id, + self.recording.startTime + twentyMinutes, undefined, + undefined); + }); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED); + self.addTransition(self.STARTED, self.COMPLETED); + self.recording = self.recordingSchedulerObject.record(self.programme); + }); + }, + + testUpdateAScheduledRecordingOnDuration: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED, function () { + var twentyMinutes = 20 * 60; + self.recordingSchedulerObject.update(self.recording.id, + undefined, self.recording.duration + twentyMinutes, + undefined); + }); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED); + self.addTransition(self.STARTED, self.COMPLETED); + self.recording = self.recordingSchedulerObject.record(self.programme); + }); + }, + + testUpdateAnOngoingRecordingWithAValidDuration: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED, function () { + var oneMinute = 1 * 60; + var result = self.recordingSchedulerObject.update(self.recording.id, + undefined, self.recording.duration + oneMinute, + undefined); + if (self.assertEquals(result, true)) { + resolve(); + } else { + reject(); + } + }); + self.recording = self.recordingSchedulerObject + .record(self.programme); + }); + }, + + testUpdateAnOngoingRecordingWithATooShortDuration: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED, function () { + var oneMinute = 1 * 60; + var result = self.recordingSchedulerObject.update( + self.recording.id, undefined, oneMinute, undefined); + if (self.assertEquals(result, false)) { + resolve(); + } else { + reject(); + } + }); + self.recording = self.recordingSchedulerObject + .record(self.programme); + }); + }, + + testUpdateAnOngoingRecordingOnStartTime: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED, function () { + + var result = self.recordingSchedulerObject.update(self.recording.id, + 564, undefined, undefined); + if (self.assertEquals(result, false)) { + resolve(); + } else { + reject(); + } + }); + self.recording = self.recordingSchedulerObject + .record(self.programme); + }); + }, + + + testUpdateAnOngoingRecordingOnRepeatDays: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED, function () { + var result = self.recordingSchedulerObject.update( + self.recording.id, undefined, undefined, 0x00); + + if (self.assertEquals(result, false)) { + resolve(); + } else { + reject(); + } + }); + self.recording = self.recordingSchedulerObject + .record(self.programme); + }); + }, + + testUpdateACompletedRecordingOnDuration: function(resolve, reject) { + var self = this; + + this.getPromise() + .then(this.bindToCurrentChannel.bind(this)) + .then(this.timeout.bind(this)) + .then(this.findProgrammeFromStream.bind(this, resolve, reject)) + .then(this.timeout.bind(this)) + .then(function() { + self.resetTransitionVariables(); + self.addTransition(null, self.SCHEDULED); + self.addTransition(self.SCHEDULED, self.BEFORE_STARTED); + self.addTransition(self.BEFORE_STARTED, self.STARTED); + self.addTransition(self.STARTED, self.COMPLETED, function () { + var twentyMinutes = 20 * 60; + var result = self.recordingSchedulerObject + .update(self.recording.id, undefined, + self.recording.duration + twentyMinutes, + undefined); + + if (self.assertEquals(result, false)) { + resolve(); + } else { + reject(); + } + }); + + self.recording = self.recordingSchedulerObject + .record(self.programme); + }); + }, + + bindToCurrentChannel: function() { + this.previousState = this.UNREALIZED; + this.addTransition(this.UNREALIZED, this.CONNECTING); + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + console.log("Binding with current channel succeeded."); + }); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + findAFinishedProgramme: function() { + var self = this; + var metadataSearch = self.searchManagerObj. + createSearch(self.SCHEDULED_CONTENT); + var now = Math.round(Date.now() / 1000); + var query = metadataSearch.createQuery("Programme.startTime", 4, now); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 4; + metadataSearch.result.getResults(offset, count); + + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (!self.assertEquals(search.result.length, 0)) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + self.programme = search.result[0]; + console.log(self.programme); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + } + break; + + default: + console.log("Unknow state"); + reject(); + } + }; + }, + + findProgrammeFromStream: function() { + var searchTarget = 1; + var metaDataSearch = this.searchManagerObj.createSearch(searchTarget); + var currentChannel = this.vidBroadObj.currentChannel; + var startTime = null; + metaDataSearch.findProgrammesFromStream(currentChannel, startTime, 1); + var offset = 0; + var count = 1; + metaDataSearch.result.getResults(offset, count); + var self = this; + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (self.assertNotNull(search.result[0])) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + self.programme = search.result[0]; + console.log(self.programme); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + } + break; + + default: + console.log("Unknow state"); + } + }; + }, + + resetTransitionVariables: function() { + this.currentIndex = 0; + this.transitions = []; + this.previousState = null; + } +}); + + Added: oipf/test/js/SearchManagerTest.js =================================================================== --- oipf/test/js/SearchManagerTest.js (rev 0) +++ oipf/test/js/SearchManagerTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,694 @@ +/* + * Description: + * This class gather a set of method necessary to test a search manager object. + * + */ +var SearchManagerTest = TestCase.extend({ + + UNREALIZED: 0, + + CONNECTING: 1, + + PRESENTING: 2, + + STOPPED: 3, + + searchManagerObj: null, + + init: function() { + this.super.init(); + }, + + beforeTest: function(resolve, reject) { + this.searchManagerObj = oipfObjectFactory.createSearchManagerObject(); + this.vidBroadObj = oipfObjectFactory.createVideoBroadcastObject(); + this.onPlayStateChange = this.onChangeState.bind(this, resolve, reject); + this.vidBroadObj.addEventListener("PlayStateChange", this.onPlayStateChange, false); + this.transitions = []; + this.previousState = this.vidBroadObj.playState; + this.currentIndex = 0; + this.channel = null; + logTest("State: Pending"); + }, + + afterTest: function(resolve, reject) { + this.vidBroadObj.removeEventListener("PlayStateChange", + this.onPlayStateChange); + this.searchManagerObj.removeEventListener("MetadataSearch", + this.onPlayStateChange); + this.timerManager.clearTimer(); + }, + + testFindAFinishedProgramme: function(resolve, reject) { + var self = this; + var metadataSearch = self.searchManagerObj. + createSearch(self.SCHEDULED_CONTENT); + var now = Math.round(Date.now() / 1000); + var query = metadataSearch.createQuery("Programme.startTime", 4, now); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 4; + metadataSearch.result.getResults(offset, count); + + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (!self.assertEquals(search.result.length, 0)) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + resolve(); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + reject(); + } + break; + + default: + console.log("Unknow state"); + reject(); + } + }; + + }, + + testGetCurrentProgrammeFromStream: function (resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + + var stat = "Pending"; + logTest("State: " + stat); + var searchTarget = 1; + var metaDataSearch = self.searchManagerObj.createSearch(searchTarget); + var currentChannel = self.vidBroadObj.currentChannel; + var startTime = null; + metaDataSearch.findProgrammesFromStream(currentChannel, startTime); + var offset = 0; + var count = 1; + metaDataSearch.result.getResults(offset, count); +// console.log(metaDataSearch.result[0]);//Must return undefined else wrong implementation of getResults method + }); + + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (self.assertNotNull(search.result[0])) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + resolve(); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + reject(); + } + break; + + case 3: + var message = "[INFO] MetadataSearch in Idle state because of either search abort or parameters have been modified (query, constraints or search target)"; + console.log(message); + reject(); + break; + + case 4: + message = "[INFO] The search cannot be complete because of lack of ressources or any other reason."; + console.log(message); + reject(); + break; + + default: + console.log("Unknow state"); + reject(); + + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testSearchingForASpecificProgrammeByName: function(resolve, reject) { + var self = this; + var value = "X:enius"; + + var stat = "Pending"; + logTest("State: " + stat); + var metadataSearch = self.searchManagerObj. + createSearch(self.SCHEDULED_CONTENT); + + var query = metadataSearch.createQuery("Programme.name", 0, value); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 1; + metadataSearch.result.getResults(offset, count); + + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (self.assertNotNull(search.result[0]) && + self.assertEquals(search.result[0].name, value)) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + resolve(); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + reject(); + } + break; + + case 3: + var message = "[INFO] MetadataSearch in Idle state because of either search abort or parameters have been modified (query, constraints or search target)"; + console.log(message); + reject(); + break; + + case 4: + message = "[INFO] The search cannot be complete because of lack of ressources or any other reason."; + console.log(message); + reject(); + break; + + default: + console.log("Unknow state"); + reject(); + + } + }; + +// this.vidBroadObj.bindToCurrentChannel(); + + }, + + testSearchingForProgrammesWithDurationLowerThanOneHour: function(resolve, reject) { + var self = this; + var value = 3600; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + + var stat = "Pending"; + logTest("State: " + stat); + var metadataSearch = self.searchManagerObj. + createSearch(self.SCHEDULED_CONTENT); + + var query = metadataSearch.createQuery("Programme.duration", 4, + value); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 6; + metadataSearch.result.getResults(offset, count); +// //Must return undefined else wrong implementation of getResults method +// console.log(metaDataSearch.result[0]); + }); + + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (self.assertEquals(search.result.length, 6)) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + resolve(); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + reject(); + } + break; + + default: + console.log("Unknow state"); + reject(); + + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testAbortWhileProgrammesSearchWithoutConstraints: function(resolve, reject) { + var value = 3600; + var self = this; + var stat = "Pending"; + logTest("State: " + stat); + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + var query = metadataSearch.createQuery("duration", 4, value); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 6; + metadataSearch.result.getResults(offset, count); +// //Must return undefined else wrong implementation of getResults method +// console.log(metadataSearch.result[0]); + metadataSearch.result.abort(); + resolve(); + + + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (self.assertEquals(search.result.length, 6)) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + resolve(); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + reject(); + } + break; + + case 3: + var message = "[INFO] MetadataSearch in Idle state because of either search abort or parameters have been modified (query, constraints or search target)"; + console.log(message); + break; + + default: + console.log("Unknow state"); + reject(); + + } + }; + + }, + + testSetQueryWhileSearchWithoutConstraints: function(resolve, reject) { + var value = 3600; + var stat = "Pending"; + logTest("State: " + stat); + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + var query = metadataSearch.createQuery("duration", 4, value); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 6; + metadataSearch.result.getResults(offset, count); +// //Must return undefined else wrong implementation of getResults method +// console.log(metadataSearch.result[0]); + metadataSearch.setQuery(query); + + if (this.assertEquals(metadataSearch.result.length, 0)) { + resolve(); + } else { + reject(); + } + + }, + + testFindProgrammesFromStreamWhileSearchWithoutConstraints: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + + var stat = "Pending"; + logTest("State: " + stat); + var searchTarget = 1; + var metadataSearch = self.searchManagerObj.createSearch(searchTarget); + + var currentChannel = self.vidBroadObj.currentChannel; + var startTime = null; + metadataSearch.findProgrammesFromStream(currentChannel, startTime); + + var offset = 0; + var count = 1; + metadataSearch.result.getResults(offset, count); + + metadataSearch.findProgrammesFromStream(currentChannel, startTime); + + if (self.assertEquals(metadataSearch.result.length, 0)) { + resolve(); + } else { + reject(); + } + }); + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testAddChannelConstraintWhileSearchWithoutConstraints: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + + var stat = "Pending"; + logTest("State: " + stat); + var searchTarget = 1; + var metadataSearch = self.searchManagerObj + .createSearch(searchTarget); + + var currentChannel = self.vidBroadObj.currentChannel; + var startTime = null; + metadataSearch.findProgrammesFromStream(currentChannel, startTime); + + var offset = 0; + var count = 1; + metadataSearch.result.getResults(offset, count); + + metadataSearch.addChannelConstraint(currentChannel); + + if (self.assertEquals(metadataSearch.result.length, 0)) { + resolve(); + } else { + reject(); + } + }); + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testRemoveChannelConstraintWhileSearchWithoutConstraints: function(resolve, reject) { + var value = 3600; + var stat = "Pending"; + logTest("State: " + stat); + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + var query = metadataSearch.createQuery("duration", 4, value); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 6; + metadataSearch.result.getResults(offset, count); + metadataSearch.addChannelConstraint(null); + + if (this.assertEquals(metadataSearch.result.length, 0)) { + resolve(); + } else { + reject(); + } + + }, + + testGetCurrentProgrammeFromNullStream: function (resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + + var stat = "Pending"; + logTest("State: " + stat); + var searchTarget = 1; + var metaDataSearch = self.searchManagerObj.createSearch(searchTarget); + var currentChannel = null; + var startTime = null; + new Promise(function (resolve, reject) { + metaDataSearch.findProgrammesFromStream(currentChannel, startTime); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + }); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testCreateSearchForScheduledContent: function(resolve, reject) { + this.metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + if (this.assertNotNull(this.metadataSearch) && + this.assertEquals(this.metadataSearch.searchTarget, + this.SCHEDULED_CONTENT)) { + resolve(); + } else { + reject(); + } + }, + + testCreateSearchForContentOnDemand: function(resolve, reject) { + this.metadataSearch = this.searchManagerObj. + createSearch(this.CONTENT_ON_DEMAND); + + if (this.assertNotNull(this.metadataSearch) && + this.assertEquals(this.metadataSearch.searchTarget, + this.CONTENT_ON_DEMAND)) { + resolve(); + } else { + reject(); + } + }, + + testCreateSearchWithNull: function(resolve, reject) { + this.metadataSearch = this.searchManagerObj. + createSearch(null); + + if (!this.assertNotNull(this.metadataSearch)) { + resolve(); + } else { + reject(); + } + }, + + testCreateSearchWithString: function(resolve, reject) { + this.metadataSearch = this.searchManagerObj. + createSearch("1"); + + if (!this.assertNotNull(this.metadataSearch)) { + resolve(); + } else { + reject(); + } + }, + + testCreateSearchWithZero: function(resolve, reject) { + this.metadataSearch = this.searchManagerObj. + createSearch(0); + + if (!this.assertNotNull(this.metadataSearch)) { + resolve(); + } else { + reject(); + } + }, + + testCreateQueryWithWellArguments: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + var query = metadataSearch.createQuery("name", 0, "X:ENIUS"); + + if (this.assertNotNull(query)) { + resolve(); + } else { + reject(); + } + + }, + + testCreateQueryWithoutParameters: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + new Promise(function (resolve, reject) { + var query = metadataSearch.createQuery(); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + + }, + + testCreateQueryWithFieldArgumentNull: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + + new Promise(function (resolve, reject) { + var query = metadataSearch.createQuery(null, 0, "X:ENIUS"); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + + }, + + testCreateQueryWithIntegerFieldArgument: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + + new Promise(function (resolve, reject) { + var query = metadataSearch.createQuery(10, 0, "X:ENIUS"); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + + }, + + testCreateQueryWithComparisonArgumentNull: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + + new Promise(function (resolve, reject) { + metadataSearch.createQuery("name", null, "X:ENIUS"); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + + }, + + testCreateQueryWithStringComparisonArgument: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + + new Promise(function (resolve, reject) { + metadataSearch.createQuery("name", "null", "X:ENIUS"); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + + }, + + testCreateQueryWithValueArgumentNull: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + new Promise(function (resolve, reject) { + metadataSearch.createQuery("name", 0, null); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + + }, + + testAnd: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + var queryA = metadataSearch.createQuery("name", 0, "X:ENIUS"); + var queryB = metadataSearch.createQuery("name", 0, "X:ENIUS"); + + var newQuery = queryA.and(queryB); + + if (this.assertNotNull(newQuery) && + !this.assertEquals(newQuery, queryA)) { + + resolve(); + } else { + reject(); + } + + }, + + testOr: function(resolve, reject) { + var metadataSearch = this.searchManagerObj. + createSearch(this.SCHEDULED_CONTENT); + + var queryA = metadataSearch.createQuery("name", 0, "X:ENIUS"); + var queryB = metadataSearch.createQuery("name", 0, "X:ENIUS"); + + var newQuery = queryA.or(queryB); + + if (this.assertNotNull(newQuery) && + !this.assertEquals(newQuery, queryA)) { + + resolve(); + } else { + reject(); + } + + }, + + testProgrammePropertiesImplementationState: function() { + var self = this; + var value = "X:ENIUS"; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + + var stat = "Pending"; + logTest("State: " + stat); + var metadataSearch = self.searchManagerObj. + createSearch(self.SCHEDULED_CONTENT); + + var query = metadataSearch.createQuery("Programme.name", 0, + value); + metadataSearch.setQuery(query); + + var offset = 0; + var count = 1; + metadataSearch.result.getResults(offset, count); +// //Must return undefined else wrong implementation of getResults method +// console.log(metaDataSearch.result[0]); + }); + + this.searchManagerObj.onMetadataSearch = function(search, state) { + + console.log("[INFO]: onMetadataSearch called"); + + switch (state) { + + case 0: + if (self.assertNotNull(search.result[0]) && + self.assertEquals(search.result[0].name, value)) { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: found"); + resolve(); + } else { + console.log("[TEST-RUNNING][Info] Label: Obtain current program according to oipf norm, State: not found"); + reject(); + } + break; + + case 3: + var message = "[INFO] MetadataSearch in Idle state because of either search abort or parameters have been modified (query, constraints or search target)"; + console.log(message); + reject(); + break; + + case 4: + message = "[INFO] The search cannot be complete because of lack of ressources or any other reason."; + console.log(message); + reject(); + break; + + default: + console.log("Unknow state"); + reject(); + + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + } + +}); \ No newline at end of file Added: oipf/test/js/Test.js =================================================================== --- oipf/test/js/Test.js (rev 0) +++ oipf/test/js/Test.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,1149 @@ +/* + * 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. + */ +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: "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 unrealized state.", + method: "testPrevChannelInUnrealized" + }, + { + label: "Switch to precedent channel in connecting state.", + method: "testPrevChannelInConnecting" + }, + { + label: "Switch to precedent channel in presenting state.", + method: "testPrevChannelInPresenting" + }, + { + label: "Switch to precedent channel in stopped state.", + method: "testPrevChannelInStopped" + }, + { + label: "Switch to next channel in unrealized state.", + method: "testNextChannelInUnrealized" + }, + { + label: "Switch to next channel in connecting state.", + method: "testNextChannelInConnecting" + }, + { + label: "Switch to next channel in presenting state.", + method: "testNextChannelInPresenting" + }, + { + label: "Switch to next channel in stopped state.", + method: "testNextChannelInStopped" + }, + { + label: "Release any tuner and/or ressources held by a video broadcast object in connecting.", + method: "testReleaseInConnecting" + }, + { + label: "Release any tuner and/or ressources held by a video broadcast object in presenting.", + method: "testReleaseInPresenting" + }, + { + label: "Release any tuner and/or ressources held by a video broadcast object in stopped.", + method: "testReleaseInStopped" + }, + { + label: "Stop the video and audio presentation of video broadcast object in connecting.", + method: "testStopInConnecting" + }, + { + label: "Stop the video and audio presentation of video broadcast object in presenting.", + method: "testStopInPresenting" + }, + { + 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 unrealized state.", + method: "testSetChannelInUnrealized" + }, + { + label: "Set a channel in connecting state.", + method: "testSetChannelInConnecting" + }, + { + label: "Call method 'setChannel' with null in connecting state.", + method: "testSetChannelInConnectingWithNull" + }, + { + label: "Set a channel in presenting state.", + method: "testSetChannelInPresenting" + }, + { + label: "Call method 'setChannel' with null in presenting state.", + method: "testSetChannelInPresentingWithNull" + }, + { + label: "Set a channel in stopped state.", + method: "testSetChannelInStopped" + }, + { + label: "Call method 'setChannel' with null in stopped state.", + method: "testSetChannelInStoppedWithNull" + } + ]},{ + name: "SearchManagerTest", + object: new SearchManagerTest(), + tests: [ + { + label: "Verify the right creation of search object.", + method: "testCreateSearchForScheduledContent" + }, + { + label: "Verify the right creation of search object about content on demand.", + method: "testCreateSearchForContentOnDemand" + }, + { + label: "Call method 'createSearch' with parameter equals to null.", + method: "testCreateSearchWithNull" + }, + { + label: "Call method 'createSearch' with a String parameter.", + method: "testCreateSearchWithString" + }, + { + label: "Call method 'createSearch' with parameter equals to 0.", + method: "testCreateSearchWithZero" + }, + { + label: "Looking for a programme already broadcasted.", + method: "testFindAFinishedProgramme" + }, + { + label: "Obtain current program according to oipf norm.", + method: "testGetCurrentProgrammeFromStream" + }, + { + label: "Try to obtain current program with a null stream.", + method: "testGetCurrentProgrammeFromNullStream" + }, + { + label: "Try to obtain a programme by its name.", + method: "testSearchingForASpecificProgrammeByName" + }, + { + label: "Try to obtain all programme \n\ + with duration lower than one hour.", + method: "testSearchingForProgrammesWithDurationLowerThanOneHour" + }, + { + label: "Create a query with well parameters.", + method: "testCreateQueryWithWellArguments" + }, + { + label: "Create a query with well parameters.", + method: "testCreateQueryWithoutParameters" + }, + { + label: "Create a query with its first parameters null.", + method: "testCreateQueryWithFieldArgumentNull" + }, + { + label: "Create a query with a Integer as first parameter.", + method: "testCreateQueryWithIntegerFieldArgument" + }, + { + label: "Create a query with its second parameters.", + method: "testCreateQueryWithComparisonArgumentNull" + }, + { + label: "Create a query with a String as second parameters.", + method: "testCreateQueryWithStringComparisonArgument" + }, + { + label: "Create a query with its last parameters.", + method: "testCreateQueryWithValueArgumentNull" + }, + { + label: "Modify query while search performing by calling 'setQuery'.", + method: "testSetQueryWhileSearchWithoutConstraints" + }, + { + label: "Call 'findProgrammesFromStream' while search performing.", + method: "testFindProgrammesFromStreamWhileSearchWithoutConstraints" + }, + { + label: "Call 'addChannelConstraint' while search performing.", + method: "testAddChannelConstraintWhileSearchWithoutConstraints" + }, + { + label: "Call 'removeChannelConstraint' while search performing.", + method: "testRemoveChannelConstraintWhileSearchWithoutConstraints" + }, + { + label: "Abort a search.", + method: "testAbortWhileProgrammesSearchWithoutConstraints" + }, + { + label: "Call method 'or' of a 'Query' object.", + method: "testAnd" + }, + { + label: "Call method 'and' of a 'Query' object.", + method: "testOr" + } + ]},{ + name: "ConfigurationTest", + object: new ConfigurationTest(), + tests: [ + { + label: "Call method 'setScreenSize' with right parameters(Type and value).", + method: "testSetScreenSize" + }, + { + label: "Call method 'setScreenSize' without parameters.", + method: "testSetScreenSizeWithoutParameters" + }, + { + label: "Call method 'setScreenSize' with 'String' parameters.", + method: "testSetScreenSizeWithUnexpectedTypeParameters" + }, + { + label: "Call method 'setScreenSize' with an excessive number of parameters.", + method: "testSetScreenSizeWithExcessiveParametersNumber" + }, + { + label: "Call method 'setTvStandard' with right parameters(Type and value).", + method: "testSetTvStandard" + }, + { + label: "Call method 'setTvStandard' without parameters.", + method: "testSetTvStandardWihtoutParameters" + }, + { + label: "Call method 'setTvStandard' with wrong parameters(Type).", + method: "testSetTvStandardWithUnexpectedTypeParameters" + }, + { + label: "Call method 'setTvStandard' with an excessive number of parameters.", + method: "testSetTvStandardWithExcessiveParametersNumber" + }, + { + label: "Call method 'setPvrSupport' with right parameters(Type and value).", + method: "testSetPvrSupport" + }, + { + label: "Call method 'setPvrSupport' without parameters.", + method: "testSetPvrSupportWithoutParameters" + }, + { + label: "Call method 'setPvrSupport' with wrong parameters(Type).", + method: "testSetPvrSupportWithUnexpectedTypeParameters" + }, + { + label: "Call method 'setPvrSupport' with an excessive number of parameters.", + method: "testSetPvrSupportWithExcessiveParametersNumber" + }, + { + label: "Call method 'setPowerState' with right parameters(Type and value).", + method: "testSetPowerState" + }, + { + label: "Call method 'setPowerState' without parameters.", + method: "testSetPowerStateWithoutParameters" + }, + { + label: "Call method 'setPowerState' with wrong parameters(Type).", + method: "testSetPowerStateWithUnexpectedTypeParameters" + }, + { + label: "Call method 'setPowerState' with an excessive number of parameters.", + method: "testSetPowerStateWithExcessiveParametersNumber" + }, + { + label: "Call method 'setDigestCredentials' with right parameters(Type and value).", + method: "testSetDigestCredentials" + }, + { + label: "Call method 'setDigestCredentials' without parameters.", + method: "testSetDigestCredentialsWithoutParameters" + }, + { + label: "Call method 'setDigestCredentials' with wrong parameters(Type).", + method: "testSetDigestCredentialsWithUnexpectedTypeParameters" + }, + { + label: "Call method 'setDigestCredentials' with an excessive number of parameters.", + method: "testSetDigestCredentialsWithExcessiveParametersNumber" + }, + { + label: "Call method 'clearDigestCredentials' with right parameters(Type and value).", + method: "testClearDigestCredentials" + }, + { + label: "Call method 'clearDigestCredentials' without parameters.", + method: "testClearDigestCredentialsWithoutParameters" + }, + { + label: "Call method 'clearDigestCredentials' with wrong parameters(Type).", + method: "testClearDigestCredentialsWithUnexpectedTypeParameters" + }, + { + label: "Call method 'clearDigestCredentials' with an excessive number of parameters.", + method: "testClearDigestCredentialsWithExcessiveParametersNumber" + }, + { + label: "Call method 'hasDigestCredentials' with right parameters(Type and value).", + method: "testHasDigestCredentials" + }, + { + label: "Call method 'hasDigestCredentials' without parameters.", + method: "testHasDigestCredentialsWithoutParameters" + }, + { + label: "Call method 'hasDigestCredentials' with wrong parameters(Type).", + method: "testHasDigestCredentialsWithUnexpectedTypeParameters" + }, + { + label: "Call method 'hasDigestCredentials' with an excessive number of parameters.", + method: "testHasDigestCredentialsWithExcessiveParametersNumber" + } + ]},{ + name: "RecordingSchedulerTest", + object: new RecordingSchedulerTest(), + tests: [ + { + label: "Call method 'setRecord' in order to record current programme.", + method: "testRecordCurrentProgramme" + }, + { + label: "Try to call method 'setRecord' with a finished programme.", + method: "testRecordAFinishedProgramme" + }, + { + label: "Call method 'setRecordAt' in order to record current programme.", + method: "testRecordAtCurrentProgramme" + }, + { + label: "Call method 'stop' after a scheduling recording.", + method: "testStopAScheduledRecording" + }, + { + label: "Call method 'stop' while a recording.", + method: "testStopAnOngoingRecording" + }, + { + label: "Call method 'stop' at the end of a recording.", + method: "testStopACompletedRecording" + }, + { + label: "Call method 'remove' after a scheduling recording.", + method: "testRemoveAScheduledRecording" + }, + { + label: "Call method 'remove' while a recording.", + method: "testRemoveAnOngoingRecording" + }, + { + label: "Call method 'remove' at the end of a recording.", + method: "testRemoveACompletedRecording" + }, + { + label: "Call method 'update' to update start time of a scheduled recording", + method: "testUpdateAScheduledRecordingOnStartTime" + }, + { + label: "Call method 'update' to update duration of a scheduled recording.", + method: "testUpdateAScheduledRecordingOnDuration" + }, + { + label: "Call method 'update' to update duration of an in-progress recording.", + method: "testUpdateAnOngoingRecordingWithAValidDuration" + }, + { + label: "Call method 'update' to update duration of an in-progress recording with a short duration.", + method: "testUpdateAnOngoingRecordingWithATooShortDuration" + }, + { + label: "Call method 'update' to update start time of an in-progress recording.", + method: "testUpdateAnOngoingRecordingOnStartTime" + }, + { + label: "Call method 'update' to update repetition frequency of an in-progress recording.", + method: "testUpdateAnOngoingRecordingOnRepeatDays" + } + ]},{ + name: "CapabilitiesTest", + object: new CapabilitiesTest(), + tests: [ + { + label: "Call method 'hasCapability' with an invalid profile name.", + method: "testHasCapabilityWithAnInvalidProfileName" + }, + { + label: "Call method 'hasCapability' to verify that the TV support at least one of pre-defined base UI profiles.", + method: "testHasCapabilityForAtLeastOneBaseProfileName" + }, + { + label: "Call method 'hasCapability' to verify if the TV support all pre-defined UI fragments profiles.", + method: "testHasCapabilityForAllUIFragmentProfile" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'TRICKMODE'.", + method: "testHasCapabilityTRICKMODE" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'AVCAD'.", + method: "testHasCapabilityAVCAD" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'DL'.", + method: "testHasCapabilityDL" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'IPTV_SDS'.", + method: "testHasCapabilityIPTV_SDS" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'IPTV_URI'.", + method: "testHasCapabilityIPTV_URI" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'ANA'.", + method: "testHasCapabilityANA" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'DVB_C'.", + method: "testHasCapabilityDVB_C" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'DVB_T'.", + method: "testHasCapabilityDVB_T" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'DVB_S'.", + method: "testHasCapabilityDVB_S" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'DVB_C2'.", + method: "testHasCapabilityDVB_C2" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'DVB_T2'.", + method: "testHasCapabilityDVB_T2" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'DVB_S2'.", + method: "testHasCapabilityDVB_S2" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'ISDB_C'.", + method: "testHasCapabilityISDB_C" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'ISDB_T'.", + method: "testHasCapabilityISDB_T" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'ISDB_S'.", + method: "testHasCapabilityISDB_S" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'META_BCG'.", + method: "testHasCapabilityMETA_BCG" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'META_EIT'.", + method: "testHasCapabilityMETA_EIT" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'META_SI'.", + method: "testHasCapabilityMETA_SI" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'ITV_KEYS'.", + method: "testHasCapabilityITV_KEYS" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature 'CONTROLLED'.", + method: "testHasCapabilityCONTROLLED" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'PVR').", + method: "testHasCapabilityPVR" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'DRM').", + method: "testHasCapabilityDRM" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'CommunicationServices').", + method: "testHasCapabilityCommunicationServices" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'SVG').", + method: "testHasCapabilitySVG" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'POINTER').", + method: "testHasCapabilityPOINTER" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'POLLNOTIF').", + method: "testHasCapabilityPOLLNOTIF" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'HTML5_MEDIA').", + method: "testHasCapabilityHtml5Media" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'WIDGETS').", + method: "testHasCapabilityWIDGETS" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'RCF').", + method: "testHasCapabilityRCF" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'TELEPHONY').", + method: "testHasCapabilityTELEPHONY" + }, + { + label: "Call method 'hasCapability' to verify if the TV support the feature recording(UI profile name fragment: 'VIDEOTELEPHONY').", + method: "testHasCapabilityVIDEOTELEPHONY" + } + ]},{ + name: "ParentalControlManagerTest", + object: new ParentalControlManagerTest(), + tests: [ + { + label: "Call method 'setParentalControlPIN' with valids parameters.", + method: "testSetParentalControlPINWithValidOldPINAndNewPIN" + }, + { + label: "Call method 'setParentalControlPIN' with a invalid pin but a valid new pin.", + method: "testSetParentalControlPINWithInvalidOldPINAndValidNewPIN" + }, + { + label: "Call method 'setParentalControlPIN' with a invalid pin but a valid new pin.", + method: "testSetParentalControlPINWithInvalidOldPINAndValidNewPIN10Times" + }, + { + label: "Call method 'verifyParentalControlPIN' with an invalid pin 10 times.", + method: "testVerifyParentalControlPINWithInvalidPIN10Times" + }, + { + label: "Call method 'verifyParentalControlPIN' with a valid pin.", + method: "testVerifyParentalControlPINWithValidPIN" + }, + { + label: "Call method 'verifyParentalControlPIN' with an invalid pin.", + method: "testVerifyParentalControlPINWithInvalidPIN" + }, + { + label: "Call method 'setBlockUnrated' with an invalid pin.", + method: "testSetBlockUnratedWithInvalidPIN10Times" + }, + { + label: "Call method 'getBlockUnrated' when contents have not been blocked.", + method: "testGetBlockUnratedWhenUnratedContentsAreNotBlocked" + }, + { + label: "Call method 'getBlockUnrated' when contents have been blocked.", + method: "testGetBlockUnratedWhenUnratedContentsAreBlocked" + }, + { + label: "Call method 'setBlockUnrated' with a valid pin and value 'true' to blocked unrated contents.", + method: "testSetBlockUnratedWithValidPINAndTrue" + }, + { + label: "Call method 'setBlockUnrated' with a valid pin and value 'false' to don't blocked unrated contents.", + method: "testSetBlockUnratedWithValidPINAndFalse" + }, + { + label: "Call method 'setBlockUnrated' with an invalid pin and value 'true' to blocked unrated contents.", + method: "testSetBlockUnratedWithInvalidPINAndTrue" + }, + { + label: "Call method 'setBlockUnrated' with an invalid pin and value 'false' to don't blocked unrated contents.", + method: "testSetBlockUnratedWithInvalidPINAndFalse" + }, + { + label: "Call method 'setParentalControlStatus' with a valid pin\ + and value 'true' to active parental control.", + method: "testSetParentalControlStatusWithValidPINAndTrue" + }, + { + label: "Call method 'setParentalControlStatus' with a valid pin\ + and value 'false' to desactive parental control.", + method: "testSetParentalControlStatusWithValidPINAndFalse" + }, + { + label: "Call method 'setParentalControlStatus' with an invalid\ + pin and value 'true' to active parental control.", + method: "testSetParentalControlStatusWithInvalidPINAndTrue" + }, + { + label: "Call method 'setParentalControlStatus' with an invalid\ + pin and value 'false' to desactive parental control.", + method: "testSetParentalControlStatusWithInvalidPINAndFalse" + }, + { + label: "Call method 'setParentalControlStatus' with an invalid\ + pin and value 'false' to verify the PIN entry locking", + method: "testSetParentalControlStatusWithInvalidOldPINAndValidNewPIN10Times" + }, + { + label: "Call method 'getParentalControlStatus' when parental\ + control status is activated.", + method: "testGetParentalControlStatusWhenParentalControlStatusActivated" + }, + { + label: "Call method 'getParentalControlStatus' when parental\ + control status is deactivated.", + method: "testGetParentalControlStatusWhenParentalControlStatusDeactivated" + } + ]},{ + name: "ApplicationManagerTest", + object: new ApplicationManagerTest(), + tests: [ + { + label: "Call method 'getOwnerApplication' with 'object document' of global property 'window'.", + method: "testGetOwnerApplicationOfDocumentOfGlobalPropertyWindow" + }, + { + label: "Call method 'getOwnerApplication' with a parameter null.", + method: "testGetOwnerApplicationWithNull" + } + ] + }], + + init: function() { + this.animation = { + i: 1, + start: true, + intervalID: 0 + }; + + this.sectionsID = []; + }, + + runAll: function() { + this.results = []; + this.currentResult = { + succeeded: 0, + failed: 0 + }; + this.runLoop(0, 0).then(this.totalPercentage.bind(this)); + }, + + runLoop: 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) { + return self.runLoop(indexObject, indexTest + 1); + + } else if (indexObject < self.testsObjects.length - 1) { + element.results = { + testName: "", + failed: 0, + succeeded: 0 + }; + element.results.testName = element.name; + element.results.failed = self.currentResult.failed; + element.results.succeeded = self.currentResult.succeeded; + self.currentResult.failed = 0; + self.currentResult.succeeded = 0; + return self.runLoop(indexObject + 1, 0); + + } + if (indexObject == self.testsObjects.length - 1) { + element.results = { + testName: "", + failed: 0, + succeeded: 0 + }; + element.results.testName = element.name; + element.results.failed = self.currentResult.failed; + element.results.succeeded = self.currentResult.succeeded; + } + }; + + return this.updateTestResult(tests[indexTest], object) + .then(loop).catch(loop); + + }, + + percentageCalculating: function(currentResult) { + this.round = Math.round.bind(Math); + var testNumber = currentResult.failed + currentResult.succeeded; + currentResult.failed = this.round((currentResult.failed/testNumber)*100); + currentResult.succeeded = this.round((currentResult.succeeded/testNumber)*100); + }, + + totalPercentage: function() { + this.resultsPercentageFailed = 0; + this.resultsPercentageSucceeded = 0; + + for (var i = 0, l = this.testsObjects.length; i < l; i++) { + + this.percentageCalculating(this.testsObjects[i].results); + this.resultsPercentageFailed += this.testsObjects[i].results.failed; + this.resultsPercentageSucceeded += this.testsObjects[i].results.succeeded; + this.results.push(this.testsObjects[i].results); + } + this.resultsPercentageFailed = this.resultsPercentageFailed/this.testsObjects.length; + this.resultsPercentageSucceeded = this.resultsPercentageSucceeded/this.testsObjects.length; + this.displayGlobalTestResults(); + }, + + displayGlobalTestResults: function() { + var id = "globalTestResultsTable"; + var tableResult = document.getElementById(id); + var content; + content += "<table>"; + content += "<tbody>"; + content += "<thead>"; + content += "<tr>"; + content += "<th></th>"; + content += "<th>Succeeded (%)</th>"; + content += "<th>Failed (%)</th>"; + content += "</tr>"; + content += "</thead>"; + for (var i = 0, l = this.results.length; i < l; i++) { + content += "<tr>"; + content += "<th>" + this.results[i].testName + "</th>"; + content += "<td>" + this.results[i].succeeded + "</td>"; + content += "<td>" + this.results[i].failed + "</td>"; + content += "</tr>"; + } + content += "<tr>"; + content += "<th>Total</th>"; + content += "<td>" + this.resultsPercentageSucceeded + "</td>"; + content += "<td>" + this.resultsPercentageFailed + "</td>"; + content += "</tr>"; + content += "</tbody>"; + content += "</table>"; + + tableResult.innerHTML = content; + + var style = document.getElementById("globalTestResultsDiv").style; + style.display = (!style.display || style.display == "none") ? "block" : "none"; + }, + + 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; + var tests = element.tests; + + return this.updateTestResult(tests[indexTest], object); + }, + + displayInLineArray: function() { + var content = "<div id='testsDisplay'>"; + content += "<div id='title'><h1> Test Page</h1></div>"; + content += "<div id='testControllerDiv'>"; + content += "<div id='titleTestControllerDiv'><h4>Test Controller<h4></div>"; + content += "<button id='runAllBtn'>Run All</button>"; + content += "<button id='displayConfigBtn'>Hide/Show</button>"; + content += "<div id='globalTestResultsDiv'>"; + content += "<div id='titleGlobalTestResultsDiv'><h4>Global Test Results<h4></div>"; + content += "<table id='globalTestResultsTable'></table>"; + content += "</div>"; + content += "</div>"; + + var testsObjects = this.testsObjects; + content += "<div id=AllTestDiv>"; + + 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>"; + var idOfTestSection = currentObject.name + "Section"; + this.sectionsID.push(idOfTestSection); + + content += "<div id=" + idOfTestSection + ">"; + content += "<table id='" + currentObject.name + "Table'>"; + content += "<tbody>"; + content += "<thead>"; + content += "<tr>"; + content += "<th>Lauching</th>"; + content += "<th>Tested Method</th>"; + content += "<th>Label</th>"; + content += "<th>Test duration</th>"; + content += "<th>Result</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><button id='" + currentTest["method"] + "Btn" + "'>Run</button></td>"; + content += "<td>" + currentTest["method"] + "</td>"; + content += "<td>" + currentTest["label"] + "</td>"; + content += "<td id='" + currentTest["method"] + "Duration'>None</td>"; + content += "<td id='" + currentTest["method"] + "Result'>None</td>"; + content += "</tr>"; + } + content += "</tbody>"; + content += "</table>"; + content += "</div>"; + } + content += "</div>"; + content += "</div>"; + document.body.innerHTML += content; + }, + + updateTestResult: function(currentTest, object) { + console.group(currentTest["label"]); + var timeStart = new Date(); + var self = this; + var result = false; + var promiseTest = new Promise(function(resolve, reject) { + try { + timeout(object.timer || 5000) + .then(reject.bind(null, "No result returned.")) + .then(function() { + !result + && self.stopAnimationInProgress(currentTest) + && object.afterTest + && object.afterTest.bind(object); + self.currentResult && self.currentResult.failed++; + }); + object.beforeTest && object.beforeTest(resolve, reject); + object[currentTest["method"]] && object[currentTest["method"]](resolve, reject); + self.startAnimationInProgress(currentTest); + } catch (error) { + reject(error); + } + }) + .then(function(val) { + self.stopAnimationInProgress(currentTest); + result = true; + console.groupEnd(currentTest["label"]); + var timeEnd = new Date(); + self.currentResult && self.currentResult.succeeded++; + self.updateTestResultSuccess(timeStart, timeEnd, currentTest, val); + object.afterTest && object.afterTest(); + }) + .catch(function(val) { + self.stopAnimationInProgress(currentTest); + self.currentResult && self.currentResult.failed++; + result = true; + console.log(val); + console.groupEnd(currentTest["label"]); + var timeEnd = new Date(); + self.updateTestResultError(timeStart, timeEnd, currentTest, val); + object.afterTest && object.afterTest(); + }); + + return promiseTest; + }, + + updateTestResultSuccess: function(timeStart, timeEnd, currentTest, message) { + 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"; + document.getElementById(currentTest["method"] + "Result").style.backgroundColor = this.colorManaging(message); + document.getElementById(currentTest["method"] + "Duration").textContent = (timeEnd - timeStart).toFixed(2) + " ms"; + }, + + startAnimationInProgress: function(currentTest) { + var self = this; + + self.animation.intervalID = setInterval(function() { + var currentTestResult = document + .getElementById(currentTest["method"] + "Result"); + + if((self.animation.i%6) == 0) { + currentTestResult.textContent = "*"; + self.animation.i = 1; + } else { + if (self.animation.start) { + currentTestResult.textContent = "*"; + self.animation.start = false; + } else { + currentTestResult.textContent += "*"; + } + console.log("Test in progress"); + self.animation.i++; + } + + }, 500); + }, + + stopAnimationInProgress: function(object, currentTest) { + + clearInterval(this.animation.intervalID); + this.animation.id = 1; + this.animation.start = true; + this.animation.intervalID = null; + + }, + + colorManaging: function(errorMessage) { + var map = { + "No result returned.": "orange", + "Untestable case for the moment.": "sandybrown", + "Invalid state.": "orangered" + }; + + if (!errorMessage) { + return "red"; + } else if (typeof errorMessage == "string") { + return map[errorMessage]; + } else if (errorMessage instanceof Error) { + return "tomato"; + } + } + +}); + + Added: oipf/test/js/TestCase.js =================================================================== --- oipf/test/js/TestCase.js (rev 0) +++ oipf/test/js/TestCase.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,94 @@ +/* + * 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. + */ +var TestCase = Class.extend({ + + init: function() { + this.modelFactory = new ModelFactory(); + this.UNREALIZED = videoBroadcastConstants.state.UNREALIZED; + this.CONNECTING = videoBroadcastConstants.state.CONNECTING; + this.PRESENTING = videoBroadcastConstants.state.PRESENTING; + this.SCHEDULED = recordingConstants.state.SCHEDULED; + this.STARTED = recordingConstants.state.STARTED; + this.COMPLETED = recordingConstants.state.COMPLETED; + this.BEFORE_STARTED = recordingConstants.state.BEFORE_STARTED; + this.REMOVED = recordingConstants.state.REMOVED; + this.UPDATED = recordingConstants.state.UPDATED; + this.SCHEDULED_CONTENT = 1; + this.CONTENT_ON_DEMAND = 2; + this.dateUtils = new DateUtils(); + this.timerManager = new TimerManager(); + this.timeout = this.timerManager.createTimer.bind(this.timerManager); +// this.transitions = null; + }, + + assertNotUndefined : function(elmt) { + return elmt; + }, + + assertEquals: function(elmt1, elmt2) { + return elmt1 == elmt2; + }, + + assertNotNull: function(elmt) { + return elmt; + }, + + waitForError: function(callback, resolve) { + new Promise(function(resolve, reject) { + callback(); + }) + .catch(function(val) { + console.log(val); + resolve(); + }); + }, + + addTransition: function(begin, end, callback) { + this.addTransitionWithError(begin, end, null, callback); + }, + + addTransitionWithError: function(begin, end, error, callback) { + this.transitions.push({ + begin: begin, + end: end, + error: error, + callback: callback + }); + }, + + /* + * + * @param {type} resolve + * @param {type} reject + * @param {type} newState + * @param {type} errorCode + * @returns {undefined} + * FIXME: Yannis - 01/04/2015 - The verification done in else clause + * could be reviewed. + */ + onChangeState: function(resolve, reject, newState, errorCode) { + var currentTransition = this.transitions[this.currentIndex]; + var begin = currentTransition.begin; + var end = currentTransition.end; + var error = currentTransition.error; + console.log(this.vidBroadObj.playState); + if (begin == this.previousState && end == newState && error == errorCode) { + currentTransition.callback && currentTransition.callback(); + this.previousState = newState; + this.currentIndex++; + } else { + // + if (begin == this.CONNECTING + && this.transitions.length == this.currentIndex + 1) { + reject("Untestable case for the moment."); + } else { + reject("Invalid state."); + } + } + } + +}); + Added: oipf/test/js/VideoBroadcastTest.js =================================================================== --- oipf/test/js/VideoBroadcastTest.js (rev 0) +++ oipf/test/js/VideoBroadcastTest.js 2015-06-09 12:04:48 UTC (rev 1636) @@ -0,0 +1,824 @@ +/* + * Description: + * This class gather a set of method necessary to test a video broadcast object. + * + */ +var VideoBroadcastTest = TestCase.extend({ + channel: null, + + UNREALIZED: 0, + + CONNECTING: 1, + + PRESENTING: 2, + + STOPPED: 3, + + vidBroadObj: null, + + errorMap: { + + 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() { + this.super.init(); + }, + + beforeTest: function(resolve, reject) { + this.vidBroadObj = oipfObjectFactory.createVideoBroadcastObject(); + this.onPlayStateChange = this.onChangeState.bind(this, resolve, reject); + this.vidBroadObj.addEventListener("PlayStateChange", this.onPlayStateChange, false); + this.transitions = []; + this.previousState = this.vidBroadObj.playState; + this.currentIndex = 0; + this.channel = null; + logTest("State: Pending"); + }, + + afterTest: function() { +// this.vidBroadObj.release(); //Useful for test on tv plateform + this.vidBroadObj.removeEventListener("PlayStateChange", this.onPlayStateChange); + this.timerManager.clearTimer(); + }, + + getChannel: function(channelCollection){ + if (channelCollection.length != 0) { + return channelCollection[0]; + } + return null; + }, + +// /* +// * +// * @param {type} resolve +// * @param {type} reject +// * @param {type} newState +// * @param {type} errorCode +// * @returns {undefined} +// * FIXME: Yannis - 01/04/2015 - The verification done in else clause +// * could be reviewed. +// */ +// onChangeState: function(resolve, reject, newState, errorCode) { +// var currentTransition = this.transitions[this.currentIndex]; +// var begin = currentTransition.begin; +// var end = currentTransition.end; +// var error = currentTransition.error; +// console.log(this.vidBroadObj.playState); +// if (begin == this.previousState && end == newState && error == errorCode) { +// currentTransition.callback && currentTransition.callback(); +// this.previousState = newState; +// this.currentIndex++; +// } else { +// // +// if (begin == this.CONNECTING +// && this.transitions.length == this.currentIndex + 1) { +// reject("Untestable case for the moment."); +// } else { +// reject("Invalid state"); +// } +// } +// }, + + /* + * This method must throw a error by using the method reject. + * + * @param {type} resolve + * @param {type} reject + * @returns {undefined} + */ + testBindToCurrentChannelWhenNoChannelPresentation: function(resolve, reject) { + //Subject to modification not rigth way failed on the tv plateform. + this.vidBroadObj._channelService.currentChannel = null; + + this.addTransitionWithError(this.UNREALIZED, this.UNREALIZED, 100, resolve); + this.vidBroadObj.bindToCurrentChannel(); + }, + + /* + * 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) { +// var self = this; +// +// this.addTransition(this.previousState, this.PRESENTING); +// +// this.vidBroadObj.bindToCurrentChannel(); +// }, + + testDoubleBindToCurrentChannel: function(resolve, reject) { + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + this.vidBroadObj.bindToCurrentChannel(); + }, + + testBindToCurrentChannelInConnecting: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING, function() { + self.vidBroadObj.bindToCurrentChannel(); + }); + + this.addTransition(this.CONNECTING, this.PRESENTING, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testBindToCurrentChannelInPresenting: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.bindToCurrentChannel(); + resolve(); + }); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testBindToCurrentChannelInStopped: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, function() { + self.vidBroadObj.bindToCurrentChannel(); + }); + + this.addTransition(this.STOPPED, this.CONNECTING); + this.addTransition(this.CONNECTING, this.PRESENTING, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + /* + * This method must throw a error by using the method reject. + * @param {type} resolve + * @param {type} reject + * @returns {undefined} + */ + testBindToCurrentChannelInStoppedWhenNoTuner: function(resolve, reject) { + var self = this; + + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, function() { + //We want test the case where the current channel has a idType whose + //any tuner supporting this kind of channel exist. + //So we create channel of idType "ATSCT". + self.vidBroadObj._channelService.currentChannel = new Channel(ID_ATSC_T, null, null); + self.vidBroadObj.bindToCurrentChannel(); + }); + + this.addTransitionWithError(this.STOPPED, this.STOPPED, 0, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testPrevChannelInUnrealized: function(resolve, reject) { + this.addTransition(null, null, reject); + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + reject(); + }; + this.vidBroadObj.prevChannel(); + this.timeout(3000).then(resolve); + + }, + + testPrevChannelInConnecting: function(resolve, reject) { + var self = this; + this.addTransition(this.UNREALIZED, this.CONNECTING, function() { + self.vidBroadObj.prevChannel(); + }); + + this.addTransition(this.CONNECTING, this.CONNECTING); + + this.addTransition(this.PRESENTING, this.CONNECTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { + logTest("State: Successful"); + resolve(); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testPrevChannelInPresenting: function(resolve, reject) { + var self = this; + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.prevChannel(); + }); + + this.addTransition(this.PRESENTING, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { + logTest("State: Successful"); + resolve("Successfull"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testPrevChannelInStopped: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, function() { + self.vidBroadObj.prevChannel(); + }); + + this.addTransition(this.STOPPED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { + logTest("State: Successful"); + resolve("Successfull"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + + }, + +// testPrevChannel: function(resolve, reject) { +// var self = this; +// +// this.addTransition(this.PRESENTING, this.CONNECTING); +// +// this.addTransition(this.CONNECTING, this.PRESENTING); +// +// this.vidBroadObj.onChannelChangeSucceeded = function(channel) { +// +// if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { +// logTest("State: Successful"); +// resolve("Successfull"); +// } else { +// logTest("State: Failure"); +// reject("Failure : The channel is null for a unknown reason or wrong play state."); +// } +// }; +// +// this.vidBroadObj.prevChannel(); +// +// }, + + testNextChannelInUnrealized: function(resolve, reject) { + this.addTransition(null, null, reject); + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + reject(); + }; + this.vidBroadObj.nextChannel(); + this.timeout(3000) + .then(resolve); + }, + + testNextChannelInConnecting: function(resolve, reject) { + var self = this; + this.addTransition(this.UNREALIZED, this.CONNECTING, function() { + self.vidBroadObj.nextChannel(); + }); + + this.addTransition(this.CONNECTING, this.CONNECTING); + + this.addTransition(this.PRESENTING, this.CONNECTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { + logTest("State: Successful"); + resolve("Successfull"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testNextChannelInPresenting: function(resolve, reject) { + var self = this; + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.nextChannel(); + }); + + this.addTransition(this.PRESENTING, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { + logTest("State: Successful"); + resolve("Successfull"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testNextChannelInStopped: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, function() { + self.vidBroadObj.nextChannel(); + }); + + this.addTransition(this.STOPPED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { + logTest("State: Successful"); + resolve("Successfull"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + + }, + +// testNextChannel: function(resolve, reject) { +// var self = this; +// +// this.addTransition(this.PRESENTING, this.CONNECTING); +// +// this.addTransition(this.CONNECTING, this.PRESENTING); +// +// this.vidBroadObj.onChannelChangeSucceeded = function(channel) { +// +// if (self.assertNotNull(channel) && self.assertEquals(this.vidBroadObj, this.PRESENTING)) { +// logTest("State: Successful"); +// resolve("Successfull"); +// } else { +// logTest("State: Failure"); +// reject("Failure : The channel is null for a unknown reason or wrong play state."); +// } +// }; +// +// this.vidBroadObj.nextChannel(); +// }, + + /* + * Description: + * Nominal Case + */ + testReleaseInConnecting: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING, function() { + self.vidBroadObj.release(); + }); + + this.addTransition(this.CONNECTING, this.UNREALIZED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testReleaseInPresenting: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.release(); + }); + + this.addTransition(this.PRESENTING, this.UNREALIZED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + /* + * Description: + * Method stop is called in presenting state(but can be also in connecting state). + * @param {type} resolve + * @param {type} reject + * @returns {undefined} + */ + testReleaseInStopped: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, function() { + self.vidBroadObj.release(); + }); + + this.addTransition(this.STOPPED, this.UNREALIZED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + +// testRelease: function(resolve, reject) { +// var self = this; +// +// this.addTransition(this.PRESENTING, this.UNREALIZED, resolve); +// +// this.vidBroadObj.release(); +// }, + + /* + * Description: + * Nominal Case + */ + testStopInConnecting: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.CONNECTING, this.STOPPED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testStopInPresenting: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + +// testStop: function(resolve, reject) { +// var self = this; +// +// this.addTransition(this.PRESENTING, this.STOPPED, resolve); +// +// this.vidBroadObj.stop(); +// }, + + /* + * Description: + * Nominal Case + */ + testSetVolume: function(resolve, reject) { + var volume = 15; + var done = this.vidBroadObj.setVolume(volume); + + if (done && this.assertEquals(volume, this.vidBroadObj.getVolume())) { + resolve(); + } else { + reject(); + } + }, + + testSetVolumeWithoutArgument: function(resolve, reject) { + var done = this.vidBroadObj.setVolume(); + + if (done) { + reject(); + } else { + resolve(); + } + }, + + testSetVolumeWithFloatArgument: function(resolve, reject) { + var volume = 15.8; + var done = this.vidBroadObj.setVolume(volume); + + if (done || this.assertEquals(volume, this.vidBroadObj.getVolume())) { + reject("[Stub]Wrong Implementation."); + } else { + resolve(); + } + }, + + testSetVolumeWithFloatUnderBoundMin: function(resolve, reject) { + var volume = -15.8; + var done = this.vidBroadObj.setVolume(volume); + + if (done || this.assertEquals(volume, this.vidBroadObj.getVolume())) { + reject("[Stub]Wrong Implementation."); + } else { + resolve(); + } + }, + + testSetVolumeWithFloatAboveBoundMax: function(resolve, reject) { + var volume = 151.74; + var done = this.vidBroadObj.setVolume(volume); + + if (done || this.assertEquals(volume, this.vidBroadObj.getVolume())) { + reject("[Stub]Wrong Implementation."); + } else { + resolve(); + } + }, + + testSetVolumeWithValueUnderBoundMin: function(resolve, reject) { + var volume = -15; + var done = this.vidBroadObj.setVolume(volume); + + if (done && this.assertEquals(volume, this.vidBroadObj.getVolume())) { + reject(); + } else { + resolve(); + } + }, + + testSetVolumeWithValueAboveBoundMax: function(resolve, reject) { + var volume = 105; + var done = this.vidBroadObj.setVolume(volume); + + if (done && this.assertEquals(volume, this.vidBroadObj.getVolume())) { + reject(); + } else { + resolve(); + } + }, + +// testSetVolume: function(resolve, reject) { +// var volume = 15; +// +// var done = this.vidBroadObj.setVolume(volume); +// +// if (done) { +// resolve(); +// } else { +// reject(); +// } +// }, + + /* + * Description: + * Nominal Case + * FIX-ME: Yannis - 24/03/2015 - Exception not throw in callback of method addTransition + */ + testGetVolume: function(resolve, reject) { + var initialVolume = 15; + var done = this.vidBroadObj.setVolume(initialVolume); + + var finalVolume = this.vidBroadObj.getVolume(); + + if (done && this.assertEquals(initialVolume, this.vidBroadObj.getVolume()) + && this.assertEquals(initialVolume, finalVolume) + && this.assertEquals(this.vidBroadObj.getVolume(), finalVolume)) { + + resolve(); + } else { + reject(); + } + }, + +// testGetVolume: function(resolve, reject) { +// var volume = this.vidBroadObj.getVolume(); +// +// if (volume ) { +// resovle(); +// } else { +// reject(); +// } +// }, + testSetChannelInUnrealized: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.setChannel(self.channel); + }); + + this.addTransition(this.PRESENTING, this.CONNECTING); + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(self.vidBroadObj.playState, self.PRESENTING)) { + logTest("State: Successful"); + resolve("Success"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testSetChannelInConnecting: function(resolve, reject) { + var self = this; + + this.channel = this.getChannel( + this.vidBroadObj.getChannelConfig().channelList); + + this.addTransition(this.UNREALIZED, this.CONNECTING, function() { + self.vidBroadObj.setChannel(self.channel); + }); + + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(self.vidBroadObj.playState, self.PRESENTING)) { + logTest("State: Successful"); + resolve("Success"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testSetChannelInConnectingWithNull: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING, function() { + self.vidBroadObj.setChannel(null); + }); + + this.addTransition(this.CONNECTING, this.UNREALIZED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testSetChannelInPresenting: function(resolve, reject) { + var self = this; + + this.channel = this.getChannel( + this.vidBroadObj.getChannelConfig().channelList); + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.setChannel(self.channel); + }); + + this.addTransition(this.PRESENTING, this.CONNECTING); + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(self.vidBroadObj.playState, self.PRESENTING)) { + logTest("State: Successful"); + resolve("Success"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testSetChannelInPresentingWithNull: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.setChannel(null); + }); + + this.addTransition(this.PRESENTING, this.UNREALIZED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + + }, + + testSetChannelInStopped: function(resolve, reject) { + var self = this; + + this.channel = this.getChannel( + this.vidBroadObj.getChannelConfig().channelList); + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, function() { + self.vidBroadObj.setChannel(self.channel); + }); + + this.addTransition(this.STOPPED, this.CONNECTING); + this.addTransition(this.CONNECTING, this.PRESENTING); + + this.vidBroadObj.onChannelChangeSucceeded = function(channel) { + + if (self.assertNotNull(channel) && self.assertEquals(self.vidBroadObj.playState, self.PRESENTING)) { + logTest("State: Successful"); + resolve("Success"); + } else { + logTest("State: Failure"); + reject("Failure : The channel is null for a unknown reason or wrong play state."); + } + }; + + this.vidBroadObj.bindToCurrentChannel(); + }, + + testSetChannelInStoppedWithNull: function(resolve, reject) { + var self = this; + + this.addTransition(this.UNREALIZED, this.CONNECTING); + + this.addTransition(this.CONNECTING, this.PRESENTING, function() { + self.vidBroadObj.stop(); + }); + + this.addTransition(this.PRESENTING, this.STOPPED, function() { + self.vidBroadObj.setChannel(null); + }); + + this.addTransition(this.STOPPED, this.UNREALIZED, resolve); + + this.vidBroadObj.bindToCurrentChannel(); + + } + +}); \ No newline at end of file
participants (1)
-
smaisonneuve@users.nuiton.org