-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 #2504 from Orange-OpenSource/addEmptyChallengeDRME…
…rror Add empty challenge drm error
- Loading branch information
Showing
3 changed files
with
82 additions
and
4 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
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,12 @@ | ||
function ProtectionKeyControllerMock () { | ||
|
||
this.getSupportedKeySystemsFromContentProtection = function (/*cps*/) { | ||
return []; | ||
}; | ||
|
||
this.getLicenseServer = function () { | ||
return null; | ||
}; | ||
} | ||
|
||
export default ProtectionKeyControllerMock; |
46 changes: 46 additions & 0 deletions
46
test/unit/streaming.protection.controllers.ProtectionController.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,46 @@ | ||
import ProtectionController from '../../src/streaming/protection/controllers/ProtectionController'; | ||
import ProtectionEvents from '../../src/streaming/protection/ProtectionEvents'; | ||
import EventBus from '../../src/core/EventBus'; | ||
import Debug from '../../src/core/Debug'; | ||
|
||
import ProtectionKeyControllerMock from './mocks/ProtectionKeyControllerMock'; | ||
|
||
const expect = require('chai').expect; | ||
const context = {}; | ||
const eventBus = EventBus(context).getInstance(); | ||
|
||
describe('ProtectionController', function () { | ||
describe('Not well initialized', function () { | ||
let protectionController = ProtectionController(context).create({}); | ||
|
||
it('should throw an exception when attempting to call initializeForMedia function without mediaInfo parameter', function () { | ||
expect(protectionController.initializeForMedia.bind(protectionController)).to.throw('mediaInfo can not be null or undefined'); | ||
}); | ||
|
||
it('should throw an error when initializeForMedia is called and config object has not been set properly', function () { | ||
expect(protectionController.initializeForMedia.bind(protectionController, {})).to.throw('Missing config parameter(s)'); | ||
}); | ||
}); | ||
|
||
describe('onKeyMessage behavior', function () { | ||
it('', function (done) { | ||
const protectionKeyControllerMock = new ProtectionKeyControllerMock(); | ||
let protectionController = ProtectionController(context).create({protectionKeyController: protectionKeyControllerMock, | ||
events: ProtectionEvents, | ||
log: Debug(context).getInstance().log, | ||
eventBus: eventBus}); | ||
|
||
let onDRMError = function (data) { | ||
eventBus.off(ProtectionEvents.LICENSE_REQUEST_COMPLETE, onDRMError); | ||
expect(data.error).to.be.equal('DRM: Empty key message from CDM'); // jshint ignore:line | ||
done(); | ||
}; | ||
|
||
eventBus.on(ProtectionEvents.LICENSE_REQUEST_COMPLETE, onDRMError, this); | ||
|
||
protectionController.initializeForMedia({}); | ||
|
||
eventBus.trigger(ProtectionEvents.INTERNAL_KEY_MESSAGE, {data: {}}); | ||
}); | ||
}); | ||
}); |