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

Side by Side Diff: LayoutTests/http/tests/media/media-source/mediasource-config-changes.js

Issue 103913010: Add new "resize" event to HTMLMediaElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: vsevik & acolwell CR Created 7 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/media/video-frame-size-change.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Extract & return the resolution string from a filename, if any.
2 function resolutionFromFilename(filename)
3 {
4 resolution = filename.replace(/^.*[^0-9]([0-9]+x[0-9]+)[^0-9].*$/, "$1");
5 if (resolution != filename) {
6 return resolution;
7 }
8 return "";
9 }
10
1 function appendBuffer(test, sourceBuffer, data) 11 function appendBuffer(test, sourceBuffer, data)
2 { 12 {
3 test.expectEvent(sourceBuffer, "update"); 13 test.expectEvent(sourceBuffer, "update");
4 test.expectEvent(sourceBuffer, "updateend"); 14 test.expectEvent(sourceBuffer, "updateend");
5 sourceBuffer.appendBuffer(data); 15 sourceBuffer.appendBuffer(data);
6 } 16 }
7 17
8 function mediaSourceConfigChangeTest(directory, idA, idB, description) 18 function mediaSourceConfigChangeTest(directory, idA, idB, description)
9 { 19 {
10 var manifestFilenameA = directory + "/test-" + idA + "-manifest.json"; 20 var manifestFilenameA = directory + "/test-" + idA + "-manifest.json";
11 var manifestFilenameB = directory + "/test-" + idB + "-manifest.json"; 21 var manifestFilenameB = directory + "/test-" + idB + "-manifest.json";
12 mediasource_test(function(test, mediaElement, mediaSource) 22 mediasource_test(function(test, mediaElement, mediaSource)
13 { 23 {
14 mediaElement.pause(); 24 mediaElement.pause();
15 test.failOnEvent(mediaElement, 'error'); 25 test.failOnEvent(mediaElement, 'error');
16 test.endOnEvent(mediaElement, 'ended'); 26 var expectResizeEvents = resolutionFromFilename(manifestFilenameA) != re solutionFromFilename(manifestFilenameB);
27 var expectedResizeEventCount = 0;
17 28
18 MediaSourceUtil.fetchManifestAndData(test, manifestFilenameA, function(t ypeA, dataA) 29 MediaSourceUtil.fetchManifestAndData(test, manifestFilenameA, function(t ypeA, dataA)
19 { 30 {
20 MediaSourceUtil.fetchManifestAndData(test, manifestFilenameB, functi on(typeB, dataB) 31 MediaSourceUtil.fetchManifestAndData(test, manifestFilenameB, functi on(typeB, dataB)
21 { 32 {
22 assert_equals(typeA, typeB, "Media format types match"); 33 assert_equals(typeA, typeB, "Media format types match");
23 34
24 var sourceBuffer = mediaSource.addSourceBuffer(typeA); 35 var sourceBuffer = mediaSource.addSourceBuffer(typeA);
25 36
26 appendBuffer(test, sourceBuffer, dataA); 37 appendBuffer(test, sourceBuffer, dataA);
27 38
28 test.waitForExpectedEvents(function() 39 test.waitForExpectedEvents(function()
29 { 40 {
30 // Add the second buffer starting at 0.5 second. 41 // Add the second buffer starting at 0.5 second.
31 sourceBuffer.timestampOffset = 0.5; 42 sourceBuffer.timestampOffset = 0.5;
32 appendBuffer(test, sourceBuffer, dataB); 43 appendBuffer(test, sourceBuffer, dataB);
44 ++expectedResizeEventCount;
33 }); 45 });
34 46
35 test.waitForExpectedEvents(function() 47 test.waitForExpectedEvents(function()
36 { 48 {
37 // Add the first buffer starting at 1 second. 49 // Add the first buffer starting at 1 second.
38 sourceBuffer.timestampOffset = 1; 50 sourceBuffer.timestampOffset = 1;
39 appendBuffer(test, sourceBuffer, dataA); 51 appendBuffer(test, sourceBuffer, dataA);
52 ++expectedResizeEventCount;
40 }); 53 });
41 54
42 test.waitForExpectedEvents(function() 55 test.waitForExpectedEvents(function()
43 { 56 {
44 // Add the second buffer starting at 1.5 second. 57 // Add the second buffer starting at 1.5 second.
45 sourceBuffer.timestampOffset = 1.5; 58 sourceBuffer.timestampOffset = 1.5;
46 appendBuffer(test, sourceBuffer, dataB); 59 appendBuffer(test, sourceBuffer, dataB);
60 ++expectedResizeEventCount;
47 }); 61 });
48 62
49 test.waitForExpectedEvents(function() 63 test.waitForExpectedEvents(function()
50 { 64 {
51 // Truncate the presentation to a duration of 2 seconds. 65 // Truncate the presentation to a duration of 2 seconds.
52 mediaSource.duration = 2; 66 mediaSource.duration = 2;
53 mediaSource.endOfStream(); 67 mediaSource.endOfStream();
54 68
69 if (expectResizeEvents) {
70 for (var i = 0; i < expectedResizeEventCount; ++i) {
71 test.expectEvent(mediaElement, "resize");
72 }
73 }
74 test.expectEvent(mediaElement, "ended");
55 mediaElement.play(); 75 mediaElement.play();
56 }); 76 });
77
78 test.waitForExpectedEvents(function() {
79 test.done();
80 });
57 }); 81 });
58 }); 82 });
59 }, description, { timeout: 10000 } ); 83 }, description, { timeout: 10000 } );
60 }; 84 };
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/media/video-frame-size-change.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698