X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FCanvasAssertions.js;h=2b37ec5855c8cc44dbf00ad6f3e3c6d570f08778;hb=bf50de0db3094fc5155efc8aee14112df2545e42;hp=929ba4f413c6660cbbe1c7c97137b023a288b1c5;hpb=30a5cfc6c8dfe0ff412e63498eac09d31e9004a7;p=dygraphs.git diff --git a/auto_tests/tests/CanvasAssertions.js b/auto_tests/tests/CanvasAssertions.js index 929ba4f..2b37ec5 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,10 +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]; - if (call.name == "lineTo" && call.properties.strokeStyle == color) { - num_lines++; + 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_potential_calls; + } + num_potential_calls = 0; } } return num_lines;