cypress_test/Makefile.am | 1 cypress_test/data/mobile/impress/spellchecking.odp |binary cypress_test/integration_tests/common/helper.js | 5 cypress_test/integration_tests/common/impress.js | 35 ++ cypress_test/integration_tests/mobile/impress/spellchecking_spec.js | 118 ++++++++++ 5 files changed, 156 insertions(+), 3 deletions(-)
New commits: commit 3b1ca68a212329111938189bc3df90a5c8996c57 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Wed Mar 18 13:18:59 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Thu Mar 19 14:48:42 2020 +0100 cypress: mobile: add spellchecking tests for impress. Change-Id: I7b3909c79ca1fad27c5e3754a36f38f659e467e1 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90712 Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index 603ec9269..394627af7 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -36,6 +36,7 @@ MOBILE_TEST_FILES= \ calc/insertion_wizard_spec.js \ calc/spellchecking_spec.js \ impress/impress_focus_spec.js \ + impress/spellchecking_spec.js \ writer/apply_font_spec.js \ writer/apply_paragraph_properties_spec.js \ writer/bottom_toolbar_spec.js \ diff --git a/cypress_test/data/mobile/impress/spellchecking.odp b/cypress_test/data/mobile/impress/spellchecking.odp new file mode 100644 index 000000000..af6096b7d Binary files /dev/null and b/cypress_test/data/mobile/impress/spellchecking.odp differ diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index dea956fa5..02a4cbdda 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -92,8 +92,9 @@ function assertCursorAndFocus() { } // Select all text via CTRL+A shortcut. -function selectAllText() { - assertCursorAndFocus(); +function selectAllText(assertFocus = true) { + if (assertFocus) + assertCursorAndFocus(); cy.log('Select all text'); diff --git a/cypress_test/integration_tests/common/impress.js b/cypress_test/integration_tests/common/impress.js index 6e1e59c55..00064c096 100644 --- a/cypress_test/integration_tests/common/impress.js +++ b/cypress_test/integration_tests/common/impress.js @@ -1,4 +1,4 @@ -/* global cy require */ +/* global cy require expect*/ var helper = require('./helper'); @@ -61,6 +61,39 @@ function typeTextAndVerify(text, expected) { helper.expectTextForClipboard(expected); } +function copyShapeContentToClipboard() { + // TODO: this fails on assertHaveKeyboardInput() + // assertInTextEditMode(); + + helper.selectAllText(false); + + // 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 - 5; + helper.longPressOnDocument(XPos, YPos); + }); + + cy.get('#mobile-wizard') + .should('be.visible'); + + // Execute copy + cy.get('.ui-header.level-0.mobile-wizard.ui-widget .context-menu-link .menu-entry-with-icon', {timeout : 10000}) + .contains('Copy') + .click(); + + // Close warning about clipboard operations + cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first') + .click(); + + // Wait until it's closed + cy.get('.vex-overlay') + .should('not.exist'); +} + module.exports.assertNotInTextEditMode = assertNotInTextEditMode; module.exports.assertInTextEditMode = assertInTextEditMode; module.exports.typeTextAndVerify = typeTextAndVerify; +module.exports.copyShapeContentToClipboard = copyShapeContentToClipboard; diff --git a/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js b/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js new file mode 100644 index 000000000..8831e3555 --- /dev/null +++ b/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js @@ -0,0 +1,118 @@ +/* global describe it cy beforeEach require afterEach expect*/ + +var helper = require('../../common/helper'); +var impress = require('../../common/impress'); + +describe('Spell checking menu.', function() { + beforeEach(function() { + helper.beforeAllMobile('spellchecking.odp', 'impress'); + + // Click on edit button + helper.enableEditingMobile(); + }); + + afterEach(function() { + helper.afterAll('spellchecking.odp'); + }); + + function openContextMenu() { + // Click on the center of the slide to step into text edit mode + cy.get('#document-container') + .then(function(items) { + expect(items).to.have.length(1); + var XPos = (items[0].getBoundingClientRect().left + items[0].getBoundingClientRect().right) / 2; + var YPos = (items[0].getBoundingClientRect().top + items[0].getBoundingClientRect().bottom) / 2; + cy.get('body') + .dblclick(XPos, YPos); + }); + + cy.get('.leaflet-cursor.blinking-cursor') + .should('exist'); + + helper.selectAllText(false); + + // Open context menu + cy.get('.leaflet-marker-icon') + .then(function(markers) { + expect(markers.length).to.have.greaterThan(1); + for (var i = 0; i < markers.length; i++) { + if (markers[i].classList.contains('leaflet-selection-marker-start')) { + var startPos = markers[i].getBoundingClientRect(); + } else if (markers[i].classList.contains('leaflet-selection-marker-end')) { + var endPos = markers[i].getBoundingClientRect(); + } + } + + // Remove selection + cy.get('#document-container') + .type('{leftarrow}'); + cy.get('.leaflet-marker-icon') + .should('not.exist'); + + var XPos = startPos.right + 10; + var YPos = endPos.top - 10; + helper.longPressOnDocument(XPos, YPos); + }); + + cy.get('#mobile-wizard-content') + .should('be.visible'); + } + + it('Apply suggestion.', function() { + openContextMenu(); + + cy.get('.context-menu-link') + .contains('hello') + .click(); + + impress.copyShapeContentToClipboard(); + + cy.get('#copy-paste-container pre') + .then(function(item) { + expect(item).to.have.lengthOf(1); + expect(item[0].innerText).to.have.string('hello'); + }); + }); + + it('Ignore all.', function() { + openContextMenu(); + + cy.get('.context-menu-link') + .contains('Ignore All') + .click(); + + openContextMenu(); + + // We don't get the spell check context menu any more + cy.get('.context-menu-link') + .contains('Paste'); + }); + + it('Apply language for word.', function() { + openContextMenu(); + + cy.get('.context-menu-link') + .contains('Word is Finnish') + .click(); + + openContextMenu(); + + // We don't get the spell check context menu any more + cy.get('.context-menu-link') + .contains('Paste'); + }); + + it('Apply language for paragraph.', function() { + openContextMenu(); + + cy.get('.context-menu-link') + .contains('Paragraph is Finnish') + .click(); + + openContextMenu(); + + // We don't get the spell check context menu any more + cy.get('.context-menu-link') + .contains('Paste'); + }); +}); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits