diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-02-03 06:35:23 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-02-03 06:35:23 +0300 |
commit | 5bacc262097a124b30e3862097ec1d88e9ff7178 (patch) | |
tree | 7f3ca4ebd9e1f2c1b3ae95f5a569adfb20d1939a /tests/UI/screenshot-diffs | |
parent | fc08408eb5566d28ce37e43849fb786c9e5cae8a (diff) |
include UI specs in Piwik repo and run tests in this repository.
On local it does not work and I have not figured out why.
Maybe it works on travis though?
Diffstat (limited to 'tests/UI/screenshot-diffs')
-rw-r--r-- | tests/UI/screenshot-diffs/diffgenerator.js | 58 | ||||
-rw-r--r-- | tests/UI/screenshot-diffs/singlediff.html | 27 |
2 files changed, 85 insertions, 0 deletions
diff --git a/tests/UI/screenshot-diffs/diffgenerator.js b/tests/UI/screenshot-diffs/diffgenerator.js new file mode 100644 index 0000000000..f88ece732e --- /dev/null +++ b/tests/UI/screenshot-diffs/diffgenerator.js @@ -0,0 +1,58 @@ +/** + * Piwik - free/libre analytics platform + * + * Diff generator + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +resemble.outputSettings({ + errorColor: { + red: 255, + green: 0, + blue: 0, + alpha: 125 + }, + errorType: 'movement', + transparency: 0.3 +}); + +function compareImages(expected, expectedGithub, processed) +{ + resemble(processed).compareTo(expected).onComplete(function(data){ + + var info = 'Mismatch percentage: ' + data.misMatchPercentage + '%'; + + if (data.dimensionDifference && !data.isSameDimensions) { + info += ' Dimension difference width: ' + data.dimensionDifference.width + ' height: ' + data.dimensionDifference.height; + } + + $('.info').text(info); + $('.diff').attr('src', data.getImageDataUrl()); + }); + + $('.processed').attr('src', encodeURI(processed)); + $('.expected').attr('src', encodeURI(expected)); + $('.expectedGithub').attr('src', 'https://raw.githubusercontent.com/piwik/piwik-ui-tests/master/expected-ui-screenshots/' + encodeURI(expectedGithub)); +} + +function getUrlQueryParam(sParam) { + var query = window.location.search.substring(1); + var variables = query.split('&'); + + for (var index = 0; index < variables.length; index++) { + + var paramName = variables[index].split('='); + if (paramName[0] == sParam) { + return paramName[1]; + } + } +} + +$(function () { + var processed = getUrlQueryParam('processed'); + var expected = getUrlQueryParam('expected'); + var github = getUrlQueryParam('github'); + compareImages(expected, github, processed); +});
\ No newline at end of file diff --git a/tests/UI/screenshot-diffs/singlediff.html b/tests/UI/screenshot-diffs/singlediff.html new file mode 100644 index 0000000000..a91ffa7a40 --- /dev/null +++ b/tests/UI/screenshot-diffs/singlediff.html @@ -0,0 +1,27 @@ +<html> +<head> + <!-- loaded when on build-artifacts --> + <script src='jquery.js'></script> + <script src='resemble.js'></script> + <!-- loaded when viewing within piwik --> + <script src='../../../../libs/bower_components/jquery/dist/jquery.min.js'></script> + <script src='../../../../tests/lib/resemblejs/resemble.js'></script> + <script src='diffgenerator.js'></script> +</head> +<body> + +<span class="info"></span> +<br /> +<br /> +<img class="diff"> + +<h2>Processed</h2> +<img class="processed"> + +<h2>Expected</h2> +<img class="expected"> + +<h2>Expected GitHub</h2> +<img class="expectedGithub"> + +</body></html>
\ No newline at end of file |