From a63939c34233ddec44ecb9bf612d7e651292a1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Wed, 30 Aug 2023 09:48:01 +0200 Subject: [PATCH 1/2] test: Improve transmuxer tests --- test/test/util/ui_utils.js | 4 +- test/transmuxer/transmuxer_integration.js | 410 +++++++++++----------- 2 files changed, 204 insertions(+), 210 deletions(-) diff --git a/test/test/util/ui_utils.js b/test/test/util/ui_utils.js index e8ff648448..a4db3fd423 100644 --- a/test/test/util/ui_utils.js +++ b/test/test/util/ui_utils.js @@ -169,7 +169,9 @@ shaka.test.UiUtils = class { const video = /** @type {!HTMLVideoElement} */(document.createElement( 'video')); - video.muted = true; + if (!shaka.util.Platform.isTizen()) { + video.muted = true; + } video.width = 600; video.height = 400; diff --git a/test/transmuxer/transmuxer_integration.js b/test/transmuxer/transmuxer_integration.js index 71159c0b9b..5bb8ebb1c1 100644 --- a/test/transmuxer/transmuxer_integration.js +++ b/test/transmuxer/transmuxer_integration.js @@ -22,6 +22,48 @@ describe('Transmuxer Player', () => { /** @type {!shaka.test.Waiter} */ let waiter; + function isAc3Supported() { + if (!MediaSource.isTypeSupported('audio/mp4; codecs="ac-3"')) { + return false; + } + // AC3 is flaky in some Tizen devices, so we need omit it for now. + if (shaka.util.Platform.isTizen()) { + return false; + } + // It seems that AC3 on Edge Windows from github actions is not working + // (in the lab AC3 is working). The AC3 detection is currently hard-coded + // to true, which leads to a failure in GitHub's environment. + // We must enable this, once it is resolved: + // https://bugs.chromium.org/p/chromium/issues/detail?id=1450313 + const chromeVersion = shaka.util.Platform.chromeVersion(); + if (shaka.util.Platform.isEdge() && + chromeVersion && chromeVersion <= 116) { + return false; + } + return true; + } + + function isEc3Supported() { + if (!MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) { + return false; + } + // EC3 is flaky in some Tizen devices, so we need omit it for now. + if (shaka.util.Platform.isTizen()) { + return false; + } + // It seems that EC3 on Edge Windows from github actions is not working + // (in the lab EC3 is working). The EC3 detection is currently hard-coded + // to true, which leads to a failure in GitHub's environment. + // We must enable this, once it is resolved: + // https://bugs.chromium.org/p/chromium/issues/detail?id=1450313 + const chromeVersion = shaka.util.Platform.chromeVersion(); + if (shaka.util.Platform.isEdge() && + chromeVersion && chromeVersion <= 116) { + return false; + } + return true; + } + beforeAll(async () => { video = shaka.test.UiUtils.createVideoElement(); document.body.appendChild(video); @@ -58,247 +100,197 @@ describe('Transmuxer Player', () => { document.body.removeChild(video); }); - it('raw AAC', async () => { - await player.load('/base/test/test/assets/hls-raw-aac/manifest.m3u8'); - await video.play(); - expect(player.isLive()).toBe(false); + describe('for audio', () => { + it('raw AAC', async () => { + await player.load('/base/test/test/assets/hls-raw-aac/manifest.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); + // Wait for the video to start playback. If it takes longer than 10 + // seconds, fail the test. + await waiter.waitForMovementOrFailOnTimeout(video, 10); - // Play for 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + // Play for 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - await player.unload(); - }); - - it('raw MP3', async () => { - if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"')) { - return; - } - await player.load('/base/test/test/assets/hls-raw-mp3/playlist.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 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - - await player.unload(); - }); + await player.unload(); + }); - it('raw AC3', async () => { - if (!MediaSource.isTypeSupported('audio/mp4; codecs="ac-3"')) { - return; - } - // This tests is flaky in some Tizen devices, so we need omit it for now. - if (shaka.util.Platform.isTizen()) { - return; - } - // It seems that AC3 on Edge Windows from github actions is not working - // (in the lab AC3 is working). The AC3 detection is currently hard-coded - // to true, which leads to a failure in GitHub's environment. - // We must enable this, once it is resolved: - // https://bugs.chromium.org/p/chromium/issues/detail?id=1450313 - const chromeVersion = shaka.util.Platform.chromeVersion(); - if (shaka.util.Platform.isEdge() && - chromeVersion && chromeVersion <= 116) { - return; - } - - await player.load('/base/test/test/assets/hls-raw-ac3/prog_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 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - - await player.unload(); - }); + it('raw MP3', async () => { + if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"')) { + return; + } + await player.load('/base/test/test/assets/hls-raw-mp3/playlist.m3u8'); + await video.play(); + expect(player.isLive()).toBe(false); - it('raw EC3', async () => { - if (!MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) { - return; - } - // This tests is flaky in some Tizen devices, so we need omit it for now. - if (shaka.util.Platform.isTizen()) { - return; - } - // It seems that AC3 on Edge Windows from github actions is not working - // (in the lab AC3 is working). The AC3 detection is currently hard-coded - // to true, which leads to a failure in GitHub's environment. - // We must enable this, once it is resolved: - // https://bugs.chromium.org/p/chromium/issues/detail?id=1450313 - const chromeVersion = shaka.util.Platform.chromeVersion(); - if (shaka.util.Platform.isEdge() && - chromeVersion && chromeVersion <= 116) { - return; - } + // Wait for the video to start playback. If it takes longer than 10 + // seconds, fail the test. + await waiter.waitForMovementOrFailOnTimeout(video, 10); - await player.load('/base/test/test/assets/hls-raw-ac3/prog_index.m3u8'); - await video.play(); - expect(player.isLive()).toBe(false); + // Play for 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - // Wait for the video to start playback. If it takes longer than 10 - // seconds, fail the test. - await waiter.waitForMovementOrFailOnTimeout(video, 10); + await player.unload(); + }); - // Play for 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + it('raw AC3', async () => { + if (!isAc3Supported()) { + return; + } - await player.unload(); - }); + await player.load('/base/test/test/assets/hls-raw-ac3/prog_index.m3u8'); + await video.play(); + expect(player.isLive()).toBe(false); - it('muxed H.264+AAC in TS', async () => { - // eslint-disable-next-line max-len - await player.load('/base/test/test/assets/hls-ts-muxed-aac-h264/playlist.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); - // Wait for the video to start playback. If it takes longer than 10 - // seconds, fail the test. - await waiter.waitForMovementOrFailOnTimeout(video, 10); + // Play for 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - // Play for 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + await player.unload(); + }); - await player.unload(); - }); + it('raw EC3', async () => { + if (!isEc3Supported()) { + return; + } - it('AAC in TS', async () => { - await player.load('/base/test/test/assets/hls-ts-aac/playlist.m3u8'); - await video.play(); - expect(player.isLive()).toBe(false); + await player.load('/base/test/test/assets/hls-raw-ac3/prog_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); + // Wait for the video to start playback. If it takes longer than 10 + // seconds, fail the test. + await waiter.waitForMovementOrFailOnTimeout(video, 10); - // Play for 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + // Play for 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - await player.unload(); - }); + await player.unload(); + }); - it('H.264 in TS', async () => { - await player.load('/base/test/test/assets/hls-ts-h264/prog_index.m3u8'); - await video.play(); - expect(player.isLive()).toBe(false); + it('AAC in TS', async () => { + await player.load('/base/test/test/assets/hls-ts-aac/playlist.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); + // Wait for the video to start playback. If it takes longer than 10 + // seconds, fail the test. + await waiter.waitForMovementOrFailOnTimeout(video, 10); - // Play for 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + // Play for 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - await player.unload(); - }); + await player.unload(); + }); - it('MP3 in TS', async () => { - if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"') && + it('MP3 in TS', async () => { + if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"') && !MediaSource.isTypeSupported('audio/mpeg')) { - return; - } - // This tests is flaky in some Tizen devices, so we need omit it for now. - if (shaka.util.Platform.isTizen()) { - return; - } - await player.load('/base/test/test/assets/hls-ts-mp3/manifest.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 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - - await player.unload(); + return; + } + // This tests is flaky in some Tizen devices, so we need omit it for now. + if (shaka.util.Platform.isTizen()) { + return; + } + await player.load('/base/test/test/assets/hls-ts-mp3/manifest.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 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + + await player.unload(); + }); + + it('AC3 in TS', async () => { + if (!isAc3Supported()) { + return; + } + + await player.load('/base/test/test/assets/hls-ts-ac3/prog_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 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + + await player.unload(); + }); + + it('EC3 in TS', async () => { + if (!isEc3Supported()) { + return; + } + + await player.load('/base/test/test/assets/hls-ts-ec3/prog_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 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + + await player.unload(); + }); }); - it('AC3 in TS', async () => { - if (!MediaSource.isTypeSupported('audio/mp4; codecs="ac-3"')) { - return; - } - // This tests is flaky in some Tizen devices, so we need omit it for now. - if (shaka.util.Platform.isTizen()) { - return; - } - // It seems that AC3 on Edge Windows from github actions is not working - // (in the lab AC3 is working). The AC3 detection is currently hard-coded - // to true, which leads to a failure in GitHub's environment. - // We must enable this, once it is resolved: - // https://bugs.chromium.org/p/chromium/issues/detail?id=1450313 - const chromeVersion = shaka.util.Platform.chromeVersion(); - if (shaka.util.Platform.isEdge() && - chromeVersion && chromeVersion <= 116) { - return; - } + describe('for video', () => { + it('H.264 in TS', async () => { + await player.load('/base/test/test/assets/hls-ts-h264/prog_index.m3u8'); + await video.play(); + expect(player.isLive()).toBe(false); - await player.load('/base/test/test/assets/hls-ts-ac3/prog_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); - // Wait for the video to start playback. If it takes longer than 10 - // seconds, fail the test. - await waiter.waitForMovementOrFailOnTimeout(video, 10); + // Play for 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - // Play for 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - - await player.unload(); + await player.unload(); + }); }); - it('EC3 in TS', async () => { - if (!MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) { - return; - } - // This tests is flaky in some Tizen devices, so we need omit it for now. - if (shaka.util.Platform.isTizen()) { - return; - } - // It seems that AC3 on Edge Windows from github actions is not working - // (in the lab AC3 is working). The AC3 detection is currently hard-coded - // to true, which leads to a failure in GitHub's environment. - // We must enable this, once it is resolved: - // https://bugs.chromium.org/p/chromium/issues/detail?id=1450313 - const chromeVersion = shaka.util.Platform.chromeVersion(); - if (shaka.util.Platform.isEdge() && - chromeVersion && chromeVersion <= 116) { - return; - } - - await player.load('/base/test/test/assets/hls-ts-ec3/prog_index.m3u8'); - await video.play(); - expect(player.isLive()).toBe(false); + describe('for muxed content', () => { + it('H.264+AAC in TS', async () => { + // eslint-disable-next-line max-len + await player.load('/base/test/test/assets/hls-ts-muxed-aac-h264/playlist.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); + // Wait for the video to start playback. If it takes longer than 10 + // seconds, fail the test. + await waiter.waitForMovementOrFailOnTimeout(video, 10); - // Play for 15 seconds, but stop early if the video ends. If it takes - // longer than 45 seconds, fail the test. - await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); + // Play for 15 seconds, but stop early if the video ends. If it takes + // longer than 45 seconds, fail the test. + await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 15, 45); - await player.unload(); + await player.unload(); + }); }); }); From 297081e301ea12fa598936b86c05a6fccaf79873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Wed, 30 Aug 2023 17:48:35 +0200 Subject: [PATCH 2/2] Update PR --- test/test/util/ui_utils.js | 2 ++ test/transmuxer/transmuxer_integration.js | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/test/util/ui_utils.js b/test/test/util/ui_utils.js index a4db3fd423..2d4a9d273e 100644 --- a/test/test/util/ui_utils.js +++ b/test/test/util/ui_utils.js @@ -169,6 +169,8 @@ shaka.test.UiUtils = class { const video = /** @type {!HTMLVideoElement} */(document.createElement( 'video')); + // Tizen has issues with audio-only playbacks on muted video elements. + // Don't mute Tizen. if (!shaka.util.Platform.isTizen()) { video.muted = true; } diff --git a/test/transmuxer/transmuxer_integration.js b/test/transmuxer/transmuxer_integration.js index 5bb8ebb1c1..f09f48dd2e 100644 --- a/test/transmuxer/transmuxer_integration.js +++ b/test/transmuxer/transmuxer_integration.js @@ -119,7 +119,7 @@ describe('Transmuxer Player', () => { it('raw MP3', async () => { if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"')) { - return; + pending('Codec MP3 in MP4 is not supported by the platform.'); } await player.load('/base/test/test/assets/hls-raw-mp3/playlist.m3u8'); await video.play(); @@ -138,7 +138,7 @@ describe('Transmuxer Player', () => { it('raw AC3', async () => { if (!isAc3Supported()) { - return; + pending('Codec AC-3 is not supported by the platform.'); } await player.load('/base/test/test/assets/hls-raw-ac3/prog_index.m3u8'); @@ -158,7 +158,7 @@ describe('Transmuxer Player', () => { it('raw EC3', async () => { if (!isEc3Supported()) { - return; + pending('Codec EC-3 is not supported by the platform.'); } await player.load('/base/test/test/assets/hls-raw-ac3/prog_index.m3u8'); @@ -195,7 +195,7 @@ describe('Transmuxer Player', () => { it('MP3 in TS', async () => { if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"') && !MediaSource.isTypeSupported('audio/mpeg')) { - return; + pending('Codec MP3 is not supported by the platform.'); } // This tests is flaky in some Tizen devices, so we need omit it for now. if (shaka.util.Platform.isTizen()) { @@ -218,7 +218,7 @@ describe('Transmuxer Player', () => { it('AC3 in TS', async () => { if (!isAc3Supported()) { - return; + pending('Codec AC-3 is not supported by the platform.'); } await player.load('/base/test/test/assets/hls-ts-ac3/prog_index.m3u8'); @@ -238,7 +238,7 @@ describe('Transmuxer Player', () => { it('EC3 in TS', async () => { if (!isEc3Supported()) { - return; + pending('Codec EC-3 is not supported by the platform.'); } await player.load('/base/test/test/assets/hls-ts-ec3/prog_index.m3u8');