Skip to content

Commit

Permalink
Debug 6001 error in shaka-project#6575
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed May 14, 2024
1 parent 87de6e0 commit 27acfb4
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 1,378 deletions.
14 changes: 8 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,14 @@ module.exports = (config) => {
clientArgs.testFiles.push('test/player_external.js');
} else {
// In a normal test run, we serve unit tests.
clientArgs.testFiles.push('test/**/*_unit.js');

if (!settings.quick) {
// If --quick is present, we don't serve integration tests.
clientArgs.testFiles.push('test/**/*_integration.js');
}
clientArgs.testFiles.push('test/**/ads_integration.js');
clientArgs.testFiles.push('test/**/player_integration.js');
clientArgs.testFiles.push('test/**/hls_parser_integration.js');

// if (!settings.quick) {
// // If --quick is present, we don't serve integration tests.
// clientArgs.testFiles.push('test/**/*_integration.js');
// }
if (settings.external) {
// If --external is present, we serve external asset tests.
clientArgs.testFiles.push('demo/common/asset.js');
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"prepublishOnly": "python build/checkversion.py && python build/all.py --force"
},
"dependencies": {
"eme-encryption-scheme-polyfill": "^2.1.2"
"eme-encryption-scheme-polyfill": "^2.1.3"
},
"engines": {
"node": ">=14"
Expand Down
116 changes: 116 additions & 0 deletions test/ads_integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

describe('Ads', () => {
const Util = shaka.test.Util;

/** @type {!jasmine.Spy} */
let onErrorSpy;

/** @type {!HTMLScriptElement} */
let imaScript;
/** @type {!HTMLVideoElement} */
let video;
/** @type {!HTMLElement} */
let adContainer;
/** @type {shaka.Player} */
let player;
/** @type {shaka.extern.IAdManager} */
let adManager;
/** @type {!shaka.util.EventManager} */
let eventManager;

let compiledShaka;

/** @type {!shaka.test.Waiter} */
let waiter;

beforeAll(async () => {
imaScript = shaka.test.UiUtils.createImaSdkScript();
const loadImaScript = new Promise((resolve, reject) => {
imaScript.onload = resolve;
imaScript.onerror= reject;
});
document.head.appendChild(imaScript);
await loadImaScript;
video = shaka.test.UiUtils.createVideoElement();
document.body.appendChild(video);
adContainer =
/** @type {!HTMLElement} */ (document.createElement('div'));
document.body.appendChild(adContainer);
compiledShaka =
await shaka.test.Loader.loadShaka(getClientArg('uncompiled'));
});

beforeEach(async () => {
await shaka.test.TestScheme.createManifests(compiledShaka, '_compiled');
player = new compiledShaka.Player();
adManager = player.getAdManager();
await player.attach(video);

player.configure('streaming.useNativeHlsOnSafari', false);

// Disable stall detection, which can interfere with playback tests.
player.configure('streaming.stallEnabled', false);

// Grab event manager from the uncompiled library:
eventManager = new shaka.util.EventManager();
waiter = new shaka.test.Waiter(eventManager);
waiter.setPlayer(player);

onErrorSpy = jasmine.createSpy('onError');
onErrorSpy.and.callFake((event) => fail(event.detail));
eventManager.listen(player, 'error', Util.spyFunc(onErrorSpy));
eventManager.listen(adManager, shaka.ads.AdManager.AD_ERROR,
Util.spyFunc(onErrorSpy));
});

afterEach(async () => {
eventManager.release();
await player.destroy();
});

afterAll(() => {
document.head.removeChild(imaScript);
document.body.removeChild(video);
});

it('supports IMA SDK with vast', async () => {
adManager.initClientSide(
adContainer, video, /** adsRenderingSettings= **/ null);

await player.load('/base/test/test/assets/dash-aes-128/dash.mpd');
await video.play();
expect(player.isLive()).toBe(false);

// Wait for the video to start playback. If it takes longer than 10
// seconds, fail the test.
await waiter.waitForMovementOrFailOnTimeout(video, 10);

// Play for 5 seconds, but stop early if the video ends. If it takes
// longer than 20 seconds, fail the test.
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 5, 20);

const adRequest = new google.ima.AdsRequest();
adRequest.adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?' +
'sz=640x480&iu=/124319096/external/single_ad_samples&' +
'ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&' +
'unviewed_position_start=1&' +
'cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=';
adManager.requestClientSideAds(adRequest);

// The ad lasts 10 seconds. If it takes longer than 300 seconds, fail the
// test.
await waiter.timeoutAfter(30)
.waitForEvent(adManager, shaka.ads.AdManager.AD_STOPPED);

// Play for 10 seconds, but stop early if the video ends. If it takes
// longer than 30 seconds, fail the test.
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 10, 30);

await player.unload();
});
});
52 changes: 0 additions & 52 deletions test/hls/hls_parser_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,6 @@ describe('HlsParser', () => {
document.body.removeChild(video);
});

it('supports AES-256 streaming', async () => {
let keyRequests = 0;
const netEngine = player.getNetworkingEngine();
netEngine.registerRequestFilter((type, request, context) => {
if (type == shaka.net.NetworkingEngine.RequestType.KEY) {
keyRequests++;
}
});
await player.load('/base/test/test/assets/hls-aes-256/index.m3u8');
await video.play();
expect(player.isLive()).toBe(false);

// Wait for the video to start playback. If it takes longer than 10
// seconds, fail the test.
await waiter.waitForMovementOrFailOnTimeout(video, 10);

// Play for 10 seconds, but stop early if the video ends. If it takes
// longer than 30 seconds, fail the test.
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 10, 30);

await player.unload();

// The stream has 6 #EXT-X-KEY but only 5 different keys.
expect(keyRequests).toBe(5);
});

drmIt('supports SAMPLE-AES identity streaming', async () => {
if (!checkClearKeySupport()) {
pending('ClearKey is not supported');
Expand All @@ -115,30 +89,4 @@ describe('HlsParser', () => {

await player.unload();
});

it('supports text discontinuity', async () => {
if (!shaka.util.Platform.supportsSequenceMode()) {
pending('Sequence mode is not supported by the platform.');
}

player.configure('manifest.hls.ignoreManifestProgramDateTime', true);
player.setTextTrackVisibility(true);

await player.load('/base/test/test/assets/hls-text-offset/index.m3u8');
await video.play();

// Wait for last cue
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 7, 30);

const cues = video.textTracks[0].cues;
expect(cues.length).toBe(3);
expect(cues[0].startTime).toBeCloseTo(0, 0);
expect(cues[0].endTime).toBeCloseTo(2, 0);
expect(cues[1].startTime).toBeCloseTo(2, 0);
expect(cues[1].endTime).toBeCloseTo(4, 0);
expect(cues[2].startTime).toBeCloseTo(6, 0);
expect(cues[2].endTime).toBeCloseTo(8, 0);

await player.unload();
});
});

0 comments on commit 27acfb4

Please sign in to comment.