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

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: Clean up 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..c43bc40ddea621d92a5c9326589eed5dcb052e8b 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,7 +106,7 @@ 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;
@@ -118,16 +118,14 @@ function verifyStartAndEndFrames(startEndFrames) {
// 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;
- }
+ success = should(startFrames.length == endFrames.length,
+ "Found all grain starts and ends").beTrue()
+ && success;
hongchan 2017/01/18 18:19:04 Please see the comment at the end.
- if (startFrames.length == numberOfTests && endFrames.length == numberOfTests) {
- testPassed("Found all " + numberOfTests + " grains.");
- } else {
- testFailed("Did not find all " + numberOfTests + " grains.");
- }
+ success = should(startFrames.length, "Number of start frames").beEqualTo(numberOfTests)
+ && success;
+ success = should(endFrames.length, "Number of end frames").beEqualTo(numberOfTests)
+ && success;
hongchan 2017/01/18 18:19:04 Ditto.
// Examine the start and stop times to see if they match our
// expectations.
@@ -137,42 +135,39 @@ function verifyStartAndEndFrames(startEndFrames) {
// for HRTF.
var expectedEnd = extraFramesHRTF + expectedStart + grainLengthInSampleFrames(k * grainOffsetStep, duration, sampleRate);
- 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;
- }
+ success = should([startFrames[k], endFrames[k]], "Pulse " + k + " boundary")
+ .beEqualToArray([expectedStart, expectedEnd])
+ && success;
}
// 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;
- }
+ success = should(startFrames.length,
+ "Number of grains that started at the correct time")
+ .beEqualTo(numberOfTests)
+ && success;
} else {
- testFailed(errorCountStart + " out of " + numberOfTests + " grains started at the wrong time.");
- success = false;
+ success = should(errorCountStart,
+ "Number of grains out of " + numberOfTests + "that started at the wrong time")
+ .beEqualTo(0)
+ && success;
}
+
hongchan 2017/01/18 18:19:04 Remove this empty line.
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;
- }
+ success = should(endFrames.length,
+ "Number of grains that ended at the correct time")
+ .beEqualTo(numberOfTests) && success;
} else {
- testFailed(errorCountEnd + " out of " + numberOfTests + " grains ended at the wrong time.");
- success = false;
+ success = should(errorCountEnd,
+ "Number of grains out of " + numberOfTests + " that ended at the wrong time")
+ .beEqualTo(0)
+ && success;
}
return success;
hongchan 2017/01/18 18:19:04 Just do all the |should| assertions, then get the
Raymond Toy 2017/01/18 19:33:30 I don't think we even need to return success anymo

Powered by Google App Engine
This is Rietveld 408576698