|
6 | 6 | </title> |
7 | 7 | <script src="/resources/testharness.js"></script> |
8 | 8 | <script src="/resources/testharnessreport.js"></script> |
9 | | - <script src="/webaudio/resources/audit-util.js"></script> |
10 | | - <script src="/webaudio/resources/audit.js"></script> |
11 | 9 | <script src="/webaudio/resources/audionodeoptions.js"></script> |
12 | 10 | </head> |
13 | 11 | <body> |
14 | | - <script id="layout-test-code"> |
15 | | - let context; |
| 12 | + <script> |
| 13 | + const context = new AudioContext(); |
16 | 14 |
|
17 | | - let audit = Audit.createTaskRunner(); |
| 15 | + test(() => { |
| 16 | + testInvalidConstructor_W3CTH('GainNode', context); |
| 17 | + }, 'GainNode: invalid constructor'); |
18 | 18 |
|
19 | | - audit.define('initialize', (task, should) => { |
20 | | - context = initializeContext(should); |
21 | | - task.done(); |
22 | | - }); |
23 | | - |
24 | | - audit.define('invalid constructor', (task, should) => { |
25 | | - testInvalidConstructor(should, 'GainNode', context); |
26 | | - task.done(); |
27 | | - }); |
28 | | - |
29 | | - audit.define('default constructor', (task, should) => { |
30 | | - let prefix = 'node0'; |
31 | | - let node = testDefaultConstructor(should, 'GainNode', context, { |
32 | | - prefix: prefix, |
| 19 | + test(() => { |
| 20 | + const prefix = 'node0'; |
| 21 | + const node = testDefaultConstructor_W3CTH('GainNode', context, { |
| 22 | + prefix, |
33 | 23 | numberOfInputs: 1, |
34 | 24 | numberOfOutputs: 1, |
35 | 25 | channelCount: 2, |
36 | 26 | channelCountMode: 'max', |
37 | 27 | channelInterpretation: 'speakers' |
38 | 28 | }); |
39 | 29 |
|
40 | | - testDefaultAttributes(should, node, prefix, [{name: 'gain', value: 1}]); |
41 | | - |
42 | | - task.done(); |
43 | | - }); |
44 | | - |
45 | | - audit.define('test AudioNodeOptions', (task, should) => { |
46 | | - testAudioNodeOptions(should, context, 'GainNode'); |
47 | | - task.done(); |
48 | | - }); |
49 | | - |
50 | | - audit.define('constructor with options', (task, should) => { |
51 | | - let node; |
52 | | - let options = { |
53 | | - gain: -2, |
54 | | - }; |
55 | | - |
56 | | - should( |
57 | | - () => { |
58 | | - node = new GainNode(context, options); |
59 | | - }, |
60 | | - 'node1 = new GainNode(c, ' + JSON.stringify(options) + ')') |
61 | | - .notThrow(); |
62 | | - should(node instanceof GainNode, 'node1 instanceof GainNode') |
63 | | - .beEqualTo(true); |
64 | | - |
65 | | - should(node.gain.value, 'node1.gain.value').beEqualTo(options.gain); |
66 | | - |
67 | | - should(node.channelCount, 'node1.channelCount').beEqualTo(2); |
68 | | - should(node.channelCountMode, 'node1.channelCountMode') |
69 | | - .beEqualTo('max'); |
70 | | - should(node.channelInterpretation, 'node1.channelInterpretation') |
71 | | - .beEqualTo('speakers'); |
72 | | - |
73 | | - task.done(); |
74 | | - }); |
75 | | - |
76 | | - audit.run(); |
| 30 | + testDefaultAttributes_W3CTH( |
| 31 | + node, |
| 32 | + prefix, |
| 33 | + [{ name: 'gain', value: 1 }]); |
| 34 | + }, 'GainNode: default constructor and default attributes'); |
| 35 | + |
| 36 | + test(() => { |
| 37 | + testAudioNodeOptions_W3CTH(context, 'GainNode'); |
| 38 | + }, 'GainNode: AudioNodeOptions are applied'); |
| 39 | + |
| 40 | + test(() => { |
| 41 | + const options = { gain: -2 }; |
| 42 | + const node = new GainNode(context, options); |
| 43 | + assert_true(node instanceof GainNode, 'instanceof GainNode'); |
| 44 | + assert_equals(node.gain.value, options.gain, 'node.gain.value'); |
| 45 | + assert_equals(node.channelCount, 2, 'node.channelCount'); |
| 46 | + assert_equals(node.channelCountMode, 'max', 'node.channelCountMode'); |
| 47 | + assert_equals( |
| 48 | + node.channelInterpretation, |
| 49 | + 'speakers', |
| 50 | + 'node.channelInterpretation'); |
| 51 | + }, 'GainNode: constructor with options'); |
77 | 52 | </script> |
78 | 53 | </body> |
79 | 54 | </html> |
0 commit comments