diff --git a/src/streaming/MediaManager.js b/src/streaming/MediaManager.js index eb3df7af32..aa12691c05 100644 --- a/src/streaming/MediaManager.js +++ b/src/streaming/MediaManager.js @@ -220,7 +220,7 @@ function MediaManager() { } altPlayer.play(); - logger.info('Alternative content playback started'); + logger.info(`Alternative content playback started for player ${playerId}`); isSwitching = false; } diff --git a/test/unit/test/streaming/streaming.MediaManager.js b/test/unit/test/streaming/streaming.MediaManager.js index a8f90f7e78..b4be56eec2 100644 --- a/test/unit/test/streaming/streaming.MediaManager.js +++ b/test/unit/test/streaming/streaming.MediaManager.js @@ -11,12 +11,10 @@ describe('MediaManager', function () { let debugMock; beforeEach(function () { - // Setup mocks videoModelMock = new VideoModelMock(); playbackControllerMock = new PlaybackControllerMock(); debugMock = new DebugMock(); - // Configure MediaManager mediaManager.setConfig({ videoModel: videoModelMock, playbackController: playbackControllerMock, @@ -44,15 +42,64 @@ describe('MediaManager', function () { }); }); + describe('prebufferAlternativeContent', function () { + it('should start prebuffering alternative content and log the action', function () { + const testUrl = 'http://test.mpd'; + const testPlayerId = 'testPlayer'; + + mediaManager.prebufferAlternativeContent(testPlayerId, testUrl); + + expect(debugMock.log.info).to.equal(`Starting prebuffering for player ${testPlayerId}`); + }); + }); + + describe('switchToAlternativeContent', function () { + beforeEach(function () { + const mockVideoElement = videoModelMock.getElement(); + mediaManager.setAlternativeVideoElement(mockVideoElement); + }); + + it('should switch to alternative content without prebuffered content', function () { + const testUrl = 'http://test.mpd'; + const testPlayerId = 'testPlayer'; + + mediaManager.switchToAlternativeContent(testPlayerId, testUrl); + + expect(debugMock.log.info).to.equal(`Alternative content playback started for player ${testPlayerId}`); + }); + + it('should switch to alternative content with prebuffered content', function () { + const testUrl = 'http://test.mpd'; + const testPlayerId = 'testPlayer'; + + mediaManager.prebufferAlternativeContent(testPlayerId, testUrl); + expect(debugMock.log.info).to.equal(`Starting prebuffering for player ${testPlayerId}`); + + mediaManager.switchToAlternativeContent(testPlayerId, testUrl); + expect(debugMock.log.info).to.equal(`Alternative content playback started for player ${testPlayerId}`); + }); + + it('should switch to alternative content and seek to a given time', function () { + const testUrl = 'http://test.mpd'; + const testPlayerId = 'testPlayer'; + const testTime = 15; + + mediaManager.switchToAlternativeContent(testPlayerId, testUrl, testTime); + + expect(debugMock.log.debug).to.equal(`Seeking alternative content to time: ${testTime}`); + expect(debugMock.log.info).to.equal(`Alternative content playback started for player ${testPlayerId}`); + }); + }); + describe('getAlternativePlayer', function () { beforeEach(function () { const mockVideoElement = videoModelMock.getElement(); mediaManager.setAlternativeVideoElement(mockVideoElement); }); - it('should return undefined when no alternative player is set', function () { + it('should return null when no alternative player is set', function () { const result = mediaManager.getAlternativePlayer(); - expect(result).to.be.undefined; + expect(result).to.be.null; }); it('should return the alternative player when it is set', function () {