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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-suspend-resume-basic.html

Issue 2865773002: Convert OfflineAudioContext to us new Audit (Closed)
Patch Set: clang-format 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
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-promise-basic.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/testharness.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script> 5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 6 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 7 <script src="../resources/audit.js"></script>
8 </head> 8 </head>
9 9
10 <body> 10 <body>
11 <script> 11 <script>
12 var sampleRate = 44100; 12 var sampleRate = 44100;
13 var renderDuration = 1; 13 var renderDuration = 1;
14 var renderQuantum = 128; 14 var renderQuantum = 128;
15 15
16 var audit = Audit.createTaskRunner(); 16 var audit = Audit.createTaskRunner();
17 17
18 // Task: Calling suspend with no argument, negative time or the time 18 // Task: Calling suspend with no argument, negative time or the time
19 // beyond the maximum render duration reject the promise. 19 // beyond the maximum render duration reject the promise.
20 audit.defineTask('suspend-invalid-argument', function (done) { 20 audit.define('suspend-invalid-argument', (task, should) => {
21 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); 21 var context =
22 new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
22 23
23 Should('context.suspend()', context.suspend()).beRejected(); 24 should(context.suspend(), 'context.suspend()').beRejected();
24 Should('context.suspend(-1.0)', context.suspend(-1.0)).beRejected(); 25 should(context.suspend(-1.0), 'context.suspend(-1.0)').beRejected();
25 Should('context.suspend(2.0)', context.suspend(2.0)).beRejected(); 26 should(context.suspend(2.0), 'context.suspend(2.0)').beRejected();
26 27
27 context.startRendering().then(done); 28 context.startRendering().then(() => task.done());
28 }); 29 });
29 30
30 // Task: Scheduling a suspend in the past should be rejected. 31 // Task: Scheduling a suspend in the past should be rejected.
31 audit.defineTask('suspend-in-the-past', function (done) { 32 audit.define('suspend-in-the-past', (task, should) => {
32 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); 33 var context =
34 new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
33 35
34 context.suspend(0.5).then(function () { 36 context.suspend(0.5).then(function() {
37 should(
38 context.suspend(context.currentTime - 0.1),
39 'Scheduling a suspend in the past')
40 .beRejected();
35 41
36 Should('Scheduling a suspend in the past', 42 should(context
37 context.suspend(context.currentTime - 0.1)).beRejected(); 43 .suspend(
38 44 context.currentTime + 0.1,
39 Should('Scheduling a suspend in the future', 45 'Scheduling a suspend in the future')
40 context.suspend(context.currentTime + 0.1).then(function () { 46 .then(function() {
41 context.resume(); 47 context.resume();
42 })).beResolved(); 48 }))
49 .beResolved();
43 50
44 context.resume(); 51 context.resume();
45 }); 52 });
46 53
47 context.startRendering().then(done); 54 context.startRendering().then(() => task.done());
48 }); 55 });
49 56
50 // Task: suspending after rendering is finished must be rejected with the 57 // Task: suspending after rendering is finished must be rejected with the
51 // properly clamped frame/time information. 58 // properly clamped frame/time information.
52 audit.defineTask('suspend-after-render-completion', function (done) { 59 audit.define('suspend-after-render-completion', (task, should) => {
53 var context = new OfflineAudioContext( 60 var context =
54 1, sampleRate * renderDuration, sampleRate); 61 new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
55 context.startRendering().then(function () { 62 context.startRendering()
56 Should('Scheduling a suspend after the render completion', 63 .then(function() {
57 context.suspend(renderDuration)).beRejected(); 64 should(
58 }).then(done); 65 context.suspend(renderDuration),
66 'Scheduling a suspend after the render completion')
67 .beRejected();
68 })
69 .then(() => task.done());
59 }); 70 });
60 71
61 // Task: Calling multiple suspends at the same rendering quantum should 72 // Task: Calling multiple suspends at the same rendering quantum should
62 // reject the promise. 73 // reject the promise.
63 audit.defineTask('identical-suspend-time', function(done) { 74 audit.define('identical-suspend-time', (task, should) => {
64 var context = 75 var context =
65 new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); 76 new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
66 77
67 // |suspendTime1| and |suspendTime2| are identical when quantized to 78 // |suspendTime1| and |suspendTime2| are identical when quantized to
68 // the render quantum size. 79 // the render quantum size.
69 var suspendTime1 = renderQuantum / sampleRate; 80 var suspendTime1 = renderQuantum / sampleRate;
70 var suspendTime2 = 1.5 * renderQuantum / sampleRate; 81 var suspendTime2 = 1.5 * renderQuantum / sampleRate;
71 82
72 Should( 83 should(
73 'Scheduling a suspend at frame ' + suspendTime1 * sampleRate, 84 () => context.suspend(suspendTime1).then(() => context.resume()),
74 () => context.suspend(suspendTime1).then(() => context.resume())) 85 'Scheduling a suspend at frame ' + suspendTime1 * sampleRate)
75 .notThrow(); 86 .notThrow();
76 87
77 Should( 88 should(
78 'Scheduling another suspend at the same rendering quantum', 89 context.suspend(suspendTime2),
79 context.suspend(suspendTime2)) 90 'Scheduling another suspend at the same rendering quantum')
80 .beRejected(); 91 .beRejected();
81 92
82 context.startRendering().then(done); 93 context.startRendering().then(() => task.done());
83 }); 94 });
84 95
85 // Task: Resuming a running context should be resolved. 96 // Task: Resuming a running context should be resolved.
86 audit.defineTask('resume-before-suspend', function (done) { 97 audit.define('resume-before-suspend', (task, should) => {
87 98
88 // Make the render length 5 times longer to minimize the flakiness. 99 // Make the render length 5 times longer to minimize the flakiness.
89 var longRenderDuration = renderDuration * 5; 100 var longRenderDuration = renderDuration * 5;
90 var context = new OfflineAudioContext(1, sampleRate * longRenderDuration , sampleRate); 101 var context = new OfflineAudioContext(
102 1, sampleRate * longRenderDuration, sampleRate);
91 103
92 // Create dummy audio graph to slow the rendering. 104 // Create dummy audio graph to slow the rendering.
93 var osc = context.createOscillator(); 105 var osc = context.createOscillator();
94 var lpf = context.createBiquadFilter(); 106 var lpf = context.createBiquadFilter();
95 osc.type = 'sawtooth'; 107 osc.type = 'sawtooth';
96 osc.frequency.setValueAtTime(0.1, 0.0); 108 osc.frequency.setValueAtTime(0.1, 0.0);
97 osc.frequency.linearRampToValueAtTime(1000, longRenderDuration * 0.5); 109 osc.frequency.linearRampToValueAtTime(1000, longRenderDuration * 0.5);
98 osc.frequency.linearRampToValueAtTime(0.1, longRenderDuration); 110 osc.frequency.linearRampToValueAtTime(0.1, longRenderDuration);
99 lpf.frequency.setValueAtTime(0.1, 0.0); 111 lpf.frequency.setValueAtTime(0.1, 0.0);
100 lpf.frequency.linearRampToValueAtTime(1000, longRenderDuration * 0.5); 112 lpf.frequency.linearRampToValueAtTime(1000, longRenderDuration * 0.5);
101 lpf.frequency.linearRampToValueAtTime(0.1, longRenderDuration); 113 lpf.frequency.linearRampToValueAtTime(0.1, longRenderDuration);
102 osc.connect(lpf); 114 osc.connect(lpf);
103 lpf.connect(context.destination); 115 lpf.connect(context.destination);
104 osc.start(); 116 osc.start();
105 117
106 // A suspend is scheduled at the 90% of the render duration. 118 // A suspend is scheduled at the 90% of the render duration.
107 Should( 119 should(
108 'Scheduling a suspend at ' + longRenderDuration * 0.9 + ' seconds',
109 () => { 120 () => {
110 // Test is finished when this suspend resolves. 121 // Test is finished when this suspend resolves.
111 context.suspend(longRenderDuration * 0.9).then(done); 122 context.suspend(longRenderDuration * 0.9).then(() => task.done());
112 }) 123 },
124 'Scheduling a suspend at ' + longRenderDuration * 0.9 + ' seconds')
113 .notThrow(); 125 .notThrow();
114 126
115 // We have to start rendering to get the time running. 127 // We have to start rendering to get the time running.
116 context.startRendering(); 128 context.startRendering();
117 129
118 // Then call resume() immediately after the rendering starts. Resuming 130 // Then call resume() immediately after the rendering starts. Resuming
119 // a context that is already running should be resolved. 131 // a context that is already running should be resolved.
120 Should('Resuming a running context', context.resume()) 132 should(context.resume(), 'Resuming a running context').beResolved();
121 .beResolved();
122 }); 133 });
123 134
124 // Task: Calling resume on a context that is not started should reject the promise. 135 // Task: Calling resume on a context that is not started should reject the
125 audit.defineTask('resume-without-suspend', function (done) { 136 // promise.
126 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); 137 audit.define('resume-without-suspend', (task, should) => {
138 var context =
139 new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
127 140
128 Should('Resuming a context without starting it', context.resume()) 141 should(context.resume(), 'Resuming a context without starting it')
129 .beRejected().then(done); 142 .beRejected()
143 .then(() => task.done());
130 }); 144 });
131 145
132 audit.runTasks(); 146 audit.run();
133 </script> 147 </script>
134 148
135 </body> 149 </body>
136 </html> 150 </html>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-promise-basic.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698