X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=auto_tests%2Ftests%2FCanvasAssertions.js;h=ef37fb9d54bf305dfec60e69660ff6457eb71cac;hb=bedc5cd39283fe07b9e4125c4e397b14571fed15;hp=62a3f495b0bc7445f4bab9883712644317ce1bc8;hpb=32c4d92b20add8400502e8d7b1337f2170fc987c;p=dygraphs.git diff --git a/auto_tests/tests/CanvasAssertions.js b/auto_tests/tests/CanvasAssertions.js index 62a3f49..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,12 +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") { + 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; @@ -236,3 +244,5 @@ CanvasAssertions.match = function(predicate, call) { } return true; }; + +export default CanvasAssertions;