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

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

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (Closed)
Patch Set: Created 3 years, 7 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>
5 Test Onended Event Listener
6 </title>
5 <script src="../../resources/testharness.js"></script> 7 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 8 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 9 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 10 <script src="../resources/audit.js"></script>
9 </head> 11 </head>
12 <body>
13 <script id="layout-test-code">
14 let sampleRate = 44100;
15 let renderLengthSeconds = 1;
16 let renderLengthFrames = renderLengthSeconds * sampleRate;
10 17
11 <body> 18 // Length of the source buffer. Anything less than the render length is
12 <script> 19 // fine.
20 let sourceBufferLengthFrames = renderLengthFrames / 8;
21 // When to stop the oscillator. Anything less than the render time is
22 // fine.
23 let stopTime = renderLengthSeconds / 8;
13 24
14 var sampleRate = 44100; 25 let audit = Audit.createTaskRunner();
15 var renderLengthSeconds = 1;
16 var renderLengthFrames = renderLengthSeconds * sampleRate;
17 26
18 // Length of the source buffer. Anything less than the render length is f ine. 27 audit.define('absn-set-onended', (task, should) => {
19 var sourceBufferLengthFrames = renderLengthFrames / 8; 28 // Test that the onended event for an AudioBufferSourceNode is fired
20 // When to stop the oscillator. Anything less than the render time is fin e. 29 // when it is set directly.
21 var stopTime = renderLengthSeconds / 8; 30 let context =
22 31 new OfflineAudioContext(1, renderLengthFrames, sampleRate);
23 var audit = Audit.createTaskRunner(); 32 let buffer = context.createBuffer(
24 33 1, sourceBufferLengthFrames, context.sampleRate);
25 audit.define("absn-set-onended", (task, should) => { 34 let source = context.createBufferSource();
26 // Test that the onended event for an AudioBufferSourceNode is fired whe n it is set
27 // directly.
28 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ;
29 var buffer = context.createBuffer(1, sourceBufferLengthFrames, context.s ampleRate);
30 var source = context.createBufferSource();
31 source.buffer = buffer; 35 source.buffer = buffer;
32 source.connect(context.destination); 36 source.connect(context.destination);
33 source.onended = function (e) { 37 source.onended = function(e) {
34 should(true, "AudioBufferSource.onended called when ended set directly ") 38 should(
35 .beEqualTo(true); 39 true, 'AudioBufferSource.onended called when ended set directly')
40 .beEqualTo(true);
36 }; 41 };
37 source.start(); 42 source.start();
38 context.startRendering().then(() => task.done()); 43 context.startRendering().then(() => task.done());
39 }); 44 });
40 45
41 audit.define("absn-add-listener", (task, should) => { 46 audit.define('absn-add-listener', (task, should) => {
42 // Test that the onended event for an AudioBufferSourceNode is fired whe n 47 // Test that the onended event for an AudioBufferSourceNode is fired
43 // addEventListener is used to set the handler. 48 // when addEventListener is used to set the handler.
44 var context = new OfflineAudioContext(1, renderLengthFrames, 49 let context =
45 sampleRate); 50 new OfflineAudioContext(1, renderLengthFrames, sampleRate);
46 var buffer = context.createBuffer(1, sourceBufferLengthFrames, 51 let buffer = context.createBuffer(
47 context.sampleRate); 52 1, sourceBufferLengthFrames, context.sampleRate);
48 var source = context.createBufferSource(); 53 let source = context.createBufferSource();
49 source.buffer = buffer; 54 source.buffer = buffer;
50 source.connect(context.destination); 55 source.connect(context.destination);
51 source.addEventListener("ended", function (e) { 56 source.addEventListener('ended', function(e) {
52 should(true, 57 should(
53 "AudioBufferSource.onended called when using addEventListener" 58 true,
54 ) 59 'AudioBufferSource.onended called when using addEventListener')
55 .beEqualTo(true); 60 .beEqualTo(true);
56 }); 61 });
57 source.start(); 62 source.start();
58 context.startRendering().then(() => task.done()); 63 context.startRendering().then(() => task.done());
59 }); 64 });
60 65
61 audit.define("osc-set-onended", (task, should) => { 66 audit.define('osc-set-onended', (task, should) => {
62 // Test that the onended event for an OscillatorNode is fired when it is set 67 // Test that the onended event for an OscillatorNode is fired when it is
63 // directly. 68 // set directly.
64 var context = new OfflineAudioContext(1, renderLengthFrames, sampleRate) ; 69 let context =
65 var source = context.createOscillator(); 70 new OfflineAudioContext(1, renderLengthFrames, sampleRate);
71 let source = context.createOscillator();
66 source.connect(context.destination); 72 source.connect(context.destination);
67 source.onended = function (e) { 73 source.onended = function(e) {
68 should(true, "Oscillator.onended called when ended set directly") 74 should(true, 'Oscillator.onended called when ended set directly')
69 .beEqualTo(true); 75 .beEqualTo(true);
70 }; 76 };
71 source.start(); 77 source.start();
72 source.stop(stopTime); 78 source.stop(stopTime);
73 context.startRendering().then(() => task.done()); 79 context.startRendering().then(() => task.done());
74 }); 80 });
75 81
76 audit.define("osc-add-listener", (task, should) => { 82 audit.define('osc-add-listener', (task, should) => {
77 // Test that the onended event for an OscillatorNode is fired when 83 // Test that the onended event for an OscillatorNode is fired when
78 // addEventListener is used to set the handler. 84 // addEventListener is used to set the handler.
79 var context = new OfflineAudioContext(1, renderLengthFrames, 85 let context =
80 sampleRate); 86 new OfflineAudioContext(1, renderLengthFrames, sampleRate);
81 var source = context.createOscillator(); 87 let source = context.createOscillator();
82 source.connect(context.destination); 88 source.connect(context.destination);
83 source.addEventListener("ended", function (e) { 89 source.addEventListener('ended', function(e) {
84 should(true, 90 should(true, 'Oscillator.onended called when using addEventListener')
85 "Oscillator.onended called when using addEventListener") 91 .beEqualTo(true);
86 .beEqualTo(true);
87 }); 92 });
88 source.start(); 93 source.start();
89 source.stop(stopTime); 94 source.stop(stopTime);
90 context.startRendering().then(() => task.done()); 95 context.startRendering().then(() => task.done());
91 }); 96 });
92 97
93 audit.run(); 98 audit.run();
94 </script> 99 </script>
95 </body> 100 </body>
96 </html> 101 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698