OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <html> | |
3 <head> | |
4 <script src="../resources/js-test.js"></script> | |
5 <script src="resources/compatibility.js"></script> | |
6 <script src="resources/audit-util.js"></script> | |
7 <script src="resources/audio-testing.js"></script> | |
8 <script src="resources/audioparam-testing.js"></script> | |
9 <title>Test AudioBuffer.getChannelData() Returns the Same Object</title> | |
10 </head> | |
11 | |
12 <body> | |
13 <script> | |
14 description("Test AudioBuffer.getChannelData() Returns the Same Object"); | |
15 window.jsTestIsAsync = true; | |
16 | |
17 var sampleRate = 48000; | |
18 var renderDuration = 0.5; | |
19 | |
20 var audit = Audit.createTaskRunner(); | |
21 | |
22 audit.defineTask("buffer-eq", function (done) { | |
23 // Verify that successive calls to getChannelData return the same buffer
. | |
24 var context = new AudioContext(); | |
25 var channelCount = 2; | |
26 var frameLength = 1000; | |
27 var buffer = context.createBuffer(channelCount, frameLength, context.sam
pleRate); | |
28 var success = true; | |
29 | |
30 for (var c = 0; c < channelCount; ++c) { | |
31 var a = buffer.getChannelData(c); | |
32 var b = buffer.getChannelData(c); | |
33 testPassed("a = buffer.getChannelData(" + c + ")"); | |
34 testPassed("b = buffer.getChannelData(" + c + ")"); | |
35 | |
36 if (a === b) { | |
37 testPassed("a === b is true"); | |
38 } else { | |
39 testFailed("a === b is false"); | |
40 success = false; | |
41 } | |
42 } | |
43 | |
44 if (success) | |
45 testPassed("getChannelData correctly returned the same buffer.\n") | |
46 else | |
47 testFailed("getChannelData inccorrectly returned the different buffers
.\n") | |
48 done(); | |
49 }); | |
50 | |
51 audit.defineTask("buffer-not-eq", function (done) { | |
52 var context = new AudioContext(); | |
53 var channelCount = 2; | |
54 var frameLength = 1000; | |
55 var buffer1 = context.createBuffer(channelCount, frameLength, context.sa
mpleRate); | |
56 var buffer2 = context.createBuffer(channelCount, frameLength, context.sa
mpleRate); | |
57 var success = true; | |
58 | |
59 for (var c = 0; c < channelCount; ++c) { | |
60 var a = buffer1.getChannelData(c); | |
61 var b = buffer2.getChannelData(c); | |
62 testPassed("a = buffer1.getChannelData(" + c + ")"); | |
63 testPassed("b = buffer2.getChannelData(" + c + ")"); | |
64 | |
65 if (a === b) { | |
66 testFailed("a === b is true"); | |
67 success = false; | |
68 } else { | |
69 testPassed("a === b is false"); | |
70 } | |
71 } | |
72 | |
73 if (success) | |
74 testPassed("getChannelData correctly returned different buffers.\n") | |
75 else | |
76 testFailed("getChannelData incorrectly returned the same buffers.\n") | |
77 done(); | |
78 }); | |
79 | |
80 audit.defineTask("finish", function (done) { | |
81 finishJSTest(); | |
82 done(); | |
83 }); | |
84 | |
85 audit.runTasks(); | |
86 </script> | |
87 </body> | |
88 </html> | |
OLD | NEW |