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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBuffer/audiobuffer.html

Issue 2595073002: Convert audiobuffer.html to testharness (Closed)
Patch Set: Remove unneeded expected results Created 3 years, 11 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 | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBuffer/audiobuffer-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../resources/audit-util.js"></script> 6 <script src="../resources/audit-util.js"></script>
6 <script src="../resources/audio-testing.js"></script> 7 <script src="../resources/audit.js"></script>
7 </head> 8 </head>
8 <body> 9 <body>
9 <script> 10 <script>
10 description("Basic tests for AudioBuffer."); 11 let sampleRate = 44100.0
12 let lengthInSeconds = 2;
13 let numberOfChannels = 4;
11 14
12 var sampleRate = 44100.0 15 let audit = Audit.createTaskRunner();
13 var lengthInSeconds = 2;
14 var numberOfChannels = 4;
15 16
16 var context = new AudioContext(); 17 audit.define("Basic tests for AudioBuffer", function (task, should) {
17 var buffer = context.createBuffer(numberOfChannels, sampleRate * lengthInSeconds , sampleRate); 18 let context = new AudioContext();
19 let buffer = context.createBuffer(numberOfChannels,
20 sampleRate * lengthInSeconds, sampleRate);
18 21
19 if (buffer.sampleRate === sampleRate) 22 // Just for printing out a message describing what "buffer" is in the
20 testPassed("sampleRate has been set correctly."); 23 // following tests.
21 else 24 should(true,
22 testFailed("sampleRate should be set correctly."); 25 "buffer = context.createBuffer(" + numberOfChannels + ", " + (
26 sampleRate * lengthInSeconds) + ", " + sampleRate + ")")
27 .beTrue();
23 28
24 if (buffer.length === sampleRate * lengthInSeconds) 29 should(buffer.sampleRate, "buffer.sampleRate")
25 testPassed("length has been set correctly."); 30 .beEqualTo(sampleRate);
26 else
27 testFailed("length should be set correctly");
28 31
29 if (buffer.duration === lengthInSeconds) 32 should(buffer.length, "buffer.length")
30 testPassed("duration has been set correctly."); 33 .beEqualTo(sampleRate * lengthInSeconds);
31 else
32 testFailed("duration should be set correctly.");
33 34
34 if (buffer.numberOfChannels === numberOfChannels) 35 should(buffer.duration, "buffer.duration")
35 testPassed("numberOfChannels has been set correctly."); 36 .beEqualTo(lengthInSeconds);
36 else
37 testFailed("numberOfChannels should be set correctly.");
38 37
39 for (var index = 0; index < buffer.numberOfChannels; ++index) { 38 should(buffer.numberOfChannels, "buffer.numberOfChannels")
40 if (buffer.getChannelData(index) instanceof window.Float32Array) 39 .beEqualTo(numberOfChannels);
41 testPassed("getChannelData(" + index + ") returns a Float32Array object. ");
42 else
43 testFailed("getChannelData(" + index + ") should return a Float32Array o bject.");
44 }
45 40
46 try { 41 for (let index = 0; index < buffer.numberOfChannels; ++index) {
47 buffer.getChannelData(buffer.numberOfChannels); 42 should(
48 testFailed("Exception should be thrown when index is not less than numberOfC hannels."); 43 buffer.getChannelData(index) instanceof window.Float32Array,
49 } catch(e) { 44 "buffer.getChannelData(" + index +
50 testPassed("Exception has been thrown correctly when index is not less than numberOfChannels."); 45 ") instanceof window.Float32Array")
51 } 46 .beTrue();
47 }
52 48
53 var buffer2 = context.createBuffer(1, 1000, 24576); 49 should(function () {
54 var expectedDuration = 1000/24576; 50 buffer.getChannelData(buffer.numberOfChannels);
51 }, "buffer.getChannelData(" + buffer.numberOfChannels + ")")
52 .throw("IndexSizeError");
55 53
56 if (buffer2.duration == expectedDuration) 54 let buffer2 = context.createBuffer(1, 1000, 24576);
57 testPassed("duration has expected accuracy."); 55 let expectedDuration = 1000 / 24576;
58 else 56
59 testFailed("duration is " + buffer2.duration + " sec instead of " + expected Duration + " sec."); 57 should(buffer2.duration, "context.createBuffer(1, 1000, 24576).duration")
58 .beEqualTo(expectedDuration);
59
60 task.done();
61 });
62
63 audit.run();
60 </script> 64 </script>
61 65
62 </body> 66 </body>
63 </html> 67 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBuffer/audiobuffer-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698