Skip to content

Commit

Permalink
test: Stop correctly DASH parser (#5715)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Oct 3, 2023
1 parent 1271a18 commit adb1aca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 24 deletions.
5 changes: 5 additions & 0 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ describe('DashParser Manifest', () => {
};
});

afterEach(() => {
// Dash parser stop is synchronous.
parser.stop();
});

/**
* Makes a series of tests for the given manifest type.
*
Expand Down
5 changes: 5 additions & 0 deletions test/dash/dash_parser_segment_base_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ describe('DashParser SegmentBase', () => {
};
});

afterEach(() => {
// Dash parser stop is synchronous.
parser.stop();
});

it('requests init data for WebM', async () => {
const source = [
'<MPD mediaPresentationDuration="PT75S">',
Expand Down
38 changes: 21 additions & 17 deletions test/dash/dash_parser_segment_list_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,24 +353,28 @@ describe('DashParser SegmentList', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
};
const manifest = await dashParser.start('dummy://foo', playerInterface);
const stream = manifest.variants[0].video;
await stream.createSegmentIndex();
goog.asserts.assert(stream.segmentIndex, 'Expected index to be created');
try {
const manifest = await dashParser.start('dummy://foo', playerInterface);
const stream = manifest.variants[0].video;
await stream.createSegmentIndex();
goog.asserts.assert(stream.segmentIndex, 'Expected index to be created');

// Don't use Dash.testSegmentIndex since it uses SegmentIndex.find, which
// doesn't reproduce this issue. We want to use Array.from which uses the
// iterator.
const expected = [
ManifestParser.makeReference('s1.mp4', 0, 10, baseUri),
ManifestParser.makeReference('s2.mp4', 10, 20, baseUri),
ManifestParser.makeReference('s3.mp4', 20, 30, baseUri),
// Don't use Dash.testSegmentIndex since it uses SegmentIndex.find, which
// doesn't reproduce this issue. We want to use Array.from which uses
// the iterator.
const expected = [
ManifestParser.makeReference('s1.mp4', 0, 10, baseUri),
ManifestParser.makeReference('s2.mp4', 10, 20, baseUri),
ManifestParser.makeReference('s3.mp4', 20, 30, baseUri),

ManifestParser.makeReference('s3.mp4', 30, 40, baseUri),
ManifestParser.makeReference('s4.mp4', 40, 50, baseUri),
ManifestParser.makeReference('s5.mp4', 50, 60, baseUri),
];
const actual = Array.from(stream.segmentIndex);
expect(actual).toEqual(expected);
ManifestParser.makeReference('s3.mp4', 30, 40, baseUri),
ManifestParser.makeReference('s4.mp4', 40, 50, baseUri),
ManifestParser.makeReference('s5.mp4', 50, 60, baseUri),
];
const actual = Array.from(stream.segmentIndex);
expect(actual).toEqual(expected);
} finally {
dashParser.stop();
}
});
});
5 changes: 5 additions & 0 deletions test/dash/dash_parser_segment_template_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ describe('DashParser SegmentTemplate', () => {
};
});

afterEach(() => {
// Dash parser stop is synchronous.
parser.stop();
});

shaka.test.Dash.makeTimelineTests(
'SegmentTemplate', 'media="s$Number$.mp4"', []);

Expand Down
23 changes: 16 additions & 7 deletions test/test/util/dash_parser_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ shaka.test.Dash = class {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
};
const manifest = await dashParser.start('dummy://foo', playerInterface);
const stream = manifest.variants[0].video;
await stream.createSegmentIndex();
try {
const manifest = await dashParser.start('dummy://foo', playerInterface);
const stream = manifest.variants[0].video;
await stream.createSegmentIndex();

shaka.test.ManifestParser.verifySegmentIndex(stream, references);
shaka.test.ManifestParser.verifySegmentIndex(stream, references);
} finally {
dashParser.stop();
}
}

/**
Expand Down Expand Up @@ -86,9 +90,14 @@ shaka.test.Dash = class {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
};
const p = dashParser.start('dummy://foo', playerInterface);
await expectAsync(p).toBeRejectedWith(
shaka.test.Util.jasmineError(expectedError));

try {
const p = dashParser.start('dummy://foo', playerInterface);
await expectAsync(p).toBeRejectedWith(
shaka.test.Util.jasmineError(expectedError));
} finally {
dashParser.stop();
}
}

/**
Expand Down

0 comments on commit adb1aca

Please sign in to comment.