X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FCanvasAssertions.js;h=2b37ec5855c8cc44dbf00ad6f3e3c6d570f08778;hb=89fdcedbda6906d90e15d84285c4f6c0b8d96d28;hp=9550912c6b3fc692bbcc327db4220156fd531930;hpb=c3b3ea32cbd608f15df6cd61aaa848e28ca0adb2;p=dygraphs.git diff --git a/auto_tests/tests/CanvasAssertions.js b/auto_tests/tests/CanvasAssertions.js index 9550912..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,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;