| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Basic ConstantSourceNode Tests</title> | 4 <title>Basic ConstantSourceNode Tests</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/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 8 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audio-testing.js"></script> |
| 9 </head> | 9 </head> |
| 10 | 10 |
| 11 <body> | 11 <body> |
| 12 <script> | 12 <script> |
| 13 var context = new AudioContext(); | 13 var context = new AudioContext(); |
| 14 | 14 |
| 15 var audit = Audit.createTaskRunner(); | 15 var audit = Audit.createTaskRunner(); |
| 16 | 16 |
| 17 audit.defineTask("createConstantSource()", function (taskDone) { | 17 audit.defineTask("createConstantSource()", function (taskDone) { |
| 18 var node; | 18 var node; |
| 19 var success = true; | 19 var success = true; |
| 20 var prefix = "Factory method: "; |
| 20 | 21 |
| 21 success = Should("node = context.createConstantSource()", function () { | 22 success = Should(prefix + "node = context.createConstantSource()", funct
ion () { |
| 22 node = context.createConstantSource(); | 23 node = context.createConstantSource(); |
| 23 }).notThrow(); | 24 }).notThrow(); |
| 24 success = Should("node instance of ConstantSourceNode", | 25 success = Should(prefix + "node instance of ConstantSourceNode", |
| 25 node instanceof ConstantSourceNode) | 26 node instanceof ConstantSourceNode) |
| 26 .beEqualTo(true) && success; | 27 .beEqualTo(true) && success; |
| 27 | 28 |
| 28 success = verifyNodeDefaults(node) && success; | 29 success = verifyNodeDefaults(node, prefix) && success; |
| 29 | 30 |
| 30 Should("createConstantSource()", success) | 31 Should("createConstantSource()", success) |
| 31 .summarize( | 32 .summarize( |
| 32 "correctly created", | 33 "correctly created", |
| 33 "incorrectly created"); | 34 "incorrectly created"); |
| 34 | 35 |
| 35 taskDone(); | 36 taskDone(); |
| 36 }); | 37 }); |
| 37 | 38 |
| 38 audit.defineTask("new ConstantSourceNode()", function (taskDone) { | 39 audit.defineTask("new ConstantSourceNode()", function (taskDone) { |
| 39 var node; | 40 var node; |
| 40 var success = true; | 41 var success = true; |
| 42 var prefix = "Constructor: "; |
| 41 | 43 |
| 42 success = Should("node = new ConstantSourceNode()", function () { | 44 success = Should(prefix + "node = new ConstantSourceNode()", function ()
{ |
| 43 node = new ConstantSourceNode(context); | 45 node = new ConstantSourceNode(context); |
| 44 }).notThrow(); | 46 }).notThrow(); |
| 45 success = Should("node instance of ConstantSourceNode", | 47 success = Should(prefix + "node instance of ConstantSourceNode", |
| 46 node instanceof ConstantSourceNode) | 48 node instanceof ConstantSourceNode) |
| 47 .beEqualTo(true) && success; | 49 .beEqualTo(true) && success; |
| 48 | 50 |
| 49 | 51 |
| 50 success = verifyNodeDefaults(node) && success; | 52 success = verifyNodeDefaults(node, prefix) && success; |
| 51 | 53 |
| 52 Should("new ConstantSourceNode(context)", success) | 54 Should("new ConstantSourceNode(context)", success) |
| 53 .summarize( | 55 .summarize( |
| 54 "correctly created", | 56 "correctly created", |
| 55 "incorrectly created"); | 57 "incorrectly created"); |
| 56 | 58 |
| 57 taskDone(); | 59 taskDone(); |
| 58 }); | 60 }); |
| 59 | 61 |
| 60 function verifyNodeDefaults(node) { | 62 function verifyNodeDefaults(node, prefix) { |
| 61 var success = true; | 63 var success = true; |
| 62 | 64 |
| 63 success = Should("node.numberOfInputs", node.numberOfInputs) | 65 success = Should(prefix + "node.numberOfInputs", node.numberOfInputs) |
| 64 .beEqualTo(0); | 66 .beEqualTo(0); |
| 65 success = Should("node.numberOfOutputs", node.numberOfOutputs) | 67 success = Should(prefix + "node.numberOfOutputs", node.numberOfOutputs) |
| 66 .beEqualTo(1) && success; | 68 .beEqualTo(1) && success; |
| 67 success = Should("node.channelCount", node.channelCount) | 69 success = Should(prefix + "node.channelCount", node.channelCount) |
| 68 .beEqualTo(2) && success; | 70 .beEqualTo(2) && success; |
| 69 success = Should("node.channelCountMode", node.channelCountMode) | 71 success = Should(prefix + "node.channelCountMode", node.channelCountMode
) |
| 70 .beEqualTo("max") && success; | 72 .beEqualTo("max") && success; |
| 71 success = Should("node.channelInterpretation", node.channelInterpretatio
n) | 73 success = Should(prefix + "node.channelInterpretation", node.channelInte
rpretation) |
| 72 .beEqualTo("speakers") && success; | 74 .beEqualTo("speakers") && success; |
| 73 | 75 |
| 74 success = Should("node.offset.value", node.offset.value) | 76 success = Should(prefix + "node.offset.value", node.offset.value) |
| 75 .beEqualTo(1) && success; | 77 .beEqualTo(1) && success; |
| 76 success = Should("node.offset.defaultValue", node.offset.defaultValue) | 78 success = Should(prefix + "node.offset.defaultValue", node.offset.defaul
tValue) |
| 77 .beEqualTo(1) && success; | 79 .beEqualTo(1) && success; |
| 78 success = Should("node.offset.minValue", node.offset.minValue) | 80 success = Should(prefix + "node.offset.minValue", node.offset.minValue) |
| 79 .beEqualTo(Math.fround(-3.4028235e38)) && success; | 81 .beEqualTo(Math.fround(-3.4028235e38)) && success; |
| 80 success = Should("node.offset.maxValue", node.offset.maxValue) | 82 success = Should(prefix + "node.offset.maxValue", node.offset.maxValue) |
| 81 .beEqualTo(Math.fround(3.4028235e38)) && success; | 83 .beEqualTo(Math.fround(3.4028235e38)) && success; |
| 82 | 84 |
| 83 return success; | 85 return success; |
| 84 } | 86 } |
| 85 | 87 |
| 86 audit.runTasks(); | 88 audit.runTasks(); |
| 87 </script> | 89 </script> |
| 88 </body> | 90 </body> |
| 89 </html> | 91 </html> |
| OLD | NEW |