Skip to content

Commit

Permalink
chore: add clock.ticks to now async operations in tests (#315)
Browse files Browse the repository at this point in the history
* add clock.ticks to now async operations

* adding more comments

* use real browser for Chrome

* skip fullscreen test for now

* export path to chrome, start xvfb, add display flag

* use base Chrome
  • Loading branch information
ldayananda authored Dec 17, 2018
1 parent 93b6167 commit 895c86a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ before_script:
- sudo apt-get install --no-install-recommends pulseaudio libavcodec54
- pulseaudio -D
- greenkeeper-lockfile-update
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
after_script: greenkeeper-lockfile-upload
addons:
chrome: stable
Expand Down
2 changes: 1 addition & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = function(config) {

var newBrowsers = [];
if (browsers.indexOf('Chrome') !== -1) {
newBrowsers.push('ChromeHeadlessWithFlags');
newBrowsers.push('Chrome');
}

if (browsers.indexOf('Firefox') !== -1) {
Expand Down
15 changes: 15 additions & 0 deletions test/master-playlist-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,9 @@ QUnit.test('switches off subtitles on subtitle errors', function(assert) {
assert.equal(textTracks[1].kind, 'subtitles', 'kind is subtitles');
textTracks[1].mode = 'showing';

// Wait for VTT segment to be requested
this.clock.tick(1);

assert.equal(this.requests.length, 1, 'made a request');
assert.equal(textTracks[1].mode, 'showing', 'text track still showing');

Expand All @@ -2302,6 +2305,9 @@ QUnit.test('switches off subtitles on subtitle errors', function(assert) {
// re-enable first text track
textTracks[1].mode = 'showing';

// Wait for VTT segment request to be made
this.clock.tick(1);

assert.equal(this.requests.length, 1, 'made a request');
assert.equal(textTracks[1].mode, 'showing', 'text track still showing');

Expand Down Expand Up @@ -2360,6 +2366,9 @@ QUnit.test('pauses subtitle segment loader on tech errors', function(assert) {
assert.equal(textTracks[1].kind, 'subtitles', 'kind is subtitles');
textTracks[1].mode = 'showing';

// Wait for VTT segment request to be made
this.clock.tick(1);

let pauseCount = 0;

masterPlaylistController.subtitleSegmentLoader_.pause = () => pauseCount++;
Expand Down Expand Up @@ -2421,6 +2430,9 @@ QUnit.test('disposes subtitle loaders on dispose', function(assert) {
assert.equal(textTracks[1].kind, 'subtitles', 'kind is subtitles');
textTracks[1].mode = 'showing';

// Wait for VTT segment request to be made
this.clock.tick(1);

assert.ok(masterPlaylistController.mediaTypes_.SUBTITLES.activePlaylistLoader,
'has a subtitle playlist loader');
assert.ok(masterPlaylistController.subtitleSegmentLoader_,
Expand Down Expand Up @@ -2468,6 +2480,9 @@ QUnit.test('subtitle segment loader resets on seeks', function(assert) {
assert.equal(textTracks[1].kind, 'subtitles', 'kind is subtitles');
textTracks[1].mode = 'showing';

// Wait for VTT segment request to be made
this.clock.tick(1);

let resetCount = 0;
let abortCount = 0;
let loadCount = 0;
Expand Down
4 changes: 3 additions & 1 deletion test/videojs-http-streaming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3454,7 +3454,9 @@ QUnit.test('stats are reset on dispose', function(assert) {
assert.equal(hls.stats.mediaBytesTransferred, 0, 'stat is reset');
});

QUnit.test('detects fullscreen and triggers a smooth quality change', function(assert) {
// mocking the fullscreenElement no longer works, find another way to mock
// fullscreen behavior(without user gesture)
QUnit.skip('detects fullscreen and triggers a smooth quality change', function(assert) {
let qualityChanges = 0;
let hls = HlsSourceHandler.handleSource({
src: 'manifest/master.m3u8',
Expand Down

0 comments on commit 895c86a

Please sign in to comment.