Skip to content

Commit 3e8c00d

Browse files
authored
test: Remove duplicate code in LCEVC tests (#8471)
1 parent 76ca89c commit 3e8c00d

File tree

1 file changed

+29
-57
lines changed

1 file changed

+29
-57
lines changed

test/lcevc/lcevc_integration.js

Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ describe('LCEVC Integration', () => {
7676
document.body.removeChild(canvas);
7777
});
7878

79+
/**
80+
* @param {string} uri
81+
* @return {!Promise}
82+
*/
83+
async function testPlayback(uri) {
84+
// Wait for LCEVCdec to finish loading
85+
await LCEVCdec.ready;
86+
87+
await player.load(seiManifests.FMP4_DASH);
88+
await video.play();
89+
90+
// Wait for the video to start playback. If it takes longer than 10
91+
// seconds, fail the test.
92+
await waiter.waitForMovementOrFailOnTimeout(video, 10);
93+
94+
// Play for 6 seconds, but stop early if the video ends. If it takes
95+
// longer than 45 seconds, fail the test.
96+
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 6, 45);
97+
98+
// Expect LCEVCdec to be enabled and have detected LCEVC data in SEI
99+
expect(LCEVCdec.instance).toBeDefined();
100+
expect(LCEVCdec.instance.isLcevcEnabled).toBe(true);
101+
expect(LCEVCdec.instance.firstLcevcSegmentLoaded).toBe(true);
102+
expect(LCEVCdec.instance.lcevcDataDetected).toBe(true);
103+
}
104+
79105
describe('SEI Integration', () => {
80106
it('Should decode LCEVC in FMP4 DASH manifest', async () => {
81107
if (shaka.util.Platform.isTizen() || shaka.util.Platform.isChromecast()) {
@@ -87,25 +113,7 @@ describe('LCEVC Integration', () => {
87113
pending('Current platform does not offer WebGL support.');
88114
}
89115

90-
// Wait for LCEVCdec to finish loading
91-
await LCEVCdec.ready;
92-
93-
await player.load(seiManifests.FMP4_DASH);
94-
await video.play();
95-
96-
// Wait for the video to start playback. If it takes longer than 10
97-
// seconds, fail the test.
98-
await waiter.waitForMovementOrFailOnTimeout(video, 10);
99-
100-
// Play for 6 seconds, but stop early if the video ends. If it takes
101-
// longer than 45 seconds, fail the test.
102-
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 6, 45);
103-
104-
// Expect LCEVCdec to be enabled and have detected LCEVC data in SEI
105-
expect(LCEVCdec.instance).toBeDefined();
106-
expect(LCEVCdec.instance.isLcevcEnabled).toBe(true);
107-
expect(LCEVCdec.instance.firstLcevcSegmentLoaded).toBe(true);
108-
expect(LCEVCdec.instance.lcevcDataDetected).toBe(true);
116+
await testPlayback(seiManifests.FMP4_DASH);
109117
});
110118

111119
it('Should decode LCEVC in FMP4 HLS manifest', async () => {
@@ -118,25 +126,7 @@ describe('LCEVC Integration', () => {
118126
pending('Current platform does not offer WebGL support.');
119127
}
120128

121-
// Wait for LCEVCdec to finish loading
122-
await LCEVCdec.ready;
123-
124-
await player.load(seiManifests.FMP4_HLS);
125-
await video.play();
126-
127-
// Wait for the video to start playback. If it takes longer than 10
128-
// seconds, fail the test.
129-
await waiter.waitForMovementOrFailOnTimeout(video, 10);
130-
131-
// Play for 6 seconds, but stop early if the video ends. If it takes
132-
// longer than 45 seconds, fail the test.
133-
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 6, 45);
134-
135-
// Expect LCEVCdec to be enabled and have detected LCEVC data in SEI
136-
expect(LCEVCdec.instance).toBeDefined();
137-
expect(LCEVCdec.instance.isLcevcEnabled).toBe(true);
138-
expect(LCEVCdec.instance.firstLcevcSegmentLoaded).toBe(true);
139-
expect(LCEVCdec.instance.lcevcDataDetected).toBe(true);
129+
await testPlayback(seiManifests.FMP4_HLS);
140130
});
141131

142132
it('Should decode LCEVC in TS HLS manifest', async () => {
@@ -149,25 +139,7 @@ describe('LCEVC Integration', () => {
149139
pending('Current platform does not offer WebGL support.');
150140
}
151141

152-
// Wait for LCEVCdec to finish loading
153-
await LCEVCdec.ready;
154-
155-
await player.load(seiManifests.TS_HLS);
156-
await video.play();
157-
158-
// Wait for the video to start playback. If it takes longer than 10
159-
// seconds, fail the test.
160-
await waiter.waitForMovementOrFailOnTimeout(video, 10);
161-
162-
// Play for 6 seconds, but stop early if the video ends. If it takes
163-
// longer than 45 seconds, fail the test.
164-
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 6, 45);
165-
166-
// Expect LCEVCdec to be enabled and have detected LCEVC data in SEI
167-
expect(LCEVCdec.instance).toBeDefined();
168-
expect(LCEVCdec.instance.isLcevcEnabled).toBe(true);
169-
expect(LCEVCdec.instance.firstLcevcSegmentLoaded).toBe(true);
170-
expect(LCEVCdec.instance.lcevcDataDetected).toBe(true);
142+
await testPlayback(seiManifests.TS_HLS);
171143
});
172144
});
173145
});

0 commit comments

Comments
 (0)