-
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 #2074 from Orange-OpenSource/add_AbandonRequestsRu…
…le_unit_test first version for AbandonRequestsRule unit test
- Loading branch information
Showing
2 changed files
with
82 additions
and
1 deletion.
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,76 @@ | ||
import AbandonRequestsRule from '../../src/streaming/rules/abr/AbandonRequestsRule'; | ||
import FragmentRequest from '../../src/streaming/vo/FragmentRequest'; | ||
|
||
const expect = require('chai').expect; | ||
|
||
const context = {}; | ||
|
||
function RulesContextMock () { | ||
this.getMediaInfo = function() { | ||
|
||
}; | ||
this.getMediaType = function() { | ||
return 'video'; | ||
}; | ||
this.getCurrentRequest = function() { | ||
let fragRequest = new FragmentRequest(); | ||
fragRequest.index = 1; | ||
|
||
return fragRequest; | ||
}; | ||
this.getTrackInfo = function() {}; | ||
this.getAbrController = function() {}; | ||
} | ||
|
||
class MetricsModelMock { | ||
constructor() { | ||
} | ||
|
||
getReadOnlyMetricsFor(type) { | ||
return null; | ||
} | ||
} | ||
|
||
class DashMetricsMock { | ||
constructor() { | ||
} | ||
|
||
getCurrentBufferLevel() { | ||
return 15; | ||
} | ||
} | ||
|
||
class MediaPlayerModelMock { | ||
constructor() { | ||
} | ||
|
||
getStableBufferTime() { | ||
return 10; | ||
} | ||
|
||
} | ||
|
||
describe('AbandonRequestsRule', function () { | ||
it("should return an empty switchRequest when shouldAbandon function is called with an empty parameter", function () { | ||
const abandonRequestsRule = AbandonRequestsRule(context).create({}); | ||
const abandonRequest = abandonRequestsRule.shouldAbandon(); | ||
|
||
expect(abandonRequest.quality).to.be.equal(-1); // jshint ignore:line | ||
}); | ||
|
||
it("should return an empty switchRequest when shouldAbandon function is called with a mock parameter", function () { | ||
let rulesContextMock = new RulesContextMock(); | ||
let dashMetricsMock = new DashMetricsMock(); | ||
let metricsModelMock = new MetricsModelMock(); | ||
let mediaPlayerModelMock = new MediaPlayerModelMock(); | ||
|
||
const abandonRequestsRule = AbandonRequestsRule(context).create({metricsModel: metricsModelMock, | ||
dashMetrics: dashMetricsMock, | ||
mediaPlayerModel: mediaPlayerModelMock}); | ||
|
||
|
||
const abandonRequest = abandonRequestsRule.shouldAbandon(rulesContextMock); | ||
|
||
expect(abandonRequest.quality).to.be.equal(-1); // jshint ignore:line | ||
}); | ||
}); |