-
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 #2138 from Orange-OpenSource/UpdateUnitTests
Update unit tests
- Loading branch information
Showing
38 changed files
with
709 additions
and
813 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
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,20 @@ | ||
import TimelineSegmentsGetter from '../../src/dash/utils/TimelineSegmentsGetter'; | ||
import TimelineConverter from '../../src/dash/utils/TimelineConverter'; | ||
|
||
const expect = require('chai').expect; | ||
|
||
describe("TimelineSegmentsGetter", function () { | ||
const context = {}; | ||
let timelineSegmentsGetter = TimelineSegmentsGetter(context).create({}); | ||
|
||
it("should throw an error if config object has not been properly passed", function () { | ||
expect(timelineSegmentsGetter.getSegments.bind(timelineSegmentsGetter)).to.be.throw('Missing config parameter(s)'); | ||
}); | ||
|
||
it("should throw an error if representation parameter has not been properly set", function () { | ||
let timelineConverter = TimelineConverter(context).getInstance(); | ||
timelineSegmentsGetter = TimelineSegmentsGetter(context).create({timelineConverter: timelineConverter}); | ||
|
||
expect(timelineSegmentsGetter.getSegments.bind(timelineSegmentsGetter)).to.be.throw('no representation'); | ||
}); | ||
}); |
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,33 @@ | ||
WEBVTT | ||
1 | ||
00:00:15.042 --> 00:00:18.042 | ||
At the <c.red.caps>left</c> we can see... | ||
|
||
2 | ||
00:00:18.167 --> 00:00:20.083 | ||
<c.red.caps>At the right we can see the...</c> | ||
|
||
3 | ||
00:00:20.083 --> 00:00:22.000 | ||
...the head-snarlers. | ||
|
||
4 | ||
00:00:22.000 --> 00:00:24.417 | ||
Everything is safe. Perfectly safe. | ||
|
||
5 | ||
00:00:24.583 --> 00:00:27.083 | ||
Emo ? Emo! | ||
|
||
6 | ||
00:00:28.208 --> 00:00:30.042 | ||
Watch out! | ||
|
||
7 | ||
00:00:46.642 --> 00:00:48.250 | ||
Are you hurt? | ||
|
||
8 | ||
00:00:52.000 --> 00:00:54.000 | ||
I don't think so. You? |
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 @@ | ||
class AdapterMock { | ||
constructor() { | ||
this.metricsList = { | ||
BUFFER_STATE: 'BUFFER_STATE' | ||
}; | ||
} | ||
getEventsFor() { | ||
return null; | ||
} | ||
} | ||
|
||
export default AdapterMock; |
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,10 @@ | ||
class DashManifestModelMock { | ||
|
||
constructor() {} | ||
|
||
getIsTextTrack() { | ||
return false; | ||
} | ||
} | ||
|
||
export default DashManifestModelMock; |
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 @@ | ||
class DashMetricsMock { | ||
constructor() { | ||
} | ||
|
||
getCurrentDVRInfo() { | ||
return null; | ||
} | ||
|
||
getCurrentBufferLevel() { | ||
return 15; | ||
} | ||
} | ||
|
||
export default DashMetricsMock; |
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,26 @@ | ||
class DomStorageMock { | ||
constructor() { | ||
this.mediaSettings = {}; | ||
} | ||
|
||
getSavedMediaSettings(type) { | ||
if (this.mediaSettings[type]) { | ||
return this.mediaSettings[type]; | ||
} | ||
return null; | ||
} | ||
|
||
setSavedMediaSettings(type, settings) { | ||
|
||
if (!settings) { | ||
return; | ||
} | ||
if (!this.mediaSettings[type]) { | ||
this.mediaSettings[type] = {}; | ||
} | ||
|
||
this.mediaSettings[type] = settings; | ||
} | ||
} | ||
|
||
export default DomStorageMock; |
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,13 @@ | ||
function ErrorHandlerMock() { | ||
this.error = undefined; | ||
|
||
this.manifestError = function(error) { | ||
this.error = error; | ||
}; | ||
|
||
this.mediaSourceError = function(error) { | ||
this.error = error; | ||
}; | ||
} | ||
|
||
export default ErrorHandlerMock; |
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,11 @@ | ||
class ManifestModelMock { | ||
constructor() { | ||
this.manifestValue = 0; | ||
} | ||
|
||
getValue() { | ||
return this.manifestValue; | ||
} | ||
} | ||
|
||
export default ManifestModelMock; |
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,25 @@ | ||
class ManifestLoaderMock { | ||
constructor() { | ||
this.loadManifest = false; | ||
} | ||
|
||
getLoadManifest() { | ||
return false; | ||
} | ||
|
||
load() { | ||
this.loadManifest = true; | ||
} | ||
} | ||
|
||
class ManifestUpdaterMock { | ||
constructor() { | ||
this.manifestLoader = new ManifestLoaderMock(); | ||
} | ||
|
||
getManifestLoader() { | ||
return this.manifestLoader; | ||
} | ||
} | ||
|
||
export default ManifestUpdaterMock; |
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,56 @@ | ||
class TimeRangesMock { | ||
constructor() { | ||
this.ranges = []; | ||
this.length = this.ranges.length; | ||
} | ||
|
||
start(index) { | ||
return this.ranges[index] ? this.ranges[index].start : null; | ||
} | ||
end(index) { | ||
return this.ranges[index] ? this.ranges[index].end : null; | ||
} | ||
|
||
addRange(range) { | ||
this.ranges.push(range); | ||
this.length = this.ranges.length; | ||
} | ||
} | ||
class MediaSourceBufferMock { | ||
constructor() { | ||
this.buffered = new TimeRangesMock(); | ||
this.updating = false; | ||
this.chunk = null; | ||
this.aborted = false; | ||
} | ||
|
||
addRange(range) { | ||
this.buffered.addRange(range); | ||
} | ||
|
||
remove() { | ||
this.updating = true; | ||
this.chunk = null; | ||
|
||
let that = this; | ||
setTimeout(function() { | ||
that.updating = false; | ||
}, 500); | ||
} | ||
|
||
append(chunk) { | ||
this.updating = true; | ||
this.chunk = chunk; | ||
|
||
let that = this; | ||
setTimeout(function() { | ||
that.updating = false; | ||
}, 500); | ||
} | ||
|
||
abort() { | ||
this.aborted = true; | ||
} | ||
} | ||
|
||
export default MediaSourceBufferMock; |
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,34 @@ | ||
import MediaSourceBufferMock from './MediaSourceBufferMock'; | ||
|
||
class MediaSourceMock { | ||
constructor() { | ||
this.buffers = []; | ||
this.readyState = 'open'; | ||
} | ||
|
||
addSourceBuffer(codec) { | ||
if (codec.match(/text/i)) { | ||
throw new Error('not really supported'); | ||
} | ||
|
||
if (codec.match(/unknown/i)) { | ||
throw new Error('unknown'); | ||
} | ||
|
||
let buffer = new MediaSourceBufferMock(); | ||
this.buffers.push(buffer); | ||
return buffer; | ||
} | ||
|
||
removeSourceBuffer(buffer) { | ||
let index = this.buffers.indexOf(buffer); | ||
|
||
if (index === -1) { | ||
return; | ||
} | ||
|
||
this.buffers.splice(index, 1); | ||
} | ||
} | ||
|
||
export default MediaSourceMock; |
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,19 @@ | ||
class MetricsModelMock { | ||
constructor() { | ||
this.bufferState = 0; | ||
this.bufferLevel = 0; | ||
} | ||
addBufferState(type, bufferState, bufferTarget) { | ||
this.bufferState = bufferState; | ||
} | ||
|
||
addBufferLevel(type, date, bufferLevel ) { | ||
this.bufferState = bufferLevel; | ||
} | ||
|
||
getReadOnlyMetricsFor() { | ||
return null; | ||
} | ||
} | ||
|
||
export default MetricsModelMock; |
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,20 @@ | ||
import FragmentRequest from '../../../src/streaming/vo/FragmentRequest'; | ||
|
||
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() {}; | ||
} | ||
|
||
export default RulesContextMock; |
Oops, something went wrong.