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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-exceptional-values.html

Issue 2651253004: Convert non-Audit AudioParam tests to testharness (Closed)
Patch Set: Reindent Created 3 years, 10 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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audit.js"></script>
5 </head> 8 </head>
6 9
7 <body> 10 <body>
8 <script> 11 <script>
9 description("Test exceptional arguments for AudioParam timeline events"); 12 let audit = Audit.createTaskRunner();
10 13
11 var context; 14 // For these values, AudioParam methods should throw an error because they
12 var gain; 15 // are invalid; only
16 // finite values are allowed.
17 let targetValues = [Infinity, -Infinity, NaN];
13 18
14 // For these values, AudioParam methods should throw an error because they are invalid; only 19 // For these time values, AudioParam methods should throw an error because
15 // finite values are allowed. 20 // they are
16 var targetValues = [Infinity, -Infinity, NaN]; 21 // invalid. Only finite non-negative values are allowed for any time or
22 // time-like parameter.
23 let timeValues = [-1, Infinity, -Infinity, NaN];
17 24
18 // For these time values, AudioParam methods should throw an error because they are 25 // For these duration values, AudioParam methods should throw an error
19 // invalid. Only finite non-negative values are allowed for any time or ti me-like parameter. 26 // because they are
20 var timeValues = [-1, Infinity, -Infinity, NaN]; 27 // invalid. Only finite values are allowed for any duration parameter.
28 let durationValues = [-1, Infinity, -Infinity, NaN, 0];
21 29
22 // For these duration values, AudioParam methods should throw an error bec ause they are 30 // For these timeConstant values for setTargetAtTime an error must be
23 // invalid. Only finite values are allowed for any duration parameter. 31 // thrown because they are
24 var durationValues = [-1, Infinity, -Infinity, NaN, 0]; 32 // invalid.
33 let timeConstantValues = [-1, Infinity, -Infinity, NaN];
25 34
26 // For these timeConstant values for setTargetAtTime an error must be thro wn because they are 35 // Just an array for use by setValueCurveAtTime. The length and contents
27 // invalid. 36 // of the array are not
28 var timeConstantValues = [-1, Infinity, -Infinity, NaN]; 37 // important.
38 let curve = new Float32Array(10);
29 39
30 // Just an array for use by setValueCurveAtTime. The length and contents o f the array are not 40 audit.define('test', function(task, should) {
31 // important. 41 task.describe(
32 var curve = new Float32Array(10); 42 'Test exceptional arguments for AudioParam timeline events');
33 43 let context = new AudioContext();
34 function runTest() { 44 let gain = context.createGain();
35 if (window.testRunner) {
36 testRunner.dumpAsText();
37 testRunner.waitUntilDone();
38 }
39 window.jsTestIsAsync = true;
40
41 context = new AudioContext();
42 gain = context.createGain();
43 45
44 // Test the value parameter 46 // Test the value parameter
45 for (value of targetValues) { 47 for (value of targetValues) {
46 shouldThrow("gain.gain.setValueAtTime(" + value + ", 1)"); 48 let testMethods = [
47 shouldThrow("gain.gain.linearRampToValueAtTime(" + value + ", 1)"); 49 {name: 'setValueAtTime', arg: [value, 1]},
48 shouldThrow("gain.gain.exponentialRampToValueAtTime(" + value + ", 1)" ); 50 {name: 'linearRampToValueAtTime', arg: [value, 1]},
49 shouldThrow("gain.gain.setTargetAtTime(" + value + ", 1, 1)"); 51 {name: 'exponentialRampToValueAtTime', arg: [value, 1]},
52 {name: 'setTargetAtTime', arg: [value, 1, 1]}
53 ];
54
55 for (method of testMethods) {
56 let message = 'gain.gain.' + method.name + '(' + method.arg + ')';
57 should(
58 () => gain.gain[method.name].apply(gain.gain, method.arg),
59 message)
60 .throw();
61 }
50 } 62 }
51 63
52 // Test the time parameter 64 // Test the time parameter
53 for (startTime of timeValues) { 65 for (startTime of timeValues) {
54 shouldThrow("gain.gain.setValueAtTime(1, " + startTime + ")"); 66 let testMethods = [
55 shouldThrow("gain.gain.linearRampToValueAtTime(1, " + startTime + ")") ; 67 {name: 'setValueAtTime', arg: [1, startTime]},
56 shouldThrow("gain.gain.exponentialRampToValueAtTime(1, " + startTime + ")"); 68 {name: 'linearRampToValueAtTime', arg: [1, startTime]},
57 shouldThrow("gain.gain.setTargetAtTime(1, " + startTime + ", 1)"); 69 {name: 'exponentialRampToValueAtTime', arg: [1, startTime]},
70 {name: 'setTargetAtTime', arg: [1, startTime, 1]}
71 ];
72
73 for (method of testMethods) {
74 let message = 'gain.gain.' + method.name + '(' + method.arg + ')';
75 should(
76 () => gain.gain[method.name].apply(gain.gain, method.arg),
77 message)
78 .throw();
79 }
58 } 80 }
59 81
60 // Test time constant 82 // Test time constant
61 for (value of timeConstantValues) { 83 for (value of timeConstantValues) {
62 shouldThrow("gain.gain.setTargetAtTime(1, 1, " + value + ")"); 84 should(
85 () => gain.gain.setTargetAtTime(1, 1, value),
86 'gain.gain.setTargetAtTime(1, 1, ' + value + ')')
87 .throw();
63 } 88 }
64 89
65 // Test startTime and duration for setValueCurveAtTime 90 // Test startTime and duration for setValueCurveAtTime
66 for (startTime of timeValues) { 91 for (startTime of timeValues) {
67 shouldThrow("gain.gain.setValueCurveAtTime(curve, " + startTime + ", 1 )"); 92 should(
93 () => gain.gain.setValueCurveAtTime(curve, startTime, 1),
94 'gain.gain.setValueCurveAtTime(curve, ' + startTime + ', 1)')
95 .throw();
68 } 96 }
69 for (duration of durationValues) { 97 for (duration of durationValues) {
70 shouldThrow("gain.gain.setValueCurveAtTime(curve, 1, " + duration + ") "); 98 should(
99 () => gain.gain.setValueCurveAtTime(curve, 1, duration),
100 'gain.gain.setValueCurveAtTime(curve, 1, ' + duration + ')')
101 .throw();
71 } 102 }
72 103
73 finishJSTest(); 104 task.done();
74 } 105 });
75 106
76 runTest(); 107 audit.run();
77 successfullyParsed = true;
78 </script> 108 </script>
79 </body> 109 </body>
80 </html> 110 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698