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

Side by Side Diff: LayoutTests/media/audio-concurrent-supported.html

Issue 600513002: Simplify media/audio-concurrent-supported.html thanks to r182442. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/media/audio-concurrent-supported-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <title>Test of concurrent HTML5 audio</title> 2 <title>Test of concurrent HTML5 audio</title>
3 <body> 3 <body>
4 4
5 <p>Test that multiple audio elements can play concurrently.</p> 5 <p>Test that multiple audio elements can play concurrently.</p>
6 6
7 <script src=video-test.js></script> 7 <script src=video-test.js></script>
8 <script src=media-file.js></script> 8 <script src=media-file.js></script>
9 <script> 9 <script>
10 var maxPlayers = 2; // Number of concurrent audio elements to test. For larger values a longer media file is needed. 10 var maxPlayers = 2; // Number of concurrent audio elements to test. For larger values a longer media file is needed.
11 var timeupdateEventCount = 0;
12 var audioElementCount = 0; 11 var audioElementCount = 0;
13 12
14 function errorListener(event) 13 function errorListener(event)
15 { 14 {
16 logResult(false, "Element " + audioElementCount + " caught 'error' event, audio.error.code = " + this.error.code); 15 logResult(false, "Element " + audioElementCount + " caught 'error' event, audio.error.code = " + this.error.code);
17 endTest(); 16 endTest();
18 } 17 }
19 18
20 function canplaythroughListener(event) 19 function canplaythroughListener(event)
21 { 20 {
22 consoleWrite("EVENT(" + audioElementCount + ", canplaythrough)"); 21 consoleWrite("EVENT(" + audioElementCount + ", canplaythrough)");
23 testElement = this; 22 testElement = this;
24 testExpected(audioElementCount + ", testElement.currentTime", 0); 23 testExpected(audioElementCount + ", testElement.currentTime", 0);
25 this.play(); 24 this.play();
26 } 25 }
27 26
28 function playingListener(event) 27 function playingListener(event)
29 { 28 {
30 consoleWrite("EVENT(" + audioElementCount + ", playing)"); 29 consoleWrite("EVENT(" + audioElementCount + ", playing)");
31 } 30 }
32 31
33 function timeupdateListener(event) 32 function timeupdateListener(event)
34 { 33 {
35 // Make sure time is advancing. 34 testElement = this;
36 if (this.currentTime > 0) { 35 testExpected(audioElementCount + ", testElement.currentTime", 0, '>' );
37 this.removeEventListener('timeupdate', timeupdateListener); 36 this.removeEventListener('timeupdate', timeupdateListener);
38 if (++audioElementCount >= maxPlayers) { 37 if (++audioElementCount >= maxPlayers) {
39 // All audio elements have been started playing. Make sure 38 // All audio elements have been started playing. Make sure
40 // all of them are still playing. 39 // all of them are still playing.
41 consoleWrite("Making sure all " + maxPlayers + " audio eleme nts are in playing state:"); 40 consoleWrite("Making sure all " + maxPlayers + " audio elements are in playing state:");
42 for (var i = 0; i < maxPlayers; i++) { 41 for (var i = 0; i < maxPlayers; i++) {
43 testElement = document.getElementsByTagName('audio')[i]; 42 testElement = document.getElementsByTagName('audio')[i];
44 testExpected(i + ", testElement.paused", false); 43 testExpected(i + ", testElement.paused", false);
45 }
46 endTest();
47 } else {
48 // Start the next audio element
49 testAudioElement(audioElementCount);
50 } 44 }
45 endTest();
46 } else {
47 // Start the next audio element
48 testAudioElement(audioElementCount);
51 } 49 }
52 } 50 }
53 51
54 function testAudioElement(count) 52 function testAudioElement(count)
55 { 53 {
56 var audioElement = document.getElementsByTagName('audio')[count]; 54 var audioElement = document.getElementsByTagName('audio')[count];
57 audioElement.addEventListener('error', errorListener); 55 audioElement.addEventListener('error', errorListener);
58 audioElement.addEventListener('canplaythrough', canplaythroughListen er); 56 audioElement.addEventListener('canplaythrough', canplaythroughListen er);
59 timeupdateEventCount = 0;
60 audioElement.addEventListener('timeupdate', timeupdateListener); 57 audioElement.addEventListener('timeupdate', timeupdateListener);
61 audioElement.addEventListener('playing', playingListener); 58 audioElement.addEventListener('playing', playingListener);
62 audioElement.src = findMediaFile("audio", "content/silence"); 59 audioElement.src = findMediaFile("audio", "content/silence");
63 } 60 }
64 61
65 consoleWrite("Starting a total of " + maxPlayers + " concurrent audio el ements."); 62 consoleWrite("Starting a total of " + maxPlayers + " concurrent audio el ements.");
66 for (var i = 0; i < maxPlayers; i++) 63 for (var i = 0; i < maxPlayers; i++)
67 document.write("<audio controls></audio>"); 64 document.write("<audio controls></audio>");
68 65
69 testAudioElement(0); 66 testAudioElement(0);
70 </script> 67 </script>
71 68
72 </body> 69 </body>
73 </html> 70 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/media/audio-concurrent-supported-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698