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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/unit-tests/audit.html

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (Closed)
Patch Set: 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>audit.js: basic tests</title> 4 <title>
5 <script src="../../resources/testharness.js"></script> 5 audit.js: basic tests
6 <script src="../../resources/testharnessreport.js"></script> 6 </title>
7 <script src="../resources/audit.js"></script> 7 <script src="../../resources/testharness.js"></script>
8 </head> 8 <script src="../../resources/testharnessreport.js"></script>
9 <body> 9 <script src="../resources/audit.js"></script>
10 <script> 10 </head>
11 var audit = Audit.createTaskRunner({ requireResultFile: true }); 11 <body>
12 <script id="layout-test-code">
13 let audit = Audit.createTaskRunner({requireResultFile: true});
12 14
13 15
14 // Basic assertion testing. 16 // Basic assertion testing.
15 audit.define({ 17 audit.define(
16 label: 'basic', 18 {
17 description: 'Simple unit tests for basic assertions.' 19 label: 'basic',
18 }, function (task, should) { 20 description: 'Simple unit tests for basic assertions.'
19 should(OfflineAudioContext, 'OfflineAudioContext').exist(); 21 },
20 should(function () { var foo1 = 0; }, 'Setting foo1 to 0').notThrow(); 22 function(task, should) {
21 should(function () { var foo2 = bar; }).throw(); 23 should(OfflineAudioContext, 'OfflineAudioContext').exist();
22 should(function () { var foo3 = bar; }).throw('ReferenceError'); 24 should(function() {
23 should(function () { var foo4 = bar; }).throw(null); 25 let foo1 = 0;
24 should(function () { var foo5 = bar; }).throw(undefined); 26 }, 'Setting foo1 to 0').notThrow();
25 should(() => { should(); }, 'Calling should() with no argument') 27 should(function() {
26 .throw('Error'); 28 let foo2 = bar;
27 should(3 < 5, '3 < 5').beTrue(); 29 }).throw();
28 should(false).beFalse(); 30 should(function() {
29 should(1).beEqualTo(1) 31 let foo3 = bar;
30 should(1).notBeEqualTo(2) 32 }).throw('ReferenceError');
31 should(typeof AudioContext.prototype).beEqualTo('object'); 33 should(function() {
32 should(2).beGreaterThan(1); 34 let foo4 = bar;
33 should(2).beGreaterThanOrEqualTo(2); 35 }).throw(null);
34 should(1).beLessThan(2); 36 should(function() {
35 should(1).beLessThanOrEqualTo(1); 37 let foo5 = bar;
36 should(should(1).beEqualTo(1), 'should(1).beEqualTo(1)').beTrue(); 38 }).throw(undefined);
37 should(true, 'The message is').message('truthful!', 'false!'); 39 should(() => {
40 should();
41 }, 'Calling should() with no argument').throw('Error');
42 should(3 < 5, '3 < 5').beTrue();
43 should(false).beFalse();
44 should(1).beEqualTo(1)
45 should(1).notBeEqualTo(2)
46 should(typeof AudioContext.prototype).beEqualTo('object');
47 should(2).beGreaterThan(1);
48 should(2).beGreaterThanOrEqualTo(2);
49 should(1).beLessThan(2);
50 should(1).beLessThanOrEqualTo(1);
51 should(should(1).beEqualTo(1), 'should(1).beEqualTo(1)').beTrue();
52 should(true, 'The message is').message('truthful!', 'false!');
38 53
39 should(BaseAudioContext.prototype, 'BaseAudioContext.prototype') 54 should(BaseAudioContext.prototype, 'BaseAudioContext.prototype')
40 .haveOwnProperty('createGain'); 55 .haveOwnProperty('createGain');
41 should(BaseAudioContext.prototype, 'BaseAudioContext.prototype') 56 should(BaseAudioContext.prototype, 'BaseAudioContext.prototype')
42 .notHaveOwnProperty('startRendering'); 57 .notHaveOwnProperty('startRendering');
43 58
44 let ac = new AudioContext(); 59 let ac = new AudioContext();
45 let sourceNode = new AudioBufferSourceNode(ac); 60 let sourceNode = new AudioBufferSourceNode(ac);
46 should(sourceNode, 'An AudioBufferSourceNode') 61 should(sourceNode, 'An AudioBufferSourceNode')
47 .inheritFrom('AudioScheduledSourceNode'); 62 .inheritFrom('AudioScheduledSourceNode');
48 should(sourceNode, 'An AudioBufferSourceNode') 63 should(sourceNode, 'An AudioBufferSourceNode')
49 .inheritFrom('AudioNode'); 64 .inheritFrom('AudioNode');
50 65
51 let oac = new OfflineAudioContext(1, 128, 44100); 66 let oac = new OfflineAudioContext(1, 128, 44100);
52 Promise.all([ 67 Promise
53 should(oac.startRendering(), 'Start OAC rendering').beResolved(), 68 .all([
54 should(oac.decodeAudioData(), 'Decoding audio data with no argument' ) 69 should(oac.startRendering(), 'Start OAC rendering')
55 .beRejected(), 70 .beResolved(),
56 should(oac.suspend(), 'Suspending OAC with no argument') 71 should(
57 .beRejectedWith('TypeError') 72 oac.decodeAudioData(),
58 ]).then(task.done.bind(task)); 73 'Decoding audio data with no argument')
59 } 74 .beRejected(),
60 ); 75 should(oac.suspend(), 'Suspending OAC with no argument')
76 .beRejectedWith('TypeError')
77 ])
78 .then(task.done.bind(task));
79 });
61 80
62 81
63 // Advanced, mostly array-based numerical testing. Note that some codes 82 // Advanced, mostly array-based numerical testing. Note that some codes
64 // are commented out to avoid the trybot failure. These failures are 83 // are commented out to avoid the trybot failure. These failures are
65 // intentional, to demonstrate how the detailed failure report works. 84 // intentional, to demonstrate how the detailed failure report works.
66 audit.define({ 85 audit.define(
67 label: 'numerical', 86 {label: 'numerical', description: 'Numerical assertion unit test.'},
68 description: 'Numerical assertion unit test.' 87 function(task, should) {
69 }, function (task, should) { 88 should(2.3).beCloseTo(2, {threshold: 0.3});
70 should(2.3).beCloseTo(2, { threshold: 0.3 }); 89 should([1, 1, 1]).beConstantValueOf(1);
71 should([1, 1, 1]).beConstantValueOf(1); 90 should([1, 0, 1]).notBeConstantValueOf(1);
72 should([1, 0, 1]).notBeConstantValueOf(1); 91 should([1, 0, 0, 1]).notBeConstantValueOf(1);
73 should([1, 0, 0, 1]).notBeConstantValueOf(1); 92 should([1, 1, 1]).beEqualToArray([1, 1, 1]);
74 should([1, 1, 1]).beEqualToArray([1, 1, 1]); 93 should([
75 should([1, 1, 1, 1, 2, 2, 3, 3, 3]) 94 1, 1, 1, 1, 2, 2, 3, 3, 3
76 .containValues([1, 2, 3], 'one, two, three'); 95 ]).containValues([1, 2, 3], 'one, two, three');
77 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.06); 96 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.06);
78 task.done(); 97 task.done();
79 } 98 });
80 );
81 99
82 audit.define({ 100 audit.define(
83 label: 'numerical typed arrays', 101 {
84 description: 'Numerical assertion unit test with typed arrays.' 102 label: 'numerical typed arrays',
85 }, function (task, should) { 103 description: 'Numerical assertion unit test with typed arrays.'
86 let testValues = [1,2,3]; 104 },
87 should(Uint8Array.from(testValues), 'Uint8Array').beEqualToArray(testValue s); 105 function(task, should) {
88 should(Float32Array.from(testValues), 'Float32Array').beEqualToArray(testV alues); 106 let testValues = [1, 2, 3];
89 should(Float64Array.from(testValues), 'Float64Array').beEqualToArray(testV alues); 107 should(Uint8Array.from(testValues), 'Uint8Array')
90 task.done(); 108 .beEqualToArray(testValues);
91 }); 109 should(Float32Array.from(testValues), 'Float32Array')
110 .beEqualToArray(testValues);
111 should(Float64Array.from(testValues), 'Float64Array')
112 .beEqualToArray(testValues);
113 task.done();
114 });
92 115
93 // Test Audit.loadFileFromUrl() within |should| assertion. 116 // Test Audit.loadFileFromUrl() within |should| assertion.
94 // See: crbug.com/701813 117 // See: crbug.com/701813
95 audit.define({ 118 audit.define(
96 label: 'load-file-in-should', 119 {
97 description: 'Test Audit.loadFileFromUrl() within |should| assertion.' 120 label: 'load-file-in-should',
98 }, (task, should) => { 121 description:
99 let url = '../resources/hyper-reality/laughter.wav'; 122 'Test Audit.loadFileFromUrl() within |should| assertion.'
100 let promise = should(Audit.loadFileFromUrl(url), 123 },
101 'Loading file within should().beResolved()') 124 (task, should) => {
102 .beResolved(); 125 let url = '../resources/hyper-reality/laughter.wav';
103 promise.then(() => { task.done() }); 126 let promise = should(
104 } 127 Audit.loadFileFromUrl(url),
105 ); 128 'Loading file within should().beResolved()')
129 .beResolved();
130 promise.then(() => {task.done()});
131 });
106 132
107 133
108 // The task headline needs to be printed even if there is no description is 134 // The task headline needs to be printed even if there is no description
109 // given. 135 // is given.
110 audit.define('dummy-label-string', function (task) { 136 audit.define('dummy-label-string', function(task) {
111 task.done(); 137 task.done();
112 }); 138 });
113 139
114 140
115 // Test the same thing in a differen way. 141 // Test the same thing in a differen way.
116 audit.define({ label: 'dummy-label-object' }, function (task) { 142 audit.define({label: 'dummy-label-object'}, function(task) {
117 task.done(); 143 task.done();
118 }); 144 });
119 145
120 146
121 // This task is defined, but you can selectively opt it out when the task 147 // This task is defined, but you can selectively opt it out when the task
122 // runs. If you would like to see how failure cases get printed, include 148 // runs. If you would like to see how failure cases get printed, include
123 // this task and launch the task runner. 149 // this task and launch the task runner.
124 audit.define('empty', function (task, should) { 150 audit.define('empty', function(task, should) {
125 task.done(); 151 task.done();
126 }); 152 });
127 153
128 154
129 // You can enumerate tasks you want to execute in the order, or simply pass 155 // You can enumerate tasks you want to execute in the order, or simply
130 // no argument to run all the defined tasks. 156 // pass no argument to run all the defined tasks.
131 audit.run('numerical', 'numerical typed arrays', 'basic', 157 audit.run(
132 'load-file-in-should', 'dummy-label-string', 'dummy-label-object') ; 158 'numerical', 'numerical typed arrays', 'basic', 'load-file-in-should',
133 </script> 159 'dummy-label-string', 'dummy-label-object');
134 </body> 160 </script>
161 </body>
135 </html> 162 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698