Skip to content

Commit 7be91b0

Browse files
[webaudio-testharness] Migrate ctor-gain.html
Convert ctor-gain.html from the legacy audit.js runner to pure testharness.js Change-Id: I6028b45cf4d8bd83c7cfdab11862c675226de4ef Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7093496 Commit-Queue: Punith Nayak <[email protected]> Reviewed-by: Hongchan Choi <[email protected]> Reviewed-by: Michael Wilson <[email protected]> Cr-Commit-Position: refs/heads/main@{#1539486}
1 parent c9ccd50 commit 7be91b0

File tree

1 file changed

+31
-56
lines changed

1 file changed

+31
-56
lines changed

webaudio/the-audio-api/the-gainnode-interface/ctor-gain.html

Lines changed: 31 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,49 @@
66
</title>
77
<script src="/resources/testharness.js"></script>
88
<script src="/resources/testharnessreport.js"></script>
9-
<script src="/webaudio/resources/audit-util.js"></script>
10-
<script src="/webaudio/resources/audit.js"></script>
119
<script src="/webaudio/resources/audionodeoptions.js"></script>
1210
</head>
1311
<body>
14-
<script id="layout-test-code">
15-
let context;
12+
<script>
13+
const context = new AudioContext();
1614

17-
let audit = Audit.createTaskRunner();
15+
test(() => {
16+
testInvalidConstructor_W3CTH('GainNode', context);
17+
}, 'GainNode: invalid constructor');
1818

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,
3323
numberOfInputs: 1,
3424
numberOfOutputs: 1,
3525
channelCount: 2,
3626
channelCountMode: 'max',
3727
channelInterpretation: 'speakers'
3828
});
3929

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');
7752
</script>
7853
</body>
7954
</html>

0 commit comments

Comments
 (0)