@@ -9,6 +9,7 @@ import Errors from '../../src/core/errors/Errors';
99import Settings from '../../src/core/Settings' ;
1010
1111import AdapterMock from './mocks/AdapterMock' ;
12+ import BaseURLControllerMock from './mocks/BaseURLControllerMock' ;
1213import ManifestModelMock from './mocks/ManifestModelMock' ;
1314import ErrorHandlerMock from './mocks/ErrorHandlerMock' ;
1415import AbrControllerMock from './mocks/AbrControllerMock' ;
@@ -45,6 +46,7 @@ describe('Stream', function () {
4546 const dashMetricsMock = new DashMetricsMock ( ) ;
4647 const textControllerMock = new TextControllerMock ( ) ;
4748 const videoModelMock = new VideoModelMock ( ) ;
49+ const baseURLControllerMock = new BaseURLControllerMock ( ) ;
4850 const timelineConverter = objectsHelper . getDummyTimelineConverter ( ) ;
4951 const streamInfo = {
5052 id : 'id' ,
@@ -70,6 +72,7 @@ describe('Stream', function () {
7072 dashMetrics : dashMetricsMock ,
7173 textController : textControllerMock ,
7274 videoModel : videoModelMock ,
75+ baseURLController : baseURLControllerMock ,
7376 settings : settings } ) ;
7477 } ) ;
7578
@@ -90,6 +93,60 @@ describe('Stream', function () {
9093 expect ( processors ) . to . be . empty ; // jshint ignore:line
9194 } ) ;
9295
96+ it ( 'should return an array that does not include the streamProcessors for text and fragmented text when getProcessors is called and text is disabled' , ( ) => {
97+ // test-specific setup
98+ adapterMock . setRepresentation ( {
99+ adaptation : { period : { mpd : { manifest : { type : 'bar' } } } } ,
100+ hasInitialization : ( ) => false ,
101+ hasSegments : ( ) => true ,
102+ id : 'foo'
103+ } ) ;
104+
105+ stream . initialize ( streamInfo , { } ) ;
106+ stream . activate (
107+ null ,
108+ null
109+ ) ;
110+
111+ // check textControllerMock is in correct state
112+ expect ( textControllerMock . isTextEnabled ( ) ) . to . be . false ; // jshint ignore:line
113+
114+ // check assertions
115+ const processors = stream . getProcessors ( ) ;
116+ expect ( processors . length ) . to . be . equal ( 2 ) ; // jshint ignore:line
117+ expect ( processors [ 0 ] . getType ( ) ) . to . be . equal ( 'video' ) ; // jshint ignore:line
118+ expect ( processors [ 1 ] . getType ( ) ) . to . be . equal ( 'audio' ) ; // jshint ignore:line
119+ } ) ;
120+
121+ it ( 'should return an array that includes the streamProcessors for text and fragmented text when getProcessors is called and text is enabled' , ( ) => {
122+ // test-specific setup
123+ adapterMock . setRepresentation ( {
124+ adaptation : { period : { mpd : { manifest : { type : 'bar' } } } } ,
125+ hasInitialization : ( ) => false ,
126+ hasSegments : ( ) => true ,
127+ id : 'foo'
128+ } ) ;
129+
130+ textControllerMock . enableText ( true ) ;
131+
132+ stream . initialize ( streamInfo , { } ) ;
133+ stream . activate (
134+ null ,
135+ null
136+ ) ;
137+
138+ // check textControllerMock is in correct state
139+ expect ( textControllerMock . isTextEnabled ( ) ) . to . be . true ; // jshint ignore:line
140+
141+ // check assertions
142+ const processors = stream . getProcessors ( ) ;
143+ expect ( processors . length ) . to . be . equal ( 4 ) ; // jshint ignore:line
144+ expect ( processors [ 0 ] . getType ( ) ) . to . be . equal ( 'video' ) ; // jshint ignore:line
145+ expect ( processors [ 1 ] . getType ( ) ) . to . be . equal ( 'audio' ) ; // jshint ignore:line
146+ expect ( processors [ 2 ] . getType ( ) ) . to . be . equal ( 'text' ) ; // jshint ignore:line
147+ expect ( processors [ 3 ] . getType ( ) ) . to . be . equal ( 'fragmentedText' ) ; // jshint ignore:line
148+ } ) ;
149+
93150 it ( 'should trigger MANIFEST_ERROR_ID_NOSTREAMS_CODE error when setMediaSource is called but streamProcessors array is empty' , ( ) => {
94151 stream . setMediaSource ( ) ;
95152 expect ( errHandlerMock . errorCode ) . to . be . equal ( Errors . MANIFEST_ERROR_ID_NOSTREAMS_CODE ) ; // jshint ignore:line
0 commit comments