X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FUtil.js;fp=auto_tests%2Ftests%2FUtil.js;h=3eb59e3db6c1351431ccb967d5e4ce280caaf794;hb=901b2ebbe25c116c93550cfca91b0704d751d997;hp=6469bc60eb7c3df9e684c222faedf58e665386dc;hpb=20d4f5375fbe40b14ae4430fb04e7a5770ba0711;p=dygraphs.git diff --git a/auto_tests/tests/Util.js b/auto_tests/tests/Util.js index 6469bc6..3eb59e3 100644 --- a/auto_tests/tests/Util.js +++ b/auto_tests/tests/Util.js @@ -19,7 +19,7 @@ Util.getYLabels = function(axis_num, parent) { ary.push(y_labels[i].innerHTML); } return ary; -} +}; /** * Get the x-labels for a given axis. @@ -34,7 +34,7 @@ Util.getXLabels = function(parent) { ary.push(x_labels[i].innerHTML); } return ary; -} +}; /** * Returns all text in tags w/ a given css class, sorted. @@ -49,13 +49,36 @@ Util.getClassTexts = function(css_class, parent) { } texts.sort(); return texts; -} +}; Util.getLegend = function(parent) { parent = parent || document; var legend = parent.getElementsByClassName("dygraph-legend")[0]; return legend.textContent; -} +}; + +/** + * Assert that all the elements in 'parent' with class 'className' is + * the expected font size. + */ +Util.assertFontSizes = function(parent, className, expectedSize) { + var expectedSizePx = expectedSize + "px"; + var labels = parent.getElementsByClassName(className); + assertTrue(labels.length > 0); + + // window.getComputedStyle is apparently compatible with all browsers + // (IE first became compatible with IE9.) + // If this test fails on earlier browsers, then enable something like this, + // because the font size is set by the parent div. + // if (!window.getComputedStyle) { + // fontSize = label.parentElement.style.fontSize; + // } + for (var idx = 0; idx < labels.length; idx++) { + var label = labels[idx]; + var fontSize = window.getComputedStyle(label).fontSize; + assertEquals(expectedSizePx, fontSize); + } +}; /** @@ -67,4 +90,4 @@ Util.makeNumbers = function(ary) { ret.push(parseFloat(ary[i])); } return ret; -} +};