cypress_test/Makefile.am | 7 cypress_test/data/mobile/simple.odt |binary cypress_test/integration_tests/mobile/apply_font_spec.js | 359 +++++++++++++++ loleaflet/src/control/Control.Toolbar.js | 2 loleaflet/src/core/Browser.js | 8 loleaflet/src/map/Clipboard.js | 7 6 files changed, 372 insertions(+), 11 deletions(-)
New commits: commit 17553b691f75c0c7980fec172b64b98c56fab0a5 Author: Tamás Zolnai <[email protected]> AuthorDate: Tue Jan 28 17:08:06 2020 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Tue Jan 28 18:01:36 2020 +0100 cypress: mobile: More font changes related tests. Change-Id: I100b5904db47af1f1f612650f280bf2518c7fae7 diff --git a/cypress_test/data/mobile/simple.odt b/cypress_test/data/mobile/simple.odt index 833aa18fa..f7494e82f 100644 Binary files a/cypress_test/data/mobile/simple.odt and b/cypress_test/data/mobile/simple.odt differ diff --git a/cypress_test/integration_tests/mobile/apply_font_spec.js b/cypress_test/integration_tests/mobile/apply_font_spec.js index 55f268e45..ad8153e8f 100644 --- a/cypress_test/integration_tests/mobile/apply_font_spec.js +++ b/cypress_test/integration_tests/mobile/apply_font_spec.js @@ -21,6 +21,18 @@ describe('Apply font changes.', function() { }); function generateTextHTML() { + // Do a new selection + cy.get('#document-container').click(); + cy.get('.leaflet-marker-icon') + .should('not.exist'); + + cy.wait(200); + + cy.get('body').type('{shift}{home}'); + cy.get('.leaflet-marker-icon'); + + cy.wait(200); + // Open context menu cy.get('.leaflet-marker-icon') .then(function(marker) { @@ -69,5 +81,279 @@ describe('Apply font changes.', function() { cy.get('#copy-paste-container p font') .should('have.attr', 'face', 'Linux Libertine G'); }); + + it('Apply font size.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Change font size + cy.get('#fontsizecombobox') + .click(); + + cy.get('.mobile-wizard.ui-combobox-text') + .contains('36') + .click(); + + cy.get('#mobile-wizard-back') + .click(); + + // Combobox entry contains the selected font name + cy.get('#fontsizecombobox .ui-header-right') + .contains('36'); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + + generateTextHTML(); + + cy.get('#copy-paste-container p font') + .should('have.attr', 'style', 'font-size: 36pt'); + }); + + it('Apply bold font.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Apply bold + cy.get('#Bold') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + + generateTextHTML(); + + cy.get('#copy-paste-container p b') + .should('exist'); + }); + + it('Apply italic font.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Apply italic + cy.get('#Italic') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + + generateTextHTML(); + + cy.get('#copy-paste-container p i') + .should('exist'); + }); + + it('Apply underline.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Change underline + cy.get('#Underlineimg') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p u') + .should('exist'); + }); + + it('Apply strikeout.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Change strikeout + cy.get('#Strikeoutimg') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p strike') + .should('exist'); + }); + + it('Apply shadowed.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Apply shadowed + cy.get('#Shadowedimg') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + // TODO: Shadowed is not in the clipboard content. + }); + + it('Apply grow.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Push grow + cy.get('#Growimg') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p font') + .should('have.attr', 'style', 'font-size: 42pt'); + }); + + it('Apply shrink.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Push shrink + cy.get('#Shrinkimg') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p font') + .should('have.attr', 'style', 'font-size: 38pt'); + }); + + it('Apply font color.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Change font color + cy.get('#FontColor') + .click(); + + cy.get('#color-picker-0-basic-color-5') + .click(); + + cy.get('#color-picker-0-tint-3') + .click(); + + cy.get('#mobile-wizard-back') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p font') + .should('have.attr', 'color', '#00ff00'); + }); + + it('Apply highlight color.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Change highlight color + cy.get('#BackColor') + .click(); + + cy.get('#color-picker-1-basic-color-5') + .click(); + + cy.get('#color-picker-1-tint-3') + .click(); + + cy.get('#mobile-wizard-back') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p font span') + .should('have.attr', 'style', 'background: #00ff00'); + }); + + it('Apply superscript.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Apply superscript + cy.get('#SuperScriptimg') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p sup') + .should('exist'); + }); + + it('Apply subscript.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Apply superscript + cy.get('#SubScriptimg') + .click(); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + cy.get('#mobile-wizard-content') + .should('not.be.visible'); + + generateTextHTML(); + + cy.get('#copy-paste-container p sub') + .should('exist'); + }); }); commit 2a82aa6db9f15b23cb9c3af993d12cc24896ddb2 Author: Tamás Zolnai <[email protected]> AuthorDate: Tue Jan 28 16:19:26 2020 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Tue Jan 28 18:01:36 2020 +0100 cypress: mobile: Add one use case to check font changes. Use the clipboard code to generate the HTML of the selected text, so we can check the font properties in the document. Change-Id: I43e5325b7fe0a9fda073c43335231e014374d6c2 diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index a65395777..c4addaab7 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -1,11 +1,12 @@ if ENABLE_CYPRESS CYPRESS_BINARY = ${abs_srcdir}/node_modules/cypress/bin/cypress +DESKTOP_USER_AGENT = "cypress" DESKTOP_TEST_FOLDER = integration_tests/desktop DESKTOP_DATA_FOLDER = ${abs_srcdir}/data/desktop/ DESKTOP_WORKDIR = ${abs_srcdir}/workdir/desktop/ -MOBILE_USER_AGENT = "cypress mobile test" +MOBILE_USER_AGENT = "cypress mobile" MOBILE_TEST_FOLDER = integration_tests/mobile MOBILE_DATA_FOLDER = ${abs_srcdir}/data/mobile/ MOBILE_WORKDIR = ${abs_srcdir}/workdir/mobile/ @@ -35,7 +36,7 @@ run-desktop: @JAILS_PATH@ node_modules @echo @echo "Open cypress with desktop tests..." @echo - $(CYPRESS_BINARY) open --config integrationFolder=$(DESKTOP_TEST_FOLDER) \ + $(CYPRESS_BINARY) open --config integrationFolder=$(DESKTOP_TEST_FOLDER),userAgent=$(DESKTOP_USER_AGENT) \ --env DATA_FOLDER=$(DESKTOP_DATA_FOLDER),WORKDIR=$(DESKTOP_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH) \ || true @pkill loolwsd || true @@ -77,7 +78,7 @@ define run_desktop_tests @echo "Running cypress desktop tests..." @echo $(CYPRESS_BINARY) run --browser $(CHROME) \ - --config integrationFolder=$(DESKTOP_TEST_FOLDER) \ + --config integrationFolder=$(DESKTOP_TEST_FOLDER),userAgent=$(DESKTOP_USER_AGENT) \ --headless \ --env DATA_FOLDER=$(DESKTOP_DATA_FOLDER),WORKDIR=$(DESKTOP_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH) \ $(if $(1), --spec=integration_tests/desktop/$(1)) \ diff --git a/cypress_test/data/mobile/simple.odt b/cypress_test/data/mobile/simple.odt new file mode 100644 index 000000000..833aa18fa Binary files /dev/null and b/cypress_test/data/mobile/simple.odt differ diff --git a/cypress_test/integration_tests/mobile/apply_font_spec.js b/cypress_test/integration_tests/mobile/apply_font_spec.js new file mode 100644 index 000000000..55f268e45 --- /dev/null +++ b/cypress_test/integration_tests/mobile/apply_font_spec.js @@ -0,0 +1,73 @@ +/* global describe it cy beforeEach require expect afterEach*/ + +var helper = require('../common/helper'); + +describe('Apply font changes.', function() { + beforeEach(function() { + helper.loadTestDoc('simple.odt', true); + + // Click on edit button + cy.get('#mobile-edit-button').click(); + + // Open mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .should('not.have.class', 'disabled') + .click(); + }); + + afterEach(function() { + cy.get('.closemobile').click(); + cy.wait(200); // wait some time to actually release the document + }); + + function generateTextHTML() { + // Open context menu + cy.get('.leaflet-marker-icon') + .then(function(marker) { + expect(marker).to.have.lengthOf(2); + var XPos = (marker[0].getBoundingClientRect().right + marker[1].getBoundingClientRect().left) / 2; + var YPos = marker[0].getBoundingClientRect().top; + cy.get('body').rightclick(XPos, YPos); + }); + + // Execute copy + cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon .context-menu-link') + .contains('Copy') + .click(); + + // Close warning about clipboard operations + cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first') + .click(); + } + + it('Apply font name.', function() { + // Select text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon'); + + // Change font name + cy.get('#fontnamecombobox') + .click(); + + cy.get('.mobile-wizard.ui-combobox-text') + .contains('Linux Libertine G') + .click(); + + cy.get('#mobile-wizard-back') + .click(); + + // Combobox entry contains the selected font name + cy.get('#fontnamecombobox .ui-header-right') + .contains('Linux Libertine G'); + + // Close mobile wizard + cy.get('#tb_actionbar_item_mobile_wizard') + .click(); + + generateTextHTML(); + + cy.get('#copy-paste-container p font') + .should('have.attr', 'face', 'Linux Libertine G'); + }); +}); + diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js index 6af48dbad..947a19a3a 100644 --- a/loleaflet/src/control/Control.Toolbar.js +++ b/loleaflet/src/control/Control.Toolbar.js @@ -11,7 +11,7 @@ var map; // has to match small screen size requirement function _inMobileMode() { - if (L.Browser.cypressMobileTest) { + if (L.Browser.mobile && L.Browser.cypressTest) { return true; } diff --git a/loleaflet/src/core/Browser.js b/loleaflet/src/core/Browser.js index b4daab8ba..607fbb77a 100644 --- a/loleaflet/src/core/Browser.js +++ b/loleaflet/src/core/Browser.js @@ -32,7 +32,7 @@ win = navigator.platform.indexOf('Win') === 0, mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1, - cypressMobileTest = ua.indexOf('cypress mobile test') !== -1, + cypressTest = ua.indexOf('cypress') !== -1, msPointer = !window.PointerEvent && window.MSPointerEvent, pointer = (window.PointerEvent && navigator.pointerEnabled && navigator.maxTouchPoints) || msPointer, @@ -137,9 +137,9 @@ // `true` for gecko-based browsers running in a mobile device. mobileGecko: mobile && gecko, - // @property cypressMobileTest: Boolean - // `true` when running cypress in mobile mode - cypressMobileTest: cypressMobileTest, + // @property cypressTest: Boolean + // `true` when the browser run by cypress + cypressTest: cypressTest, // @property touch: Boolean // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events). diff --git a/loleaflet/src/map/Clipboard.js b/loleaflet/src/map/Clipboard.js index b4d76884a..335314223 100644 --- a/loleaflet/src/map/Clipboard.js +++ b/loleaflet/src/map/Clipboard.js @@ -494,7 +494,7 @@ L.Clipboard = L.Class.extend({ }, _beforeSelectImpl: function(operation) { - if (L.Browser.isInternetExplorer && operation != 'paste') + if ((L.Browser.isInternetExplorer || L.Browser.cypressTest) && operation != 'paste') // We need populate our content into the div for // the brower to copy. this._dummyDiv.innerHTML = this._getHtmlForClipboard(); @@ -547,7 +547,8 @@ L.Clipboard = L.Class.extend({ _execOnElement: function(operation) { var serial = this._clipboardSerial; - this._resetDiv(); + if (!L.Browser.cypressTest) + this._resetDiv(); var success = false; var active = null; @@ -572,7 +573,7 @@ L.Clipboard = L.Class.extend({ var serial = this._clipboardSerial; // try a direct execCommand. - if (L.Browser.isInternetExplorer && operation != 'paste') + if ((L.Browser.isInternetExplorer || L.Browser.cypressTest) && operation != 'paste') this._beforeSelectImpl(operation); if (document.execCommand(operation) && serial !== this._clipboardSerial) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
