cypress_test/integration_tests/common/helper.js | 29 +++++ cypress_test/integration_tests/mobile/insert_object_spec.js | 54 +++++++++- cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js | 2 loleaflet/src/map/Map.js | 4 4 files changed, 79 insertions(+), 10 deletions(-)
New commits: commit f53e0303390309e993e27dccc56b4a4934d08776 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Thu Feb 6 17:17:25 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Fri Feb 7 10:09:54 2020 +0100 cypress: mobile: emulate tap and long press events. To achive a better test covarage. Now, the simple click() method is recognized as 'tap' by hummerjs. For long press we need to use low level events. I expect that we can emulate other mobile events too on a similar way. Change-Id: I5f43afafe087133e707eed6ff8a43765324d5e24 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88161 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-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 c14caf365..0e5f885a1 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -66,7 +66,7 @@ function copyTextToClipboard() { expect(marker).to.have.lengthOf(2); var XPos = (marker[0].getBoundingClientRect().right + marker[1].getBoundingClientRect().left) / 2; var YPos = marker[0].getBoundingClientRect().top - 5; - cy.get('body').rightclick(XPos, YPos); + longPressOnDocument(XPos, YPos); }); // Execute copy @@ -101,7 +101,7 @@ function copyTableToClipboard() { var XPos = startPos.right + 10; var YPos = endPos.top - 10; - cy.get('body').rightclick(XPos, YPos); + longPressOnDocument(XPos, YPos); }); // Execute copy @@ -161,9 +161,34 @@ function detectLOCoreVersion() { } } +function longPressOnDocument(posX, posY) { + cy.get('#document-container') + .then(function(items) { + expect(items).have.length(1); + + var eventOptions = { + force: true, + button: 0, + pointerType: 'mouse', + x: posX - items[0].getBoundingClientRect().left, + y: posY - items[0].getBoundingClientRect().top + }; + + cy.get('.leaflet-pane.leaflet-map-pane') + .trigger('pointerdown', eventOptions) + .trigger('pointermove', eventOptions); + + cy.wait(600); + + cy.get('.leaflet-pane.leaflet-map-pane') + .trigger('pointerup', eventOptions); + }); +} + module.exports.loadTestDoc = loadTestDoc; module.exports.selectAllMobile = selectAllMobile; module.exports.copyTextToClipboard = copyTextToClipboard; module.exports.copyTableToClipboard = copyTableToClipboard; module.exports.afterAll = afterAll; module.exports.beforeAllMobile = beforeAllMobile; +module.exports.longPressOnDocument = longPressOnDocument; diff --git a/cypress_test/integration_tests/mobile/insert_object_spec.js b/cypress_test/integration_tests/mobile/insert_object_spec.js index 3c0cebc31..e514ed5f9 100644 --- a/cypress_test/integration_tests/mobile/insert_object_spec.js +++ b/cypress_test/integration_tests/mobile/insert_object_spec.js @@ -8,11 +8,6 @@ describe('Insert objects via insertion wizard.', function() { // Click on edit button cy.get('#mobile-edit-button').click(); - - // Open insertion wizard - cy.get('#tb_actionbar_item_insertion_mobile_wizard') - .should('not.have.class', 'disabled') - .click(); }); afterEach(function() { @@ -20,6 +15,10 @@ describe('Insert objects via insertion wizard.', function() { }); it('Insert local image.', function() { + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // We check whether the entry is there cy.get('.menu-entry-with-icon') .contains('Local Image...'); @@ -27,6 +26,10 @@ describe('Insert objects via insertion wizard.', function() { }); it('Insert comment.', function() { + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + cy.get('.menu-entry-with-icon') .contains('Comment') .click(); @@ -45,6 +48,10 @@ describe('Insert objects via insertion wizard.', function() { if (Cypress.env('LO_CORE_VERSION') === 'master') return; + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Open Table submenu cy.get('.menu-entry-with-icon.flex-fullwidth') .contains('Table') @@ -76,6 +83,10 @@ describe('Insert objects via insertion wizard.', function() { if (Cypress.env('LO_CORE_VERSION') === 'master') return; + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Open Table submenu cy.get('.menu-entry-with-icon.flex-fullwidth') .contains('Table') @@ -111,6 +122,7 @@ describe('Insert objects via insertion wizard.', function() { it('Insert header.', function() { // Get the blinking cursor pos cy.get('#document-container').type('xxxx'); + var cursorOrigLeft = 0; cy.get('.blinking-cursor') .then(function(cursor) { @@ -118,6 +130,10 @@ describe('Insert objects via insertion wizard.', function() { cursorOrigLeft = cursor[0].getBoundingClientRect().left; }); + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Open header/footer submenu cy.get('.sub-menu-title') .contains('Header and Footer') @@ -155,6 +171,10 @@ describe('Insert objects via insertion wizard.', function() { cursorOrigTop = cursor[0].getBoundingClientRect().top; }); + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Open header/footer submenu cy.get('.sub-menu-title') .contains('Header and Footer') @@ -192,6 +212,10 @@ describe('Insert objects via insertion wizard.', function() { cursorOrigTop = cursor[0].getBoundingClientRect().top; }); + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Insert footnote cy.get('.menu-entry-with-icon') .contains('Footnote') @@ -217,6 +241,10 @@ describe('Insert objects via insertion wizard.', function() { cursorOrigTop = cursor[0].getBoundingClientRect().top; }); + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Insert endnote cy.get('.menu-entry-with-icon') .contains('Endnote') @@ -242,6 +270,10 @@ describe('Insert objects via insertion wizard.', function() { cursorOrigTop = cursor[0].getBoundingClientRect().top; }); + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Insert endnote cy.get('.menu-entry-with-icon') .contains('Page Break') @@ -267,6 +299,10 @@ describe('Insert objects via insertion wizard.', function() { cursorOrigTop = cursor[0].getBoundingClientRect().top; }); + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Do insertion cy.get('.menu-entry-with-icon') .contains('Column Break') @@ -283,6 +319,10 @@ describe('Insert objects via insertion wizard.', function() { }); it('Insert hyperlink.', function() { + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Open hyperlink dialog cy.get('.menu-entry-with-icon') .contains('Hyperlink...') @@ -298,6 +338,10 @@ describe('Insert objects via insertion wizard.', function() { }); it('Insert shape.', function() { + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + // Do insertion cy.get('.menu-entry-with-icon') .contains('Shape') diff --git a/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js b/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js index 5ea03ed55..e4074e51c 100644 --- a/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js +++ b/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js @@ -104,7 +104,7 @@ describe('Mobile wizard state tests', function() { .should('have.class', 'checked'); // Open context wizard by right click on document - cy.get('#document-container').rightclick(); + helper.longPressOnDocument(40, 40); cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon') .contains('Paste'); diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index e7a75f205..f06298aaa 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -128,7 +128,7 @@ L.Map = L.Evented.extend({ this.addHandler('keyboard', L.Map.Keyboard); this.addHandler('dragging', L.Map.Drag); - if (L.Browser.touch && !L.Browser.pointer) { + if ((L.Browser.touch && !L.Browser.pointer) || (L.Browser.cypressTest && L.Browser.mobile)) { this.dragging.disable(); this.options.inertia = false; this.dragging._draggable._manualDrag = true; @@ -909,7 +909,7 @@ L.Map = L.Evented.extend({ // accept key input, and show the virtual keyboard. focus: function (acceptInput) { this._textInput.focus(); - if (window.mode.isMobile() && acceptInput !== true && !L.Browser.cypressTest) + if (window.mode.isMobile() && acceptInput !== true) this.blur(); }, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits