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

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

Issue 2435593009: New WebAudio layout testing utility: audit.js (Closed)
Patch Set: more progress Created 4 years, 1 month 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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>A simple unit testing for audio-test-utils.js and testharness.js</title >
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit.js"></script>
8 </head>
9 <body>
10 <script>
11 var audit = Audit.createTaskRunner();
12
13 // Basic assertion testing.
14 audit.define('basic', function (task, should) {
15 task.describe('Simple unit tests for basic assertions.');
16
17 should(OfflineAudioContext, 'OfflineAudioContext').exist();
18
19 should(function () { var foo = 0; }, 'Setting foo to 0').notThrow();
20 should(function () { var foo = bar; }).throw('ReferenceError');
21
22 should(true).beTrue();
23 should(false).beFalse();
24
25 should(3).notBeNaN();
26 should(new Object(), 'A newly created object').notBeNaN();
27 should([1, 2, 3]).notBeNaN();
28 should([1, 2, 3, NaN, 4, 5, 6, NaN]).notBeNaN();
29
30 should(1).beEqualTo(1)
31 should(1).notBeEqualTo(2)
32 should(typeof AudioContext.prototype).beEqualTo('object');
33
34 should(2).beGreaterThan(1);
35 should(2).beGreaterThanOrEqualTo(2);
36
37 should(1).beLessThan(2);
38 should(1).beLessThanOrEqualTo(1);
39
40 let oac = new OfflineAudioContext(1, 128, 44100);
41
42 Promise.all([
43 should(oac.startRendering(), 'Start OAC rendering').beResolved(),
44 should(oac.decodeAudioData()).beRejected()
45 ]).then(function () {
46 task.done();
47 });
48 });
49
50
51 // Advanced, mostly array-based numerical testing.
52 audit.define('numerical', function (task, should) {
53 task.describe('Numerical assertion unit test.');
54
55 should(2.3).beCloseTo(2, 0.3);
56
57 should([1, 1, 1]).beConstantValueOf(1);
58 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49]).beConstantValueOf(5);
59
60 should([1, 1, 1]).beEqualToArray([1, 1, 1]);
61 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49])
62 .beEqualToArray([1, 8, 10, 18, 6, 5, 6, 5, 123, 48]);
63
64 should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 2, 3]);
65 should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 3, 2]);
66
67 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.06);
68 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.04);
69
70 should([0.11, 0.19]).beCloseToArray([0.1, 0.2], {
71 absoluteThreshold: 0.02,
72 relativeThreshold: 0.1
73 });
74
Raymond Toy 2016/11/08 21:14:18 Need test where this fails. To be thorough, need
75 task.done();
76 });
77
78
79 audit.run();
80 </script>
81 </body>
82 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698