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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiosource-onended.html

Issue 2593043003: Convert AudioBufferSource tests using Audit to testharness (Closed)
Patch Set: Missed a couple testFailed calls. Created 3 years, 11 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
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Onended Event Listener</title> 4 <title>Test Onended Event Listener</title>
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audio-testing.js"></script>
8 </head> 9 </head>
9 10
10 <body> 11 <body>
11 <script> 12 <script>
12 description("Test onended event listener");
13 window.jsTestIsAsync = true;
14 13
15 var sampleRate = 44100; 14 var sampleRate = 44100;
16 var renderLengthSeconds = 1; 15 var renderLengthSeconds = 1;
17 var renderLengthFrames = renderLengthSeconds * sampleRate; 16 var renderLengthFrames = renderLengthSeconds * sampleRate;
18 17
19 // Length of the source buffer. Anything less than the render length is f ine. 18 // Length of the source buffer. Anything less than the render length is f ine.
20 var sourceBufferLengthFrames = renderLengthFrames / 8; 19 var sourceBufferLengthFrames = renderLengthFrames / 8;
21 // When to stop the oscillator. Anything less than the render time is fin e. 20 // When to stop the oscillator. Anything less than the render time is fin e.
22 var stopTime = renderLengthSeconds / 8; 21 var stopTime = renderLengthSeconds / 8;
23 22
24 var audit = Audit.createTaskRunner(); 23 var audit = Audit.createTaskRunner();
25 24
26 audit.defineTask("absn-set-onended", function (done) { 25 audit.defineTask("absn-set-onended", function (done) {
27 // Test that the onended event for an AudioBufferSourceNode is fired whe n it is set 26 // Test that the onended event for an AudioBufferSourceNode is fired whe n it is set
28 // directly. 27 // directly.
29 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ; 28 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ;
30 var buffer = context.createBuffer(1, sourceBufferLengthFrames, context.s ampleRate); 29 var buffer = context.createBuffer(1, sourceBufferLengthFrames, context.s ampleRate);
31 var source = context.createBufferSource(); 30 var source = context.createBufferSource();
32 source.buffer = buffer; 31 source.buffer = buffer;
33 source.connect(context.destination); 32 source.connect(context.destination);
34 source.onended = function (e) { 33 source.onended = function (e) {
35 testPassed("AudioBufferSource.onended called when ended set directly." ); 34 Should("AudioBufferSource.onended called when ended set directly", tru e)
35 .beEqualTo(true);
36 }; 36 };
37 source.start(); 37 source.start();
38 context.startRendering().then(done); 38 context.startRendering().then(done);
39 }); 39 });
40 40
41 audit.defineTask("absn-add-listener", function (done) { 41 audit.defineTask("absn-add-listener", function (done) {
42 // Test that the onended event for an AudioBufferSourceNode is fired whe n 42 // Test that the onended event for an AudioBufferSourceNode is fired whe n
43 // addEventListener is used to set the handler. 43 // addEventListener is used to set the handler.
44 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ; 44 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ;
45 var buffer = context.createBuffer(1, sourceBufferLengthFrames, context.s ampleRate); 45 var buffer = context.createBuffer(1, sourceBufferLengthFrames, context.s ampleRate);
46 var source = context.createBufferSource(); 46 var source = context.createBufferSource();
47 source.buffer = buffer; 47 source.buffer = buffer;
48 source.connect(context.destination); 48 source.connect(context.destination);
49 source.addEventListener("ended", function (e) { 49 source.addEventListener("ended", function (e) {
50 testPassed("AudioBufferSource.onended called when using addEventListen er."); 50 Should("AudioBufferSource.onended called when using addEventListener",
51 true).beEqualTo(true);
51 }); 52 });
52 source.start(); 53 source.start();
53 context.startRendering().then(done); 54 context.startRendering().then(done);
54 }); 55 });
55 56
56 audit.defineTask("osc-set-onended", function (done) { 57 audit.defineTask("osc-set-onended", function (done) {
57 // Test that the onended event for an OscillatorNode is fired when it is set 58 // Test that the onended event for an OscillatorNode is fired when it is set
58 // directly. 59 // directly.
59 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ; 60 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ;
60 var source = context.createOscillator(); 61 var source = context.createOscillator();
61 source.connect(context.destination); 62 source.connect(context.destination);
62 source.onended = function (e) { 63 source.onended = function (e) {
63 testPassed("Oscillator.onended called when ended set directly."); 64 Should("Oscillator.onended called when ended set directly", true).beEq ualTo(true);
64 }; 65 };
65 source.start(); 66 source.start();
66 source.stop(stopTime); 67 source.stop(stopTime);
67 context.startRendering().then(done); 68 context.startRendering().then(done);
68 }); 69 });
69 70
70 audit.defineTask("osc-add-listener", function (done) { 71 audit.defineTask("osc-add-listener", function (done) {
71 // Test that the onended event for an OscillatorNode is fired when 72 // Test that the onended event for an OscillatorNode is fired when
72 // addEventListener is used to set the handler. 73 // addEventListener is used to set the handler.
73 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ; 74 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ;
74 var source = context.createOscillator(); 75 var source = context.createOscillator();
75 source.connect(context.destination); 76 source.connect(context.destination);
76 source.addEventListener("ended", function (e) { 77 source.addEventListener("ended", function (e) {
77 testPassed("Oscillator.onended called when using addEventListener."); 78 Should("Oscillator.onended called when using addEventListener", true). beEqualTo(true);
78 }); 79 });
79 source.start(); 80 source.start();
80 source.stop(stopTime); 81 source.stop(stopTime);
81 context.startRendering().then(done); 82 context.startRendering().then(done);
82 }); 83 });
83 84
84 audit.defineTask("finish", function (done) { 85 audit.defineTask("finish", function (done) {
85 finishJSTest();
86 done(); 86 done();
87 }); 87 });
88 88
89 audit.runTasks(); 89 audit.runTasks();
90 succesfullyParsed = true; 90 succesfullyParsed = true;
91 </script> 91 </script>
92 </body> 92 </body>
93 </html> 93 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698