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

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

Issue 2705483002: Print out label and description on task entry in Audit task runner (Closed)
Patch Set: Deactivate task.describe() and simplify change Created 3 years, 10 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: handling failures</title> 4 <title>audit.js: handling failures</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.js"></script> 7 <script src="../resources/audit.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <script> 10 <script>
11 // The task runner will print out a console message to ensure the text file 11 // The task runner will print out a console message to ensure the text file
12 // comparison. 12 // comparison.
13 var audit = Audit.createTaskRunner({ requireResultFile: true }); 13 var audit = Audit.createTaskRunner({ requireResultFile: true });
14 14
15 15
16 // These assertions are supposed to be failed. The WPT (testharness) fails 16 // These assertions are supposed to be failed. The WPT (testharness) fails
17 // because the assertions are failing, but the existence of expected test 17 // because the assertions are failing, but the existence of expected test
18 // result makes this test pass as long as the actual and the expected match. 18 // result makes this test pass as long as the actual and the expected match.
19 // See the expected result file to see the logging message from Audit. 19 // See the expected result file to see the logging message from Audit.
20 20
21 21
22 // Basic assertions. 22 // Basic assertions.
23 audit.define('basic-failure', function (task, should) { 23 audit.define({
24 task.describe('Testing basic assertion failures.'); 24 label: 'basic-failure',
25 description: 'Testing basic assertion failures.'
26 }, function (task, should) {
27 should(function () { var foo = bar; }, 'Setting foo to bar').notThrow();
28 should(function () { var foo = 0; }).throw('ReferenceError');
29 should(3 > 5, '3 < 5').beTrue();
30 should(true).beFalse();
31 should(1, 'The number of channels').beEqualTo(2);
32 should(1).notBeEqualTo(1);
33 should(typeof 3.141592, 'typeof 3.141592').beEqualTo('string');
34 should(1).beGreaterThan(2);
35 should(1).beGreaterThanOrEqualTo(2);
36 should(2).beLessThan(1);
37 should(2).beLessThanOrEqualTo(1);
38 should(should(1).beEqualTo(2), 'should(1).beEqualTo(2)').beTrue();
39 should(false, 'The message is').message('truthful!', 'false!');
25 40
26 should(function () { var foo = bar; }, 'Setting foo to bar').notThrow(); 41 let oac = new OfflineAudioContext(1, 128, 44100);
27 should(function () { var foo = 0; }).throw('ReferenceError'); 42 Promise.all([
28 should(3 > 5, '3 < 5').beTrue(); 43 should(oac.decodeAudioData(), 'Decoding audio data with no argument' )
29 should(true).beFalse(); 44 .beResolved(),
30 should(1, 'The number of channels').beEqualTo(2); 45 should(oac.startRendering(), 'Start OAC rendering').beRejected(),
31 should(1).notBeEqualTo(1); 46 should(oac.suspend(), 'Suspending OAC with no argument')
32 should(typeof 3.141592, 'typeof 3.141592').beEqualTo('string'); 47 .beRejectedWith('IndexSizeError')
33 should(1).beGreaterThan(2); 48 ]).then(task.done.bind(task));
34 should(1).beGreaterThanOrEqualTo(2); 49 }
35 should(2).beLessThan(1); 50 );
36 should(2).beLessThanOrEqualTo(1);
37 should(should(1).beEqualTo(2), 'should(1).beEqualTo(2)').beTrue();
38 should(false, 'The message is').message('truthful!', 'false!');
39
40 let oac = new OfflineAudioContext(1, 128, 44100);
41 Promise.all([
42 should(oac.decodeAudioData(), 'Decoding audio data with no argument')
43 .beResolved(),
44 should(oac.startRendering(), 'Start OAC rendering').beRejected(),
45 should(oac.suspend(), 'Suspending OAC with no argument')
46 .beRejectedWith('IndexSizeError')
47 ]).then(task.done.bind(task));
48 });
49 51
50 52
51 // Numerical assertions. 53 // Numerical assertions.
52 audit.define('numerical-failures', function (task, should) { 54 audit.define({
53 task.describe('Testing numerical assertion failures.'); 55 label: 'numerical-failures',
56 description: 'Testing numerical assertion failures.'
57 }, function (task, should) {
58 should(0).beCloseTo(0.1, { threshold: 0 });
59 should(59, 'The measured decibel').beCloseTo(62, { threshold: 0.01 });
60 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49]).beConstantValueOf(5);
61 should([0, 0, 0]).notBeConstantValueOf(0);
62 should([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
63 .beEqualToArray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
64 should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 3, 2]);
65 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.04);
66 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
67 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
68 absoluteThreshold: 0.02
69 });
70 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
71 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
72 relativeThreshold: 0.1
73 });
74 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
75 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
76 absoluteThreshold: 0.02,
77 relativeThreshold: 0.1
78 });
54 79
55 should(0).beCloseTo(0.1, { threshold: 0 }); 80 task.done();
56 should(59, 'The measured decibel').beCloseTo(62, { threshold: 0.01 }); 81 }
57 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49]).beConstantValueOf(5); 82 );
58 should([0, 0, 0]).notBeConstantValueOf(0);
59 should([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
60 .beEqualToArray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
61 should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 3, 2]);
62 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.04);
63 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
64 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
65 absoluteThreshold: 0.02
66 });
67 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
68 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
69 relativeThreshold: 0.1
70 });
71 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
72 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
73 absoluteThreshold: 0.02,
74 relativeThreshold: 0.1
75 });
76
77 task.done();
78 });
79 83
80 84
81 // With no argument, this executes all tasks in the order defined. 85 // With no argument, this executes all tasks in the order defined.
82 audit.run(); 86 audit.run();
83 </script> 87 </script>
84 </body> 88 </body>
85 </html> 89 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698