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

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

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update files to the right GN files. Created 4 years, 3 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
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test Constructor: AudioBuffer</title>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/compatibility.js"></script>
8 </head>
9
10 <body>
11 <script>
12 var context;
13
14 test(function () {
hongchan 2016/09/08 21:41:11 Are you keeping the test in this way? This is okay
Raymond Toy 2016/09/08 21:58:00 Oops. I forgot to rewrite these.
15 context = new OfflineAudioContext(1, 1, 48000);
16 assert_true(context instanceof AudioContext,
17 "context created successfully");
18 }, "Construct offline context");
19
20 test(function () {
21 assert_throws(null,
22 function () {
23 var node = new AudioBuffer(context);
24 }, "Two arguments required");
25
26 assert_throws(null,
27 function () {
28 return new AudioBuffer(42, {})
29 }, "First argument must be a context");
30
31 assert_throws(null,
32 function () {
33 return new AudioBuffer(context, 42);
34 }, "Second arg must be an object");
35 }, "Test argument count and type");
36
37 test(function () {
38 assert_throws("NotFoundError",
39 function () {
40 var buffer = new AudioBuffer(context, {});
41 }, "Empty options");
42
43 assert_throws("NotFoundError",
44 function () {
45 var buffer = new AudioBuffer(context, {
46 numberOfChannels: 1
47 });
48 }, "Include numberOfChannels");
49
50 assert_throws("NotFoundError",
51 function () {
52 var buffer = new AudioBuffer(context, {
53 length: 10
54 });
55 }, "Include numberOfChannels");
56
57 }, "Construct AudioBuffer without required values, throwing errors");
58
59 test(function () {
60 var options = {
61 numberOfChannels: 3,
62 length: 42,
63 sampleRate: 16000
64 };
65 var buffer = new AudioBuffer(context, options);
66
67 assert_equals(buffer.numberOfChannels, options.numberOfChannels);
68 assert_equals(buffer.length, options.length);
69 assert_equals(buffer.sampleRate, options.sampleRate);
70
71 buffer = new AudioBuffer(context, {
72 numberOfChannels: 3,
73 length: 42
74 });
75
76 assert_equals(buffer.sampleRate, context.sampleRate);
77
78 }, "Construct valid AudioBuffer and check values");
79
80 </script>
81 </body>
82 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698