cypress_test/integration_tests/common/helper.js | 32 +++++++++- cypress_test/integration_tests/mobile/impress/slide_properties_spec.js | 28 -------- 2 files changed, 33 insertions(+), 27 deletions(-)
New commits: commit 0994b2f1be060700bcd7b79392ab5f413bc5a925 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Mon Jun 15 16:35:09 2020 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Wed Jun 17 16:50:41 2020 +0200 cypress: extract imageShouldBeFullWhiteOrNot() method. Change-Id: I7d60eadb3a343c5c270cfd4ab90a7681d7c95ffa Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96522 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index f8bdd7209..00490c9bd 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -1,4 +1,4 @@ -/* global cy Cypress*/ +/* global cy Cypress expect */ function loadTestDoc(fileName, subFolder, mobile) { cy.log('Loading test document - start.'); @@ -242,6 +242,35 @@ function getLOVersion() { return 'master'; } +function imageShouldBeFullWhiteOrNot(selector, fullWhite = true) { + cy.get(selector) + .should(function(images) { + var img = images[0]; + + // Create an offscreen canvas to check the image's pixels + var canvas = document.createElement('canvas'); + canvas.width = img.width; + canvas.height = img.height; + canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height); + var context = canvas.getContext('2d'); + + // Ignore a small zone on the edges, to ignore border. + var ignoredPixels = 2; + var pixelData = context.getImageData(ignoredPixels, ignoredPixels, + img.width - 2 * ignoredPixels, + img.height - 2 * ignoredPixels).data; + + var allIsWhite = true; + for (var i = 0; i < pixelData.length; ++i) { + allIsWhite = allIsWhite && pixelData[i] == 255; + } + if (fullWhite) + expect(allIsWhite).to.be.true; + else + expect(allIsWhite).to.be.false; + }); +} + module.exports.loadTestDoc = loadTestDoc; module.exports.assertCursorAndFocus = assertCursorAndFocus; module.exports.assertNoKeyboardInput = assertNoKeyboardInput; @@ -259,3 +288,4 @@ module.exports.isWriter = isWriter; module.exports.beforeAllDesktop = beforeAllDesktop; module.exports.typeText = typeText; module.exports.getLOVersion = getLOVersion; +module.exports.imageShouldBeFullWhiteOrNot = imageShouldBeFullWhiteOrNot; diff --git a/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js b/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js index 5a869a821..fb18d99bf 100644 --- a/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js +++ b/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js @@ -21,32 +21,8 @@ describe('Changing slide properties.', function() { }); function previewShouldBeFullWhite(fullWhite = true, slideNumber = 1) { - cy.get('.preview-frame:nth-of-type(' + (slideNumber + 1).toString() + ') img') - .should(function(preview) { - var img = preview[0]; - - // Create an offscreen canvas to check the preview's pixels - var canvas = document.createElement('canvas'); - canvas.width = img.width; - canvas.height = img.height; - canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height); - var context = canvas.getContext('2d'); - - // There is a border around the preview, ignore that - var ignoredPixels = 2; - var pixelData = context.getImageData(ignoredPixels, ignoredPixels, - img.width - 2 * ignoredPixels, - img.height - 2 * ignoredPixels).data; - - var allIsWhite = true; - for (var i = 0; i < pixelData.length; ++i) { - allIsWhite = allIsWhite && pixelData[i] == 255; - } - if (fullWhite) - expect(allIsWhite).to.be.true; - else - expect(allIsWhite).to.be.false; - }); + var selector = '.preview-frame:nth-of-type(' + (slideNumber + 1).toString() + ') img'; + helper.imageShouldBeFullWhiteOrNot(selector, fullWhite); } function switchToMasterView() { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits