-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from fmtvp/restart_successful_event
IPLAYERTVV1-3166 Restart successful event
- Loading branch information
Showing
10 changed files
with
431 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
static/script-tests/tests/devices/mediaplayer/cehtmlseekfinishedemiteventtest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/** | ||
* @preserve Copyright (c) 2014 British Broadcasting Corporation | ||
* (http://www.bbc.co.uk) and TAL Contributors (1) | ||
* | ||
* (1) TAL Contributors are listed in the AUTHORS file and at | ||
* https://github.com/fmtvp/TAL/AUTHORS - please extend this file, | ||
* not this notice. | ||
* | ||
* @license Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* All rights reserved | ||
* Please contact us for an alternative licence | ||
*/ | ||
|
||
(function() { | ||
// jshint newcap: false | ||
this.CEHTMLSeekFinishedEmitEventTests = AsyncTestCase("CEHTMLSeekFinishedEmitEvent"); | ||
|
||
var config = {"modules":{"base":"antie/devices/browserdevice","modifiers":["antie/devices/mediaplayer/cehtmlseekfinishedemitevent"]}, "input":{"map":{}},"layouts":[{"width":960,"height":540,"module":"fixtures/layouts/default","classes":["browserdevice540p"]}],"deviceConfigurationKey":"devices-html5-1"}; | ||
var configWithRestartTimeout = {"restartTimeout":10000, "modules":{"base":"antie/devices/browserdevice","modifiers":["antie/devices/mediaplayer/cehtmlseekfinishedemitevent"]}, "input":{"map":{}},"layouts":[{"width":960,"height":540,"module":"fixtures/layouts/default","classes":["browserdevice540p"]}],"deviceConfigurationKey":"devices-html5-1"}; | ||
|
||
var eventWasFired = function(eventHandler, eventType) { | ||
for(var i = 0; i < eventHandler.callCount; i++) { | ||
if(eventHandler.getCall(i).args[0].type === eventType) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
var eventNotFired = function(eventHandler, eventType) { | ||
return !eventWasFired(eventHandler, eventType); | ||
}; | ||
|
||
// --------------- | ||
// Mix in the base HTML5 tests to make sure the sub-modifier doesn't break basic functionality | ||
// --------------- | ||
window.commonTests.mediaPlayer.cehtml.mixinTests(this.CEHTMLSeekFinishedEmitEventTests, "antie/devices/mediaplayer/cehtmlseekfinishedemitevent", config); | ||
|
||
// --------------- | ||
// Remove tests that are irrelevant for this sub-modifier. | ||
// --------------- | ||
|
||
// --------------- | ||
// Additional tests for this sub-modifier. | ||
// --------------- | ||
this.CEHTMLSeekFinishedEmitEventTests.prototype.testIfTimeIsInRangeAndHasBeenPlaying5TimesWithNoTimeoutWeFireSeekFinishedEvent = function(queue) { | ||
expectAsserts(7); | ||
var self = this; | ||
this.runMediaPlayerTest(this, queue, function (MediaPlayer) { | ||
var eventHandler = self.sandbox.stub(); | ||
self._mediaPlayer.addEventCallback(null, eventHandler); | ||
|
||
self._mediaPlayer.setSource(MediaPlayer.TYPE.VIDEO, 'http://testurl/', 'video/mp4'); | ||
self._mediaPlayer.beginPlaybackFrom(1000); | ||
self.deviceMockingHooks.sendMetadata(self._mediaPlayer, 0, { start: 0, end: 100 }); | ||
self.deviceMockingHooks.finishBuffering(self._mediaPlayer); | ||
|
||
assert(eventWasFired(eventHandler, MediaPlayer.EVENT.SEEK_ATTEMPTED)); | ||
for(var i = 0; i < 5; i++) { | ||
assert(eventNotFired(eventHandler, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
self._clock.tick(500); | ||
self.fakeCEHTMLObject.playPosition += 500; | ||
eventHandler.reset(); | ||
} | ||
|
||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventWasFired(eventHandler, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
}); | ||
}; | ||
|
||
this.CEHTMLSeekFinishedEmitEventTests.prototype.testIfWeFiredSeekFinishedEventDoNotFireAnother = function(queue) { | ||
expectAsserts(8); | ||
var self = this; | ||
this.runMediaPlayerTest(this, queue, function (MediaPlayer) { | ||
var eventHandler = self.sandbox.stub(); | ||
self._mediaPlayer.addEventCallback(null, eventHandler); | ||
|
||
self._mediaPlayer.setSource(MediaPlayer.TYPE.VIDEO, 'http://testurl/', 'video/mp4'); | ||
self._mediaPlayer.beginPlaybackFrom(1000); | ||
self.deviceMockingHooks.sendMetadata(self._mediaPlayer, 0, { start: 0, end: 100 }); | ||
self.deviceMockingHooks.finishBuffering(self._mediaPlayer); | ||
|
||
assert(eventWasFired(eventHandler, MediaPlayer.EVENT.SEEK_ATTEMPTED)); | ||
for(var i = 0; i < 5; i++) { | ||
assert(eventNotFired(eventHandler, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
self._clock.tick(500); | ||
self.fakeCEHTMLObject.playPosition += 500; | ||
eventHandler.reset(); | ||
} | ||
|
||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventWasFired(eventHandler, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
eventHandler.reset(); | ||
|
||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventNotFired(eventHandler, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
}); | ||
}; | ||
|
||
this.CEHTMLSeekFinishedEmitEventTests.prototype.testIfTimeIsInRangeAndHasBeenPlaying5TimesWith10SecondTimeoutWeFireSeekFinishedEvent = function(queue) { | ||
var self = this; | ||
expectAsserts(21); | ||
this.runMediaPlayerTestWithSpecificConfig(this, queue, function (MediaPlayer) { | ||
var eventHandler = self.sandbox.stub(); | ||
self._mediaPlayer.addEventCallback(null, eventHandler); | ||
|
||
self._mediaPlayer.setSource(MediaPlayer.TYPE.VIDEO, 'http://testurl/', 'video/mp4'); | ||
self._mediaPlayer.beginPlaybackFrom(1000); | ||
self.deviceMockingHooks.sendMetadata(self._mediaPlayer, 0, { start: 0, end: 100 }); | ||
self.deviceMockingHooks.finishBuffering(self._mediaPlayer); | ||
|
||
assert(eventWasFired(eventHandler, MediaPlayer.EVENT.SEEK_ATTEMPTED)); | ||
|
||
var numberOfLoops = configWithRestartTimeout.restartTimeout/500; | ||
for(var i = 0; i < numberOfLoops - 1; i++) { | ||
self._clock.tick(500); | ||
self.fakeCEHTMLObject.playPosition += 500; | ||
assert(eventNotFired(eventHandler, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
} | ||
|
||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventWasFired(eventHandler, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
}, configWithRestartTimeout); | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
static/script-tests/tests/devices/mediaplayer/html5seekfinishedemiteventtest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/** | ||
* @preserve Copyright (c) 2014 British Broadcasting Corporation | ||
* (http://www.bbc.co.uk) and TAL Contributors (1) | ||
* | ||
* (1) TAL Contributors are listed in the AUTHORS file and at | ||
* https://github.com/fmtvp/TAL/AUTHORS - please extend this file, | ||
* not this notice. | ||
* | ||
* @license Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* All rights reserved | ||
* Please contact us for an alternative licence | ||
*/ | ||
|
||
(function() { | ||
// jshint newcap: false | ||
this.HTML5SeekFinishedEmitEventTests = AsyncTestCase("HTML5SeekFinishedEmitEvent"); | ||
|
||
var config = {"modules":{"base":"antie/devices/browserdevice","modifiers":["antie/devices/mediaplayer/html5seekfinishedemitevent"]}, "input":{"map":{}},"layouts":[{"width":960,"height":540,"module":"fixtures/layouts/default","classes":["browserdevice540p"]}],"deviceConfigurationKey":"devices-html5-1"}; | ||
var configWithRestartTimeout = {"restartTimeout":10000, "modules":{"base":"antie/devices/browserdevice","modifiers":["antie/devices/mediaplayer/html5seekfinishedemitevent"]}, "input":{"map":{}},"layouts":[{"width":960,"height":540,"module":"fixtures/layouts/default","classes":["browserdevice540p"]}],"deviceConfigurationKey":"devices-html5-1"}; | ||
|
||
var eventWasFired = function(self, eventType) { | ||
for(var i = 0; i < self._eventCallback.args.length; i++) { | ||
if(eventType === self._eventCallback.args[i][0].type) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
var eventNotFired = function(self, eventType) { | ||
return !eventWasFired(self, eventType); | ||
}; | ||
|
||
// --------------- | ||
// Mix in the base HTML5 tests to make sure the sub-modifier doesn't break basic functionality | ||
// --------------- | ||
window.commonTests.mediaPlayer.html5.mixinTests(this.HTML5SeekFinishedEmitEventTests, "antie/devices/mediaplayer/html5seekfinishedemitevent", config); | ||
|
||
// --------------- | ||
// Remove tests that are irrelevant for this sub-modifier. | ||
// --------------- | ||
|
||
// --------------- | ||
// Additional tests for this sub-modifier. | ||
// --------------- | ||
|
||
var getToPlaying = function(self, MediaPlayer) { | ||
self._mediaPlayer.setSource(MediaPlayer.TYPE.VIDEO, 'http://testurl/', 'video/mp4'); | ||
self._mediaPlayer.beginPlaybackFrom(0); | ||
self.deviceMockingHooks.sendMetadata(self._mediaPlayer, 0, { start: 0, end: 100 }); | ||
self.deviceMockingHooks.finishBuffering(self._mediaPlayer); | ||
}; | ||
|
||
this.HTML5SeekFinishedEmitEventTests.prototype.testIfTimeIsInRangeAndHasBeenPlaying5TimesWithNoTimeoutWeFireSeekFinishedEvent = function(queue) { | ||
var self = this; | ||
expectAsserts(7); | ||
this.runMediaPlayerTest(this, queue, function (MediaPlayer) { | ||
getToPlaying(this, MediaPlayer); | ||
|
||
assert(eventWasFired(self, MediaPlayer.EVENT.SEEK_ATTEMPTED)); | ||
for(var i = 0; i < 5; i++) { | ||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventNotFired(self, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
self._clock.tick(1000); | ||
self.stubCreateElementResults.video.currentTime += 1; | ||
self._eventCallback.reset(); | ||
} | ||
|
||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventWasFired(self, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
}); | ||
}; | ||
|
||
this.HTML5SeekFinishedEmitEventTests.prototype.testWeAlreadyFiredSeekFinishedEventDoNotFireAnother = function(queue) { | ||
var self = this; | ||
expectAsserts(8); | ||
this.runMediaPlayerTest(this, queue, function (MediaPlayer) { | ||
getToPlaying(this, MediaPlayer); | ||
|
||
assert(eventWasFired(self, MediaPlayer.EVENT.SEEK_ATTEMPTED)); | ||
for(var i = 0; i < 5; i++) { | ||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventNotFired(self, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
self._clock.tick(1000); | ||
self.stubCreateElementResults.video.currentTime += 1; | ||
self._eventCallback.reset(); | ||
} | ||
|
||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventWasFired(self, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
|
||
self._eventCallback.reset(); | ||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
assert(eventNotFired(self, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
}); | ||
}; | ||
|
||
this.HTML5SeekFinishedEmitEventTests.prototype.testIfTimeIsInRangeAndHasBeenPlaying5TimesWith10SecondTimeoutWeFireSeekFinishedEvent = function(queue) { | ||
var self = this; | ||
expectAsserts(12); | ||
this.runMediaPlayerTestWithSpecificConfig(this, queue, function (MediaPlayer) { | ||
getToPlaying(this, MediaPlayer); | ||
|
||
assert(eventWasFired(self, MediaPlayer.EVENT.SEEK_ATTEMPTED)); | ||
for(var i = 0; i < 10; i++) { | ||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
self._clock.tick(1000); | ||
self.stubCreateElementResults.video.currentTime += 1; | ||
assert(eventNotFired(self, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
self._eventCallback.reset(); | ||
} | ||
|
||
self.deviceMockingHooks.makeOneSecondPass(self._mediaPlayer); | ||
self._clock.tick(1000); | ||
assert(eventWasFired(self, MediaPlayer.EVENT.SEEK_FINISHED)); | ||
}, configWithRestartTimeout); | ||
}; | ||
})(); |
14 changes: 14 additions & 0 deletions
14
static/script/devices/mediaplayer/cehtmlseekfinishedemitevent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require.def( | ||
"antie/devices/mediaplayer/cehtmlseekfinishedemitevent", | ||
[ | ||
"antie/devices/mediaplayer/seekfinishedemitevent", | ||
"antie/devices/mediaplayer/cehtml" | ||
], | ||
function (SeekFinishedEmitEvent, CEHTML) { | ||
"use strict"; | ||
|
||
SeekFinishedEmitEvent(CEHTML); | ||
|
||
return CEHTML; | ||
} | ||
); |
Oops, something went wrong.