X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FCanvasAssertions.js;h=8b521552f43587020c4f9a84dc7ad0b4d1143662;hb=4a0cb9c4671b5c212da6ebc71e25fb9d1aaec692;hp=1ef0573ae2e859fd11efd18427b004dd625399c0;hpb=02eb7ae72eb3d5e83c2bf546d1fc2a6a60b91008;p=dygraphs.git diff --git a/auto_tests/tests/CanvasAssertions.js b/auto_tests/tests/CanvasAssertions.js index 1ef0573..8b52155 100644 --- a/auto_tests/tests/CanvasAssertions.js +++ b/auto_tests/tests/CanvasAssertions.js @@ -85,6 +85,21 @@ CanvasAssertions.assertLineDrawn = function(proxy, p1, p2, attrs) { " and " + p2 + " with attributes " + toString(attrs)); } +/** + * Checks how many lines of the given color have been drawn. + * @return {Integer} The number of lines of the given color. + */ +CanvasAssertions.numLinesDrawn = function(proxy, color) { + var num_lines = 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++; + } + } + return num_lines; +} + CanvasAssertions.matchPixels = function(expected, actual) { // Expect array of two integers. Assuming the values are within one // integer unit of each other. This should be tightened down by someone