X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FCanvasAssertions.js;h=ef37fb9d54bf305dfec60e69660ff6457eb71cac;hb=b55a71d768d2f8de62877c32b3aec9e9975ac389;hp=9550912c6b3fc692bbcc327db4220156fd531930;hpb=8370701b5b35bc4ac1c77e87f9e839112abd46ce;p=dygraphs.git diff --git a/auto_tests/tests/CanvasAssertions.js b/auto_tests/tests/CanvasAssertions.js index 9550912..ef37fb9 100644 --- a/auto_tests/tests/CanvasAssertions.js +++ b/auto_tests/tests/CanvasAssertions.js @@ -115,8 +115,8 @@ CanvasAssertions.assertLineDrawn = function(proxy, p1, p2, predicate) { } return s + "}"; }; - fail("Can't find a line drawn between " + p1 + - " and " + p2 + " with attributes " + toString(predicate)); + throw "Can't find a line drawn between " + p1 + + " and " + p2 + " with attributes " + toString(predicate); }; /** @@ -183,15 +183,20 @@ CanvasAssertions.assertBalancedSaveRestore = function(proxy) { CanvasAssertions.numLinesDrawn = function(proxy, color) { CanvasAssertions.cleanPathAttrs_(proxy.calls__); var num_lines = 0; + var num_potential_calls = 0; for (var i = 0; i < proxy.calls__.length; i++) { var call = proxy.calls__[i]; - - // note: Don't simplify these two conditionals into one. The - // separation simplifies debugging tricky tests. - if (call.name == "lineTo") { + if (call.name == "beginPath") { + num_potential_calls = 0; + } else if (call.name == "lineTo") { + num_potential_calls++; + } else if (call.name == "stroke") { + // note: Don't simplify these two conditionals into one. The + // separation simplifies debugging tricky tests. if (call.properties.strokeStyle == color) { - num_lines++; + num_lines += num_potential_calls; } + num_potential_calls = 0; } } return num_lines; @@ -239,3 +244,5 @@ CanvasAssertions.match = function(predicate, call) { } return true; }; + +export default CanvasAssertions;