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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/panner-distance-clamping.html

Issue 2512793003: Throw RangeError for invalid refDistance/maxDistance (Closed)
Patch Set: Rebase Created 4 years 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 | « no previous file | third_party/WebKit/Source/modules/webaudio/PannerNode.h » ('j') | 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 <title>Test Clamping of Distance for PannerNode</title> 4 <title>Test Clamping of Distance for PannerNode</title>
5 <script src="../resources/testharness.js"></script> 5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script> 6 <script src="../resources/testharnessreport.js"></script>
7 <script src="resources/audio-testing.js"></script> 7 <script src="resources/audio-testing.js"></script>
8 </head> 8 </head>
9 9
10 <body> 10 <body>
11 <script> 11 <script>
12 // Arbitrary sample rate and render length. 12 // Arbitrary sample rate and render length.
13 var sampleRate = 48000; 13 var sampleRate = 48000;
14 var renderFrames = 128; 14 var renderFrames = 128;
15 15
16 var audit = Audit.createTaskRunner(); 16 var audit = Audit.createTaskRunner();
17 17
18 audit.defineTask("ref-distance-error", function (taskDone) {
19 testDistanceLimits({name: "refDistance"});
20 taskDone();
21 });
22
23 audit.defineTask("max-distance-error", function (taskDone) {
24 testDistanceLimits({name: "maxDistance"});
25 taskDone();
26 });
27
28 function testDistanceLimits(options) {
29 // Verify that exceptions are thrown for invalid values of refDistance.
30 var context = new OfflineAudioContext(1, renderFrames, sampleRate);
31
32 var attrName = options.name;
33 var prefix = "new PannerNode(c, {" + attrName + ": ";
34
35 success = Should(prefix + "-1})", function () {
36 var nodeOptions = {};
37 nodeOptions[attrName] = -1;
38 new PannerNode(context, nodeOptions);
39 }).throw("RangeError");
40
41 success = Should(prefix + "0})", function () {
42 var nodeOptions = {};
43 nodeOptions[attrName] = 0;
44 new PannerNode(context, nodeOptions);
45 }).throw("RangeError") && success;
46
47 // The smallest representable positive single float.
48 var leastPositiveDoubleFloat = 4.9406564584124654e-324;
49
50 success = Should(prefix + leastPositiveDoubleFloat + "})",
51 function () {
52 var nodeOptions = {};
53 nodeOptions[attrName] = leastPositiveDoubleFloat;
54 new PannerNode(context, nodeOptions);
55 }).notThrow() && success;
56
57 prefix = "panner." + attrName + " = ";
58 panner = new PannerNode(context);
59 success = Should(prefix + "-1", function () {
60 panner[attrName] = -1;
61 }).throw("RangeError") && success;
62
63 success = Should(prefix + "0", function () {
64 panner[attrName] = 0;
65 }).throw("RangeError") && success;
66
67 success = Should(prefix + leastPositiveDoubleFloat, function () {
68 panner[attrName] = leastPositiveDoubleFloat;
69 }).notThrow() && success;
70
71 Should("Invalid " + attrName + " values handled", success)
72 .summarize("correctly", "incorrectly");
73
74 }
75
18 audit.defineTask("min-distance", function (taskDone) { 76 audit.defineTask("min-distance", function (taskDone) {
19 // Test clamping of panner distance to refDistance for all of the 77 // Test clamping of panner distance to refDistance for all of the
20 // distance models. The actual distance is arbitrary as long as it's 78 // distance models. The actual distance is arbitrary as long as it's
21 // less than refDistance. We test default and non-default values for 79 // less than refDistance. We test default and non-default values for
22 // the panner's refDistance and maxDistance. 80 // the panner's refDistance and maxDistance.
23 // correctly. 81 // correctly.
24 Promise.all([ 82 Promise.all([
25 runTest({ 83 runTest({
26 distance: 0.01, 84 distance: 0.01,
27 distanceModel: "linear", 85 distanceModel: "linear",
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 .beEqualTo(true); 203 .beEqualTo(true);
146 Should("Test panner output " + JSON.stringify(options), actual) 204 Should("Test panner output " + JSON.stringify(options), actual)
147 .beEqualToArray(expected); 205 .beEqualToArray(expected);
148 }); 206 });
149 } 207 }
150 208
151 audit.runTasks(); 209 audit.runTasks();
152 </script> 210 </script>
153 </body> 211 </body>
154 </html> 212 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/PannerNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698