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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js

Issue 2594183003: Convert note-grain-on tests to testharness (Closed)
Patch Set: Remove |success| which isn't needed anymore. 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
Index: third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js
diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js
index 8f93c9edfaf32a128cfadd01fc716513db901642..35f662db2fa14b72fdd8faec42b654951f9f2853 100644
--- a/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js
@@ -106,28 +106,21 @@ function playAllGrains(context, source, numberOfNotes) {
// Verify that the start and end frames for each grain match our
// expected start and end frames.
-function verifyStartAndEndFrames(startEndFrames) {
+function verifyStartAndEndFrames(startEndFrames, should) {
var startFrames = startEndFrames.start;
var endFrames = startEndFrames.end;
- var success = true;
-
// Count of how many grains started at the incorrect time.
var errorCountStart = 0;
// Count of how many grains ended at the incorrect time.
var errorCountEnd = 0;
- if (startFrames.length != endFrames.length) {
- testFailed("Could not find the beginning or end of a grain.");
- success = false;
- }
+ should(startFrames.length == endFrames.length,
+ "Found all grain starts and ends").beTrue();
- if (startFrames.length == numberOfTests && endFrames.length == numberOfTests) {
- testPassed("Found all " + numberOfTests + " grains.");
- } else {
- testFailed("Did not find all " + numberOfTests + " grains.");
- }
+ should(startFrames.length, "Number of start frames").beEqualTo(numberOfTests);
hongchan 2017/01/20 17:46:10 Wrap at 80.
Raymond Toy 2017/01/20 19:37:10 Done.
+ should(endFrames.length, "Number of end frames").beEqualTo(numberOfTests);
// Examine the start and stop times to see if they match our
// expectations.
@@ -137,43 +130,33 @@ function verifyStartAndEndFrames(startEndFrames) {
// for HRTF.
var expectedEnd = extraFramesHRTF + expectedStart + grainLengthInSampleFrames(k * grainOffsetStep, duration, sampleRate);
hongchan 2017/01/20 17:46:09 Let's wrap at 80.
Raymond Toy 2017/01/20 19:37:10 Done.
- if (startFrames[k] != expectedStart) {
- testFailed("Pulse " + k + " started at " + startFrames[k] + " but expected at " + expectedStart);
- ++errorCountStart;
- success = false;
- }
+ if (startFrames[k] != expectedStart)
+ ++errorCountStart;
+ if (endFrames[k] != expectedEnd)
+ ++errorCountEnd;
- if (endFrames[k] != expectedEnd) {
- testFailed("Pulse " + k + " ended at " + endFrames[k] + " but expected at " + expectedEnd);
- ++errorCountEnd;
- success = false;
- }
+ should([startFrames[k], endFrames[k]], "Pulse " + k + " boundary")
+ .beEqualToArray([expectedStart, expectedEnd]);
}
// Check that all the grains started or ended at the correct time.
if (!errorCountStart) {
- if (startFrames.length == numberOfTests) {
- testPassed("All " + numberOfTests + " grains started at the correct time.");
- } else {
- testFailed("All grains started at the correct time, but only " + startFrames.length + " grains found.");
- success = false;
- }
+ should(startFrames.length,
+ "Number of grains that started at the correct time")
+ .beEqualTo(numberOfTests);
} else {
- testFailed(errorCountStart + " out of " + numberOfTests + " grains started at the wrong time.");
- success = false;
+ should(errorCountStart,
+ "Number of grains out of " + numberOfTests + "that started at the wrong time")
hongchan 2017/01/20 17:46:10 This line needs to be wrapped.
Raymond Toy 2017/01/20 19:37:10 Done.
+ .beEqualTo(0);
}
if (!errorCountEnd) {
- if (endFrames.length == numberOfTests) {
- testPassed("All " + numberOfTests + " grains ended at the correct time.");
- } else {
- testFailed("All grains ended at the correct time, but only " + endFrames.length + " grains found.");
- success = false;
- }
+ should(endFrames.length,
+ "Number of grains that ended at the correct time")
+ .beEqualTo(numberOfTests);
} else {
- testFailed(errorCountEnd + " out of " + numberOfTests + " grains ended at the wrong time.");
- success = false;
+ should(errorCountEnd,
+ "Number of grains out of " + numberOfTests + " that ended at the wrong time")
hongchan 2017/01/20 17:46:10 Ditto.
Raymond Toy 2017/01/20 19:37:10 Done.
+ .beEqualTo(0);
}
-
- return success;
}

Powered by Google App Engine
This is Rietveld 408576698