Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html

Issue 245893002: Improve unprefixed MediaSource test coverage. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html b/LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html
new file mode 100644
index 0000000000000000000000000000000000000000..8dbec0bc07c2f33c0029fac425ca2f901113c8f9
--- /dev/null
+++ b/LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src="/w3c/resources/testharness.js"></script>
+ <script src="/w3c/resources/testharnessreport.js"></script>
+ <script src="mediasource-util.js"></script>
+ <link rel='stylesheet' href='/w3c/resources/testharness.css'>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ function DurationBoundaryConditionTest(testDurationValue, expectedError, description)
+ {
+ return mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ // Append initialization segment.
+ test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
+ test.expectEvent(mediaElement, 'loadedmetadata', 'mediaElement');
+ sourceBuffer.appendBuffer(MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init));
+ test.waitForExpectedEvents(function()
+ {
+ if (expectedError) {
+ assert_throws(expectedError,
+ function() { mediaSource.duration = testDurationValue; },
+ "mediaSource.duration assignment throws an exception for " + testDurationValue);
+ test.done();
+ return;
+ }
+
+ mediaSource.duration = testDurationValue;
+
+ assert_equals(mediaSource.duration, testDurationValue, "mediaSource.duration");
+ assert_equals(mediaElement.duration, testDurationValue, "mediaElement.duration");
+
+ test.expectEvent(mediaElement, 'durationchange', 'mediaElement');
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaSource.duration, testDurationValue, "mediaSource.duration");
+ assert_equals(mediaElement.duration, testDurationValue, "mediaElement.duration");
+ test.done();
+ });
+ });
+
+ }, description);
+ }
+
+ DurationBoundaryConditionTest(Math.pow(2, 31) - 1, null, "Set duration to 2^31 - 1");
+ DurationBoundaryConditionTest(1, null, "Set duration to 1");
+ DurationBoundaryConditionTest(Number.MAX_VALUE, null, "Set duration to Number.MAX_VALUE");
+ DurationBoundaryConditionTest(Number.MIN_VALUE, null, "Set duration to Number.MIN_VALUE");
+ DurationBoundaryConditionTest(Number.MAX_VALUE - 1, null, "Set duration to Number.MAX_VALUE - 1");
+ DurationBoundaryConditionTest(Number.MIN_VALUE - 1, "InvalidAccessError", "Set duration to Number.MIN_VALUE - 1");
+ DurationBoundaryConditionTest(Number.POSITIVE_INFINITY, null, "Set duration to Number.POSITIVE_INFINITY");
+ DurationBoundaryConditionTest(Number.NEGATIVE_INFINITY, "InvalidAccessError", "Set duration to Number.NEGATIVE_INFINITY");
+ DurationBoundaryConditionTest(-1 * Number.MAX_VALUE, "InvalidAccessError", "Set duration to lowest value.");
+ DurationBoundaryConditionTest(-101.9, "InvalidAccessError", "Set duration to a negative double.");
+ DurationBoundaryConditionTest(101.9, null, "Set duration to a positive double.");
+ DurationBoundaryConditionTest(0, null, "Set duration to zero");
+ DurationBoundaryConditionTest(NaN, "InvalidAccessError", "Set duration to NaN");
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698