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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/constructor/new-audionodeoptions.js

Issue 2828933003: Convert constructor/channelmerger.html to use new Audit (Closed)
Patch Set: Address review comments Created 3 years, 8 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 | « third_party/WebKit/LayoutTests/webaudio/constructor/channelmerger.html ('k') | 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 // Test that constructor for the node with name |nodeName| handles the 1 // Test that constructor for the node with name |nodeName| handles the
2 // various possible values for channelCount, channelCountMode, and 2 // various possible values for channelCount, channelCountMode, and
3 // channelInterpretation. 3 // channelInterpretation.
4 4
5 // The |should| parameter is the test function from new |Audit|. 5 // The |should| parameter is the test function from new |Audit|.
6 function testAudioNodeOptions(should, context, nodeName, expectedNodeOptions) { 6 function testAudioNodeOptions(should, context, nodeName, expectedNodeOptions) {
7 if (expectedNodeOptions === undefined) 7 if (expectedNodeOptions === undefined)
8 expectedNodeOptions = {}; 8 expectedNodeOptions = {};
9 let node; 9 let node;
10 10
11 // Test that we can set channelCount and that errors are thrown for 11 // Test that we can set channelCount and that errors are thrown for
12 // invalid values 12 // invalid values
13 let testChannelCount = 17; 13 let testChannelCount = 17;
14 if (expectedNodeOptions.ChannelCount) { 14 if (expectedNodeOptions.channelCount) {
15 testChannelCount = expectedNodeOptions.ChannelCount.value; 15 testChannelCount = expectedNodeOptions.channelCount.value;
16 } 16 }
17 should( 17 should(
18 () => { 18 () => {
19 node = new window[nodeName]( 19 node = new window[nodeName](
20 context, Object.assign({}, expectedNodeOptions.additionalOptions, { 20 context, Object.assign({}, expectedNodeOptions.additionalOptions, {
21 channelCount: testChannelCount 21 channelCount: testChannelCount
22 })); 22 }));
23 }, 23 },
24 'new ' + nodeName + '(c, {channelCount: ' + testChannelCount + '}}') 24 'new ' + nodeName + '(c, {channelCount: ' + testChannelCount + '}}')
25 .notThrow(); 25 .notThrow();
26 should(node.channelCount, 'node.channelCount').beEqualTo(testChannelCount); 26 should(node.channelCount, 'node.channelCount').beEqualTo(testChannelCount);
27 27
28 if (expectedNodeOptions.ChannelCount && 28 if (expectedNodeOptions.channelCount &&
29 expectedNodeOptions.ChannelCount.isFixed) { 29 expectedNodeOptions.channelCount.isFixed) {
30 // The channel count is fixed. Verify that we throw an error if 30 // The channel count is fixed. Verify that we throw an error if
31 // we try to change it. Arbitrarily set the count to be one more 31 // we try to change it. Arbitrarily set the count to be one more
32 // than the expected value. 32 // than the expected value.
33 testChannelCount = expectedNodeOptions.ChannelCount.value + 1; 33 testChannelCount = expectedNodeOptions.channelCount.value + 1;
34 should( 34 should(
35 () => { 35 () => {
36 node = new window[nodeName]( 36 node = new window[nodeName](
37 context, 37 context,
38 Object.assign( 38 Object.assign(
39 {}, expectedNodeOptions.additionalOptions, 39 {}, expectedNodeOptions.additionalOptions,
40 {channelCount: testChannelCount})); 40 {channelCount: testChannelCount}));
41 }, 41 },
42 'new ' + nodeName + '(c, {channelCount: ' + testChannelCount + '}}') 42 'new ' + nodeName + '(c, {channelCount: ' + testChannelCount + '}}')
43 .throw(expectedNodeOptions.ChannelCount.errorType || 'TypeError'); 43 .throw(expectedNodeOptions.channelCount.errorType || 'TypeError');
44 } else { 44 } else {
45 // The channel count is not fixed. Try to set the count to invalid 45 // The channel count is not fixed. Try to set the count to invalid
46 // values and make sure an error is thrown. 46 // values and make sure an error is thrown.
47 let errorType = 'NotSupportedError'; 47 let errorType = 'NotSupportedError';
48 48
49 should(() => { 49 should(() => {
50 node = new window[nodeName]( 50 node = new window[nodeName](
51 context, 51 context,
52 Object.assign( 52 Object.assign(
53 {}, expectedNodeOptions.additionalOptions, {channelCount: 0})); 53 {}, expectedNodeOptions.additionalOptions, {channelCount: 0}));
54 }, 'new ' + nodeName + '(c, {channelCount: 0}}', ).throw(errorType); 54 }, 'new ' + nodeName + '(c, {channelCount: 0}}', ).throw(errorType);
55 55
56 should(() => { 56 should(() => {
57 node = new window[nodeName]( 57 node = new window[nodeName](
58 context, 58 context,
59 Object.assign( 59 Object.assign(
60 {}, expectedNodeOptions.additionalOptions, {channelCount: 99})); 60 {}, expectedNodeOptions.additionalOptions, {channelCount: 99}));
61 }, 'new ' + nodeName + '(c, {channelCount: 99}}').throw(errorType); 61 }, 'new ' + nodeName + '(c, {channelCount: 99}}').throw(errorType);
62 } 62 }
63 63
64 // Test channelCountMode 64 // Test channelCountMode
65 let testChannelCountMode = 'max'; 65 let testChannelCountMode = 'max';
66 if (expectedNodeOptions.ChannelCountMode) { 66 if (expectedNodeOptions.channelCountMode) {
67 testChannelCountMode = expectedNodeOptions.ChannelCountMode.value; 67 testChannelCountMode = expectedNodeOptions.channelCountMode.value;
68 } 68 }
69 should( 69 should(
70 () => { 70 () => {
71 node = new window[nodeName]( 71 node = new window[nodeName](
72 context, Object.assign({}, expectedNodeOptions.additionalOptions, { 72 context, Object.assign({}, expectedNodeOptions.additionalOptions, {
73 channelCountMode: testChannelCountMode 73 channelCountMode: testChannelCountMode
74 })); 74 }));
75 }, 75 },
76 'new ' + nodeName + '(c, {channelCountMode: "' + testChannelCountMode + '" }') 76 'new ' + nodeName + '(c, {channelCountMode: "' + testChannelCountMode + '" }')
77 .notThrow(); 77 .notThrow();
78 should(node.channelCountMode, 'node.channelCountMode').beEqualTo(testChannelCo untMode); 78 should(node.channelCountMode, 'node.channelCountMode').beEqualTo(testChannelCo untMode);
79 79
80 if (expectedNodeOptions.ChannelCountMode && 80 if (expectedNodeOptions.channelCountMode &&
81 expectedNodeOptions.ChannelCountMode.isFixed) { 81 expectedNodeOptions.channelCountMode.isFixed) {
82 // Channel count mode is fixed. Test setting to something else throws. 82 // Channel count mode is fixed. Test setting to something else throws.
83 let testChannelCountModeMap = { 83 let testChannelCountModeMap = {
84 'max': 'clamped-max', 84 'max': 'clamped-max',
85 'clamped-max': 'explicit', 85 'clamped-max': 'explicit',
86 'explicit': 'max' 86 'explicit': 'max'
87 }; 87 };
88 testChannelCountMode = testChannelCountModeMap[expectedNodeOptions.ChannelCo untMode.value]; 88 testChannelCountMode = testChannelCountModeMap[expectedNodeOptions.channelCo untMode.value];
89 should( 89 should(
90 () => { 90 () => {
91 node = new window[nodeName]( 91 node = new window[nodeName](
92 context, 92 context,
93 Object.assign( 93 Object.assign(
94 {}, expectedNodeOptions.additionalOptions, 94 {}, expectedNodeOptions.additionalOptions,
95 {channelCountMode: testChannelCountMode})); 95 {channelCountMode: testChannelCountMode}));
96 }, 96 },
97 'new ' + nodeName + '(c, {channelCountMode: "' + testChannelCountMode + '"}') 97 'new ' + nodeName + '(c, {channelCountMode: "' + testChannelCountMode + '"}')
98 .throw(expectedNodeOptions.ChannelCountMode.errorType); 98 .throw(expectedNodeOptions.channelCountMode.errorType);
99 } else { 99 } else {
100 // Mode is not fixed. Verify that we can set the mode to all valid 100 // Mode is not fixed. Verify that we can set the mode to all valid
101 // values, and that we throw for invalid values. 101 // values, and that we throw for invalid values.
102 102
103 should(() => { 103 should(() => {
104 node = new window[nodeName]( 104 node = new window[nodeName](
105 context, Object.assign({}, expectedNodeOptions.additionalOptions, { 105 context, Object.assign({}, expectedNodeOptions.additionalOptions, {
106 channelCountMode: 'clamped-max' 106 channelCountMode: 'clamped-max'
107 })); 107 }));
108 }, 'new ' + nodeName + '(c, {channelCountMode: "clamped-max"}').notThrow(); 108 }, 'new ' + nodeName + '(c, {channelCountMode: "clamped-max"}').notThrow();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 items.forEach((item) => { 214 items.forEach((item) => {
215 let attr = node[item.name]; 215 let attr = node[item.name];
216 if (attr instanceof AudioParam) { 216 if (attr instanceof AudioParam) {
217 should(attr.value, prefix + '.' + item.name + '.value') 217 should(attr.value, prefix + '.' + item.name + '.value')
218 .beEqualTo(item.value); 218 .beEqualTo(item.value);
219 } else { 219 } else {
220 should(attr, prefix + '.' + item.name).beEqualTo(item.value); 220 should(attr, prefix + '.' + item.name).beEqualTo(item.value);
221 } 221 }
222 }); 222 });
223 } 223 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/constructor/channelmerger.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698