cypress_test/Makefile.am                                  |    2 -
 cypress_test/data/mobile/calc/focus.ods                   |binary
 cypress_test/integration_tests/mobile/calc/calc_helper.js |   24 ++++++++++++
 cypress_test/integration_tests/mobile/calc/focus_spec.js  |   27 ++++++++------
 4 files changed, 41 insertions(+), 12 deletions(-)

New commits:
commit 90c57174663f15dd4c300a069dc7116630a927d0
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Mon Mar 9 15:08:33 2020 +0100
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Mon Mar 9 15:39:40 2020 +0100

    cypress: mobile: avoid hard coded coordinates for calc focus tests.
    
    Change-Id: I9da74fcd090371cbea5b3a8c8836bf9236f709b3
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90224
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>

diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am
index 5e7c13c7e..e4616f3dc 100644
--- a/cypress_test/Makefile.am
+++ b/cypress_test/Makefile.am
@@ -31,7 +31,7 @@ export DISPLAY=$(if 
$(HEADLESS_BUILD),:$(DISPLAY_NUMBER),$(shell echo $$DISPLAY)
 
 if HAVE_LO_PATH
 MOBILE_TEST_FILES= \
-       calc/calc_focus_spec.js \
+       calc/focus_spec.js \
        impress/impress_focus_spec.js \
        writer/apply_font_spec.js \
        writer/apply_paragraph_properties_spec.js \
diff --git a/cypress_test/data/mobile/calc/focus.ods 
b/cypress_test/data/mobile/calc/focus.ods
index 98c5d3a36..ab2f20975 100644
Binary files a/cypress_test/data/mobile/calc/focus.ods and 
b/cypress_test/data/mobile/calc/focus.ods differ
diff --git a/cypress_test/integration_tests/mobile/calc/calc_helper.js 
b/cypress_test/integration_tests/mobile/calc/calc_helper.js
new file mode 100644
index 000000000..5839efb01
--- /dev/null
+++ b/cypress_test/integration_tests/mobile/calc/calc_helper.js
@@ -0,0 +1,24 @@
+/* global cy expect*/
+
+function clickOnFirstCell() {
+       // Enable editing if it's in read-only mode
+       cy.get('#mobile-edit-button')
+               .then(function(button) {
+                       if (button.css('display') !== 'none') {
+                               cy.get('#mobile-edit-button')
+                                       .click();
+                       }
+               });
+
+       // Use the tile's edge to find the first cell's position
+       cy.get('.leaflet-tile-container')
+               .then(function(items) {
+                       expect(items).to.have.lengthOf(1);
+                       var XPos = items[0].getBoundingClientRect().right + 10;
+                       var YPos = items[0].getBoundingClientRect().top + 10;
+                       cy.get('body')
+                               .click(XPos, YPos);
+               });
+}
+
+module.exports.clickOnFirstCell = clickOnFirstCell;
diff --git a/cypress_test/integration_tests/mobile/calc/calc_focus_spec.js 
b/cypress_test/integration_tests/mobile/calc/focus_spec.js
similarity index 66%
rename from cypress_test/integration_tests/mobile/calc/calc_focus_spec.js
rename to cypress_test/integration_tests/mobile/calc/focus_spec.js
index 8d5cada69..801b423f8 100644
--- a/cypress_test/integration_tests/mobile/calc/calc_focus_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/focus_spec.js
@@ -1,6 +1,7 @@
-/* global describe it cy beforeEach require afterEach*/
+/* global describe it cy beforeEach require afterEach expect*/
 
 var helper = require('../../common/helper');
+var calcHelper = require('./calc_helper');
 
 describe('Calc focus tests', function() {
        beforeEach(function() {
@@ -23,18 +24,24 @@ describe('Calc focus tests', function() {
                        .should('be.eq', 'BODY');
 
                // One tap on an other cell -> no focus on the document
-               cy.get('#document-container')
-                       .click(120, 120);
+               calcHelper.clickOnFirstCell();
 
-               cy.get('.leaflet-marker-icon.spreadsheet-cell-resize-marker');
+               cy.get('.leaflet-marker-icon.spreadsheet-cell-resize-marker')
+                       .should('be.visible');
 
                // No focus
                cy.document().its('activeElement.tagName')
                        .should('be.eq', 'BODY');
 
-               // Double tap on a cell gives the focus to the document
-               cy.get('#document-container')
-                       .dblclick(20, 20);
+               // Double tap on another cell gives the focus to the document
+               cy.get('.spreadsheet-cell-resize-marker')
+                       .then(function(items) {
+                               expect(items).to.have.lengthOf(2);
+                               var XPos = 
Math.max(items[0].getBoundingClientRect().right, 
items[1].getBoundingClientRect().right) + 10;
+                               var YPos = 
Math.max(items[0].getBoundingClientRect().top, 
items[1].getBoundingClientRect().top) - 10;
+                               cy.get('body')
+                                       .dblclick(XPos, YPos);
+                       });
 
                // Document has the focus
                cy.document().its('activeElement.className')
@@ -53,8 +60,7 @@ describe('Calc focus tests', function() {
                        .should('be.eq', 'BODY');
 
                // One tap on a cell -> no document focus
-               cy.get('#document-container')
-                       .click();
+               calcHelper.clickOnFirstCell();
 
                cy.get('.leaflet-marker-icon.spreadsheet-cell-resize-marker');
 
@@ -63,8 +69,7 @@ describe('Calc focus tests', function() {
                        .should('be.eq', 'BODY');
 
                // Second tap on the same cell
-               cy.get('#document-container')
-                       .click();
+               calcHelper.clickOnFirstCell();
 
                // Document has the focus
                cy.document().its('activeElement.className')
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to