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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-seekbar-buffer-with-currentTime.html

Issue 2439083003: Replace flaky test, wrangle with harness/infra
Patch Set: Created 4 years, 1 month 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4
5 <script>
6 // NOTE: For this to work in content shell, must comment
7 // RemoveProprietaryMediaTypesAndCodecsForTests() in shell_main_dele gate.cc
8 force_mp4 = false;
9 if (force_mp4) {
10 // CREDIT: https://github.com/erkserkserks/h264ify
11 // var audioElem = document.createElement('audio');
12 // var origCanPlayType = audioElem.canPlayType.bind(audioElem);
13 // audioElem.__proto__.canPlayType = function(type) {
14 var origChecker = MediaSource.isTypeSupported.bind(MediaSource);
15 MediaSource.isTypeSupported = function(type) {
16 var disallowed_types = ['webm', 'vp8', 'vp9'];
17 // If video type is in disallowed_types, say we don't suppor t them
18 for (var i = 0; i < disallowed_types.length; i++) {
19 if (type.indexOf(disallowed_types[i]) !== -1) return '';
20 }
21
22 // Otherwise, ask the browser
23 return origChecker(type);
24 }
25 }
26 </script>
27 <script src="/w3c/resources/testharness.js"></script>
28 <script src="/w3c/resources/testharnessreport.js"></script>
29 <script src="mediasource-util.js"></script>
30 <link rel="stylesheet" href="/w3c/resources/testharness.css">
31 </head>
32 <body>
33 <script>
34 if (window.testRunner) {
35 testRunner.dumpPixelResults();
36 testRunner.waitUntilDone();
37 }
38
39 // The most important part of this test is verifying correct paintin g of the seekbar
40 // with respect to currentTime and the buffered ranges. Use an audio tag to ensure
41 // controls show persistently without mouse hover. Don't remove the element when the
42 // test completes.
43 test_properties = { audio_only: true, remove_element_when_done: fals e };
44
45
46 mediasource_test(function(test, mediaElement, mediaSource)
47 {
48 // Force controls to show.
49 mediaElement.controls = true;
50
51 // Fetch an audio file using the appropriate manifest.
52 var subType = MediaSourceUtil.getSubType(MediaSourceUtil.AUDIO_O NLY_TYPE);
53 var mediaDataManifest = subType + '/test-a-128k-44100Hz-1ch-mani fest.json';
54 MediaSourceUtil.fetchManifestAndData(test, mediaDataManifest, fu nction(manifest_type, mediaData) {
55
56 // Once fetched, append the whole file.
57 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUt il.AUDIO_ONLY_TYPE);
58 test.expectEvent(sourceBuffer, 'updateend', 'append complete d');
59 test.expectEvent(mediaElement, 'loadedmetadata', 'got metada ta');
60 test.expectEvent(mediaElement, 'canplaythrough', 'can play t hrough');
61
62 sourceBuffer.appendBuffer(mediaData);
63 test.waitForExpectedEvents(function()
64 {
65 // Explicitly set duration (not truncating) to make dura tion same for webm
66 // and mp4 files.
67 test.expectEvent(mediaElement, 'durationchange', 'durati on changed');
68 mediaSource.duration = 2.1;
69 test.waitForExpectedEvents(function()
70 {
71 // One buffered range for full content duration.
72 assert_equals(mediaElement.buffered.length, 1);
73 assert_equals(Math.round(mediaElement.duration), 2);
74
75 // Remove some media in the middle to create two buf fered ranges.
76 sourceBuffer.remove(.5, 1);
77 test.expectEvent(sourceBuffer, 'updateend', 'remove completed');
78
79 test.waitForExpectedEvents(function()
80 {
81 mediaSource.endOfStream();
82
83 // Now two buffered ranges.
84 assert_equals(mediaElement.buffered.length, 2);
85
86 // Seek near the end and play to end.
87 mediaElement.currentTime = 1.75;
88 mediaElement.play();
89
90 // Wait for ended and conclude the test.
91 test.expectEvent(mediaElement, 'ended', 'playbac k ended');
92 test.waitForExpectedEvents(function(){
93 // Pass the test asserts.
94 test.done();
95
96 // Image diff will verify seekbar painting i s correct.
97 if (window.testRunner)
98 testRunner.notifyDone();
99 });
100 });
101 });
102 });
103 });
104 }, 'Verify seekbar indicates buffered range containing currentTime ', test_properties);
105 </script>
106 </body>
107 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698