cypress: split imageShouldNotBeFullWhiteOrNot() method.

So we have separate imageShouldBeFullWhite() and
imageShouldNotBeFullWhite() methods, which might make
the code more readable, then having it controlled by
a bool parameter.

Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Change-Id: I2ada6b9e6f6d93b8a48e9ddd3c851ef3e6fcd632
This commit is contained in:
Tamás Zolnai 2021-02-05 15:36:23 +01:00 committed by Tamás Zolnai
parent 53642adf96
commit f4c4b7091a
3 changed files with 32 additions and 5 deletions

View file

@ -659,7 +659,18 @@ function typeText(selector, text, delayMs=0) {
}
}
function imageShouldBeFullWhiteOrNot(selector, fullWhite = true) {
// Check wether an img DOM element has only white colored pixels or not.
// Parameters:
// selector - a CSS selector to query the img DOM element.
// fullWhite - this specifies what we expect here, that the image is full white
// or on the contrary.
function imageShouldNotBeFullWhiteOrNot(selector, fullWhite = true) {
cy.log('Check whether an image is full white or not - start.');
cy.log('Param - selector: ' + selector);
cy.log('Param - fullWhite: ' + fullWhite);
expect(selector).to.have.string('img');
cy.get(selector)
.should(function(images) {
var img = images[0];
@ -686,6 +697,18 @@ function imageShouldBeFullWhiteOrNot(selector, fullWhite = true) {
else
expect(allIsWhite).to.be.false;
});
cy.log('Check whether an image is full white or not - end.');
}
// Check wether an img DOM element consist of only white pixels.
function imageShouldBeFullWhite(selector) {
imageShouldNotBeFullWhiteOrNot(selector, true);
}
// Check wether an img DOM element has any non-white pixels.
function imageShouldNotBeFullWhite(selector) {
imageShouldNotBeFullWhiteOrNot(selector, false);
}
function canvasShouldBeFullWhiteOrNot(selector, fullWhite = true) {
@ -998,7 +1021,8 @@ module.exports.doIfNotInImpress = doIfNotInImpress;
module.exports.doIfNotInWriter = doIfNotInWriter;
module.exports.beforeAll = beforeAll;
module.exports.typeText = typeText;
module.exports.imageShouldBeFullWhiteOrNot = imageShouldBeFullWhiteOrNot;
module.exports.imageShouldBeFullWhite = imageShouldBeFullWhite;
module.exports.imageShouldNotBeFullWhite = imageShouldNotBeFullWhite;
module.exports.canvasShouldBeFullWhiteOrNot = canvasShouldBeFullWhiteOrNot;
module.exports.clickOnIdle = clickOnIdle;
module.exports.inputOnIdle = inputOnIdle;

View file

@ -374,12 +374,12 @@ describe('Trigger hamburger menu options.', function() {
impressHelper.removeShapeSelection();
var preiew = '.preview-frame:nth-of-type(2) img';
helper.imageShouldBeFullWhiteOrNot(preiew, false);
helper.imageShouldNotBeFullWhite(preiew);
// Disable automatic spell checking
mobileHelper.selectHamburgerMenuItem(['Automatic Spell Checking']);
helper.imageShouldBeFullWhiteOrNot(preiew, true);
helper.imageShouldBeFullWhite(preiew);
});
it('Fullscreen presentation.', function() {

View file

@ -22,7 +22,10 @@ describe('Changing slide properties.', function() {
function previewShouldBeFullWhite(fullWhite = true, slideNumber = 1) {
var selector = '.preview-frame:nth-of-type(' + (slideNumber + 1).toString() + ') img';
helper.imageShouldBeFullWhiteOrNot(selector, fullWhite);
if (fullWhite)
helper.imageShouldBeFullWhite(selector);
else
helper.imageShouldNotBeFullWhite(selector);
}
function switchToMasterView() {