Skip to content

Commit

Permalink
SauceLabs: test NASA stream
Browse files Browse the repository at this point in the history
  • Loading branch information
mangui committed Oct 10, 2016
1 parent 4523ddc commit 0e00cf5
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 18 deletions.
32 changes: 32 additions & 0 deletions tests/functional/auto/hlsjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,38 @@
callback('notSupported');
}
}

function switchToLowestLevel(mode) {
switch(mode) {
case 'current':
hls.currentLevel = 0;
break;
case 'next':
hls.nextLevel = 0;
break;
case 'load':
default:
hls.loadLevel = 0;
break;
}
}

function switchToHighestLevel() {
var highestLevel = hls.levels.length-1;
switch(mode) {
case 'current':
hls.currentLevel = highestLevel;
break;
case 'next':
hls.nextLevel = highestLevel;
break;
case 'load':
default:
hls.loadLevel = highestLevel;
break;
}
}

</script>
</head>
<body>
Expand Down
71 changes: 53 additions & 18 deletions tests/functional/auto/hlsjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ var chromedriver = require("chromedriver");
var HttpServer = require("http-server");

var STREAMS = [
{ url : 'http://www.streambox.fr/playlists/test_001/stream.m3u8', description : 'ARTE China,ABR' },
{ url : 'http://www.streambox.fr/playlists/x36xhzz/x36xhzz.m3u8', description : 'big buck bunny,ABR'},
{ url : 'http://www.streambox.fr/playlists/x36xhzz/url_6/193039199_mp4_h264_aac_hq_7.m3u8', description : 'big buck bunny,480p'},
{ url : 'http://www.streambox.fr/playlists/cisq0gim60007xzvi505emlxx.m3u8', description : 'https://github.com/dailymotion/hls.js/issues/666'}
{ url : 'http://www.streambox.fr/playlists/test_001/stream.m3u8', description : 'ARTE China,ABR', live : false , abr : true},
{ url : 'http://www.streambox.fr/playlists/x36xhzz/x36xhzz.m3u8', description : 'big buck bunny,ABR', live : false, abr : false},
{ url : 'http://www.streambox.fr/playlists/x36xhzz/url_6/193039199_mp4_h264_aac_hq_7.m3u8', description : 'big buck bunny,480p', live : false, abr : false},
{ url : 'http://www.streambox.fr/playlists/cisq0gim60007xzvi505emlxx.m3u8', description : 'https://github.com/dailymotion/hls.js/issues/666', live : false, abr : false},
{ url : 'http://nasatv-lh.akamaihd.net/i/NASA_101@319270/index_1000_av-p.m3u8?sd=10&rebase=on', description : 'NASA live stream', live : true, abr : true}
];


Expand Down Expand Up @@ -62,20 +63,54 @@ describe("testing hls.js playback in the browser", function() {
});
});

it("should seek near the end and receive video ended event for " + stream.description, function() {
var url = stream.url;
return this.browser.executeAsyncScript(function(url) {
var callback = arguments[arguments.length - 1];
startStream(url, callback);
video.onloadeddata = function() {
video.currentTime = video.duration - 5;
};
video.onended = function() {
callback('ended');
};
}, url).then(function(result) {
assert.strictEqual(result, 'ended');
if (stream.abr) {
it("should 'smooth switch' to highest level and still play(readyState === 4) after 12s for " + stream.description, function() {
var url = stream.url;
return this.browser.executeAsyncScript(function(url) {
var callback = arguments[arguments.length - 1];
startStream(url, callback);
video.onloadeddata = function() {
switchToHighestLevel('next');
};
window.setTimeout(function() { callback(video.readyState);},12000);
}, url).then(function(result) {
assert.strictEqual(result, 4);
});
});
});
}

if (stream.live) {
it("should seek near the end and receive video seeked event for " + stream.description, function() {
var url = stream.url;
return this.browser.executeAsyncScript(function(url) {
var callback = arguments[arguments.length - 1];
startStream(url, callback);
video.onloadeddata = function() {
window.setTimeout(function() { video.currentTime = video.duration - 5;},5000);
};
video.onseeked = function() {
callback('seeked');
};
}, url).then(function(result) {
assert.strictEqual(result, 'seeked');
});
});
} else {
it("should seek near the end and receive video ended event for " + stream.description, function() {
var url = stream.url;
return this.browser.executeAsyncScript(function(url) {
var callback = arguments[arguments.length - 1];
startStream(url, callback);
video.onloadeddata = function() {
video.currentTime = video.duration - 5;
};
video.onended = function() {
callback('ended');
};
}, url).then(function(result) {
assert.strictEqual(result, 'ended');
});
});
}
});
});

0 comments on commit 0e00cf5

Please sign in to comment.