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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/constructor/gain.html

Issue 2830053003: Convert constructor/gain.html to use new Audit (Closed)
Patch Set: Rebase 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 | « no previous file | 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 <title>Test Constructor: Gain</title> 4 <title>Test Constructor: Gain</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/audit.js"></script>
9 <script src="audionodeoptions.js"></script> 9 <script src="new-audionodeoptions.js"></script>
10 </head> 10 </head>
11 11
12 <body> 12 <body>
13 <script> 13 <script>
14 var context; 14 var context;
15 15
16 var audit = Audit.createTaskRunner(); 16 var audit = Audit.createTaskRunner();
17 17
18 audit.defineTask("initialize", function (taskDone) { 18 audit.define('initialize', (task, should) => {
19 Should("context = new OfflineAudioContext(...)", function () { 19 context = initializeContext(should);
20 context = new OfflineAudioContext(1, 1, 48000); 20 task.done();
21 }).notThrow();
22 taskDone();
23 }); 21 });
24 22
25 audit.defineTask("invalid constructor", function (taskDone) { 23 audit.define('invalid constructor', (task, should) => {
26 var node; 24 testInvalidConstructor(should, 'GainNode', context);
27 var success = true; 25 task.done();
28
29 success = Should("new GainNode()", function () {
30 node = new GainNode();
31 }).throw("TypeError");
32 success = Should("new GainNode(1)", function () {
33 node = new GainNode(1);
34 }).throw("TypeError") && success;
35 success = Should("new GainNode(context, 42)", function () {
36 node = new GainNode(context, 42);
37 }).throw("TypeError") && success;
38
39 Should("Invalid constructors", success)
40 .summarize(
41 "correctly threw errors",
42 "did not throw errors in all cases");
43
44 taskDone();
45 }); 26 });
46 27
47 audit.defineTask("default constructor", function (taskDone) { 28 audit.define('default constructor', (task, should) => {
48 var node; 29 let prefix = 'node0';
49 var success = true; 30 let node = testDefaultConstructor(should, 'GainNode', context, {
31 prefix: prefix,
32 numberOfInputs: 1,
33 numberOfOutputs: 1,
34 channelCount: 2,
35 channelCountMode: 'max',
36 channelInterpretation: 'speakers'
37 });
50 38
51 success = Should("node0 = new GainNode(context)", function () { 39 testDefaultAttributes(should, node, prefix, [{name: 'gain', value: 1}]);
52 node = new GainNode(context);
53 }).notThrow();
54 success = Should("node0 instanceof GainNode",
55 node instanceof GainNode)
56 .beEqualTo(true) && success;
57 40
58 success = Should("node0.gain.value", node.gain.value) 41 task.done();
59 .beEqualTo(1) && success;
60
61 success = Should("node0.channelCount", node.channelCount)
62 .beEqualTo(2) && success;
63 success = Should("node0.channelCountMode", node.channelCountMode)
64 .beEqualTo("max") && success;
65 success = Should("node0.channelInterpretation", node.channelInterpretati on)
66 .beEqualTo("speakers") && success;
67
68 Should("new GainNode(context)", success)
69 .summarize(
70 "constructed node with correct attributes",
71 "did not construct correct node correctly")
72
73 taskDone();
74 }); 42 });
75 43
76 audit.defineTask("test AudioNodeOptions", function (taskDone) { 44 audit.define('test AudioNodeOptions', (task, should) => {
77 testAudioNodeOptions(context, "GainNode"); 45 testAudioNodeOptions(should, context, 'GainNode');
78 taskDone(); 46 task.done();
79 }); 47 });
80 48
81 audit.defineTask("constructor with options", function (taskDone) { 49 audit.define('constructor with options', (task, should) => {
82 var node; 50 var node;
83 var success = true;
84 var options = { 51 var options = {
85 gain: -2, 52 gain: -2,
86 }; 53 };
87 54
88 success = Should("node1 = new GainNode(c, " + JSON.stringify(options) + ")", function () { 55 should(
89 node = new GainNode(context, options); 56 () => {
90 }).notThrow(); 57 node = new GainNode(context, options);
91 success = Should("node1 instanceof GainNode", 58 },
92 node instanceof GainNode) 59 'node1 = new GainNode(c, ' + JSON.stringify(options) + ')')
93 .beEqualTo(true) && success; 60 .notThrow();
61 should(node instanceof GainNode, 'node1 instanceof GainNode')
62 .beEqualTo(true);
94 63
95 success = Should("node1.gain.value", node.gain.value) 64 should(node.gain.value, 'node1.gain.value').beEqualTo(options.gain);
96 .beEqualTo(options.gain) && success;
97 65
98 success = Should("node1.channelCount", node.channelCount) 66 should(node.channelCount, 'node1.channelCount').beEqualTo(2);
99 .beEqualTo(2) && success; 67 should(node.channelCountMode, 'node1.channelCountMode')
100 success = Should("node1.channelCountMode", node.channelCountMode) 68 .beEqualTo('max');
101 .beEqualTo("max") && success; 69 should(node.channelInterpretation, 'node1.channelInterpretation')
102 success = Should("node1.channelInterpretation", node.channelInterpretati on) 70 .beEqualTo('speakers');
103 .beEqualTo("speakers") && success;
104 71
105 Should("new GainNode() with options", success) 72 task.done();
106 .summarize(
107 "constructed with correct attributes",
108 "was not constructed correctly");
109
110 taskDone();
111 }); 73 });
112 74
113 audit.runTasks(); 75 audit.run();
114 </script> 76 </script>
115 </body> 77 </body>
116 </html> 78 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698