r1227 - in oipf/js: . configuration
Author: ygrego Date: 2015-04-20 08:00:35 +0000 (Mon, 20 Apr 2015) New Revision: 1227 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1227 Log: A new directory: "configuration" containing a new javascritp file "TestConfig" in order to manage redefinition of class when the tests will be launch on TV platform. Added: oipf/js/configuration/ oipf/js/configuration/TestConfig.js Added: oipf/js/configuration/TestConfig.js =================================================================== --- oipf/js/configuration/TestConfig.js (rev 0) +++ oipf/js/configuration/TestConfig.js 2015-04-20 08:00:35 UTC (rev 1227) @@ -0,0 +1,175 @@ +/* + * 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. + */ + +if (!String.prototype.includes) { + String.prototype.includes = function() {'use strict'; + return String.prototype.indexOf.apply(this, arguments) !== -1; + }; +} + +var userAgent = navigator.userAgent; + +if (userAgent.includes("HbbTV") || userAgent.includes("SmartTv")) { + console.log("OIPF TESTS ON TV PLATFORM"); + var hbbTv = ApplicationManager.getWindows[2]; + hbbTv && hbbTv.deactivate(); + var ui = ApplicationManager.getWindows()[0]; //or getWindowsByName + ui && ui.keySet.setValue(0x10, []); + !ui.visible && ui.show(); + !ui.active && ui.activate(); + + + var VideoBroadcastManager = VideoBroadcastTest.extend({ + + init: function() { +// this.superBeforeTest = VideoBroadcastTest.prototype.super.beforeTest; + this.vidBroadObj = oipfObjectFactory.createVideoBroadcastObject(); + + this.superBeforeTest = this.super.beforeTest; + this.superOnChangeState = this.super.onChangeState; + }, + + onChangeState: function(resolve, reject, event) { + this.superOnChangeState.call(this, + resolve, reject, event.state, event.error); + }, + +// beforeTest: function(resolve, reject) { +// this.reject = reject.bind(null); +// this.resolve = resolve.bind(null); +// this.superBeforeTest.call(this, this.resolve, this.reject); +// this.cancel = true; +// }, + + beforeTest: function(resolve, reject) { + this.reject = reject.bind(null); + this.resolve = resolve.bind(null); + 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; + this.timerManager = new TimerManager(); + this.timeout = this.timerManager.createTimer.bind(this.timerManager); + logTest("State: Pending"); + this.cancel = true; + }, + + unrealizedToConnecting: function(begin, end, callback) { + if (callback) { + throw ("Untestable Case."); + } + }, + + connectingToPresenting: function(begin, end, callback) { + /** + * Avoid that the future transition C->P be canceled. + * More extend super method beforeTest in order to reset + * 'startEndStates' property. + */ + if (this.cancel) { + callback && this.timeout().then(callback).then(console.log.bind(console, "TOTO")); + this.cancel = false; + } else { + this.pushTransition(begin, end, callback, null); + } + }, + + unrealizedToUnrealized: function(begin, end, callback) { + this.reject("Untestable Case."); + }, + + stopToStop: function(begin, end, callback) { + this.reject("Untestable Case."); + }, + + noStatesDefined: function(begin, end, callback) { + this.reject("Untestable Case."); + }, + + startEndStates: { + + "00": "unrealizedToUnrealized", + "01": "unrealizedToConnecting", + "12": "connectingToPresenting", + "33": "stopToStop", + "nullnull": "noStatesDefined" + }, + + pushTransition: function(begin, end, callback, error) { + this.transitions.push({ + begin: begin, + end: end, + error: error, + callback: callback + }); + }, + + pushTransitionWithError: function(begin, end, callback, error) { + var method = this.startEndStates[""+begin+end]; + if (method) { + this[method].call(this, begin, end, callback); + } else { + this.pushTransition(begin, end, callback, error); + } + }, + + addTransition: function(begin, end, callback) { + this.addTransitionWithError(begin, end, callback, null); + }, + + addTransitionWithError: function(begin, end, callback, error) { + this.pushTransitionWithError(begin, end, callback, error); + } + }); + + var VideoBroadcastTest = VideoBroadcastManager.extend({ + + init: function() { +// this.superBeforeTest = VideoBroadcastTest.prototype.super.beforeTest; +// this.vidBroadManager = new VideoBroadcastManager(); + + this.super.init(); +// this.onChangeState = this.super.beforeTest.bind(this); +// +// // beforeTest: function(resolve, reject) { +// // this.reject = reject.bind(null); +// // this.resolve = resolve.bind(null); +// // this.superBeforeTest.call(this, this.resolve, this.reject); +// // this.cancel = true; +// // }, +// +// this.beforeTest = this.super.beforeTest.bind(this); +// +// this.unrealizedToConnecting = this.super +// .unrealizedToConnecting.bind(this); +// +// this.connectingToPresenting = this.super +// .connectingToPresenting.bind(this); +// +// this.unrealizedToUnrealized = this.super. +// unrealizedToConnecting.bind(this); +// +// this.stopToStop = this.super.stopToStop.bind(this); +// +// this.noStatesDefined = this.super.noStatesDefined.bind(this); +// +// this.pushTransition = this.super.pushTransition.bind(this); +// +// this.pushTransitionWithError = this.super +// .pushTransitionWithError.bind(this); +// +// this.addTransition = this.super.addTransition.bind(this); +// +// this.addTransitionWithError = this.super +// .addTransitionWithError.bind(this); + } + + }); +} + +
participants (1)
-
ygregoï¼ users.nuiton.org