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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html

Issue 2595153002: Convert audiobuffersource-grain test to testharness (Closed)
Patch Set: Rebase and remove unneeded expected result 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html
index a50b108010b1e1fcb9642115242b990d020991f7..0ac2da6be8fb230de80f89608b3f2de5ef81063a 100644
--- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html
@@ -2,31 +2,30 @@
<html>
<head>
<title>Test Start Grain with Delayed Buffer Setting </title>
- <script src="../../resources/js-test.js"></script>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
- <script src="../resources/audio-testing.js"></script>
+ <script src="../resources/audit.js"></script>
</head>
<body>
<script>
- description("Test setting the source buffer after starting the grain");
+ let audit = Audit.createTaskRunner();
+ let context;
+ let source;
+ let buffer;
+ let renderedData;
- var context;
- var source;
- var buffer;
- var renderedData;
+ let sampleRate = 44100;
- var sampleRate = 44100;
+ let testDurationSec = 1;
+ let testDurationSamples = testDurationSec * sampleRate;
+ let startTime = 0.9 * testDurationSec;
- var testDurationSec = 1;
- var testDurationSamples = testDurationSec * sampleRate;
- var startTime = 0.9 * testDurationSec;
-
- function runTest() {
- window.jsTestIsAsync = true;
-
- context = new OfflineAudioContext(1, testDurationSamples, sampleRate);
- context.oncomplete = checkResult;
+ audit.define("Test setting the source buffer after starting the grain",
+ function (task, should) {
+ context = new OfflineAudioContext(1, testDurationSamples,
+ sampleRate);
buffer = createConstantBuffer(context, testDurationSamples, 1);
source = context.createBufferSource();
@@ -38,34 +37,32 @@
source.buffer = buffer;
// Render it!
- context.startRendering();
- }
+ context.startRendering()
+ .then(function (buffer) {
+ checkResult(buffer, should);
+ })
+ .then(task.done.bind(task));;
+ });
- function checkResult(event) {
- var success = false;
+ function checkResult(buffer, should) {
+ let success = false;
- renderedData = event.renderedBuffer.getChannelData(0);
+ renderedData = buffer.getChannelData(0);
- // Check that the rendered data is not all zeroes. Any non-zero data means the test
- // passed.
- var startFrame = Math.round(startTime * sampleRate);
- for (k = 0; k < renderedData.length; ++k) {
- if (renderedData[k]) {
- success = true;
- break;
- }
+ // Check that the rendered data is not all zeroes. Any non-zero data means the test
+ // passed.
hongchan 2017/01/04 21:40:55 Just a thought: perhaps we need should().beNonZero
Raymond Toy 2017/01/04 21:44:00 Only if we add should().beZero(). :-) Both would
hongchan 2017/01/04 21:53:36 should().beZero() can be achieved by should().beCo
+ let startFrame = Math.round(startTime * sampleRate);
+ for (k = 0; k < renderedData.length; ++k) {
+ if (renderedData[k]) {
+ success = true;
+ break;
}
+ }
- if (success)
- testPassed("Buffer was played.");
- else
- testFailed("Buffer was not played.");
-
- finishJSTest();
+ should(success, "Buffer was played").beTrue();
}
- runTest();
- successfullyParsed = true;
+ audit.run();
</script>
</body>
</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698