[Libreoffice-commits] online.git: cypress_test/integration_tests

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 10 20:43:17 UTC 2020


 cypress_test/integration_tests/mobile/focus_spec.js |  240 +++++++++++++++++---
 1 file changed, 207 insertions(+), 33 deletions(-)

New commits:
commit fe3d3e69988fd37831a12eab993247cdfc10dedc
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Feb 10 16:08:31 2020 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Mon Feb 10 21:42:54 2020 +0100

    cypress: mobile: Add some focus related tests (writer).
    
    Change-Id: Ibe2ce81cfea0c0d4bf9af584c54e5ee8c1e356f1
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88381
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/integration_tests/mobile/focus_spec.js b/cypress_test/integration_tests/mobile/focus_spec.js
index e411b94c8..badb1e0ad 100644
--- a/cypress_test/integration_tests/mobile/focus_spec.js
+++ b/cypress_test/integration_tests/mobile/focus_spec.js
@@ -1,4 +1,4 @@
-/* global describe it cy beforeEach require afterEach*/
+/* global describe it cy beforeEach require afterEach expect*/
 
 var helper = require('../common/helper');
 
@@ -11,17 +11,27 @@ describe('Focus tests', function() {
 		helper.afterAll();
 	});
 
-	it('Focus after document fully loaded.', function() {
-		// The document body should have the focus
-		cy.document().its('activeElement.tagName')
-			.should('be.eq', 'BODY');
-	});
+	it('Basic document focus.', function() {
+		// Click on edit button
+		cy.get('#mobile-edit-button').click();
+
+		cy.get('#tb_actionbar_item_mobile_wizard')
+			.should('not.have.class', 'disabled');
 
-	it('Focus after closing a dialog.', function() {
-		// The document body has the focus first
+		// Body has the focus -> can't type in the document
 		cy.document().its('activeElement.tagName')
 			.should('be.eq', 'BODY');
 
+		// Click in the document
+		cy.get('#document-container')
+			.click();
+
+		// Clipboard has the focus -> can type in the document
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'clipboard');
+	});
+
+	it('Focus with a vex dialog.', function() {
 		// Click on edit button
 		cy.get('#mobile-edit-button').click();
 
@@ -30,7 +40,8 @@ describe('Focus tests', function() {
 			.should('not.have.class', 'disabled')
 			.click();
 
-		cy.get('.loleaflet-annotation-table').should('be.visible');
+		cy.get('.loleaflet-annotation-table')
+			.should('be.visible');
 
 		// The dialog grabs the focus
 		cy.document().its('activeElement.className')
@@ -40,47 +51,78 @@ describe('Focus tests', function() {
 		cy.contains('Cancel').click();
 		cy.get('.loleaflet-annotation-table').should('be.not.visible');
 
-		// The document should have the focus again
+		// Body should have the focus again (no focus on document)
 		cy.document().its('activeElement.tagName')
 			.should('be.eq', 'BODY');
 	});
 
-	it('Focus when using insertion mobile wizard.', function() {
-		// The document body has the focus first
+	it('Focus with opened mobile wizard.', function() {
+		// Click on edit button
+		cy.get('#mobile-edit-button').click();
+
+		// Click in the document
+		cy.get('#document-container')
+			.click();
+
+		// Clipboard has the focus -> can type in the document
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'clipboard');
+
+		// Open mobile wizard
+		cy.get('#tb_actionbar_item_mobile_wizard')
+			.should('not.have.class', 'disabled')
+			.click();
+
+		cy.get('#mobile-wizard-content')
+			.should('not.be.empty');
+
+		// Body should have the focus (no focus on document)
+		cy.document().its('activeElement.tagName')
+			.should('be.eq', 'BODY');
+
+		// Close mobile wizard
+		cy.get('#tb_actionbar_item_mobile_wizard')
+			.click();
+
+		// No focus
 		cy.document().its('activeElement.tagName')
 			.should('be.eq', 'BODY');
+	});
 
+	it('Focus inside mobile wizard.', function() {
 		// Click on edit button
 		cy.get('#mobile-edit-button').click();
 
-		// Open insertion mobile wizard
-		cy.get('#tb_actionbar_item_insertion_mobile_wizard')
+		// Open mobile wizard
+		cy.get('#tb_actionbar_item_mobile_wizard')
 			.should('not.have.class', 'disabled')
 			.click();
 
 		cy.get('#mobile-wizard-content')
 			.should('not.be.empty');
 
-		// This fails here: the document still has the focus
-		// The wizard changes the focus
-		//cy.document().its('activeElement.className')
-		//	.should('be.eq', 'clipboard');
+		// Open paragraph properties
+		cy.get('#Paragraph')
+			.click();
 
-		// Close the mobile wizard
-		cy.get('#tb_actionbar_item_insertion_mobile_wizard').click();
-		cy.get('#mobile-wizard').should('not.be.visible');
+		cy.get('#aboveparaspacing .spinfield')
+			.should('have.attr', 'value', '0.0')
+			.click();
 
-		// This fails here: the focus is not on the document body
-		// The document should have the focus again
-		//cy.document().its('activeElement.tagName')
-		//	.should('be.eq', 'BODY');
-	});
+		// The spinfield should have the focus now.
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'spinfield');
 
-	it('Focus after insertion.', function() {
-		// The document body has the focus first
+		// Close mobile wizard
+		cy.get('#tb_actionbar_item_mobile_wizard')
+			.click();
+
+		// No focus
 		cy.document().its('activeElement.tagName')
 			.should('be.eq', 'BODY');
+	});
 
+	it('Focus after insertion.', function() {
 		// Click on edit button
 		cy.get('#mobile-edit-button').click();
 
@@ -100,11 +142,143 @@ describe('Focus tests', function() {
 		// Insert a field
 		cy.get('.ui-header.level-1.mobile-wizard.ui-widget .menu-entry-with-icon')
 			.contains('Page Number').click();
-		cy.get('#mobile-wizard').should('not.be.visible');
 
-		// This fails here: the focus is not on the document body
-		// The document should have the focus again
-		//cy.document().its('activeElement.tagName')
-		//	.should('be.eq', 'BODY');
+		cy.get('#mobile-wizard')
+			.should('not.be.visible');
+
+		// After insertion the document gets the focus
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'clipboard');
+	});
+
+	it('Shape related focus.', function() {
+		// Click on edit button
+		cy.get('#mobile-edit-button').click();
+
+		// Open insertion mobile wizard
+		cy.get('#tb_actionbar_item_insertion_mobile_wizard')
+			.should('not.have.class', 'disabled')
+			.click();
+
+		cy.get('#mobile-wizard-content')
+			.should('not.be.empty');
+
+		// Do insertion
+		cy.get('.menu-entry-with-icon')
+			.contains('Shape')
+			.click();
+
+		cy.get('.col.w2ui-icon.basicshapes_rectangle').
+			click();
+
+		// Check that the shape is there
+		cy.get('.leaflet-pane.leaflet-overlay-pane svg g')
+			.should('exist');
+
+		// One tap on the shape
+		cy.get('.leaflet-pane.leaflet-overlay-pane svg')
+			.then(function(svg) {
+				expect(svg[0].getBBox().width).to.be.greaterThan(0);
+				expect(svg[0].getBBox().height).to.be.greaterThan(0);
+				var posX = svg[0].getBBox().x + svg[0].getBBox().width / 2;
+				var posY = svg[0].getBBox().y + svg[0].getBBox().height / 2;
+				cy.get('#document-container')
+					.click(posX, posY);
+			});
+
+		// Document grabs the focus
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'clipboard');
+
+		// Double tap on the shape
+		cy.get('.leaflet-pane.leaflet-overlay-pane svg')
+			.then(function(svg) {
+				expect(svg[0].getBBox().width).to.be.greaterThan(0);
+				expect(svg[0].getBBox().height).to.be.greaterThan(0);
+				var posX = svg[0].getBBox().x + svg[0].getBBox().width / 2;
+				var posY = svg[0].getBBox().y + svg[0].getBBox().height / 2;
+				cy.get('#document-container')
+					.dblclick(posX, posY);
+			});
+
+		// Document still has the focus
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'clipboard');
+	});
+
+	it('Focus with hamburger menu.', function() {
+		// Click on edit button
+		cy.get('#mobile-edit-button').click();
+
+		// Click in the document
+		cy.get('#document-container')
+			.click();
+
+		// Clipboard has the focus -> can type in the document
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'clipboard');
+
+		// Open hamburger menu
+		cy.get('#toolbar-hamburger')
+			.click();
+
+		// No focus
+		cy.document().its('activeElement.tagName')
+			.should('be.eq', 'BODY');
+
+		// Close hamburger menu
+		cy.get('#toolbar-hamburger')
+			.click();
+
+		// No focus
+		cy.document().its('activeElement.tagName')
+			.should('be.eq', 'BODY');
+	});
+
+	it('Focus after applying font change.', function() {
+		// Click on edit button
+		cy.get('#mobile-edit-button').click();
+
+		// Click in the document
+		cy.get('#document-container')
+			.click();
+
+		// Clipboard has the focus -> can type in the document
+		cy.document().its('activeElement.className')
+			.should('be.eq', 'clipboard');
+
+		// Open mobile wizard
+		cy.get('#tb_actionbar_item_mobile_wizard')
+			.should('not.have.class', 'disabled')
+			.click();
+
+		cy.get('#mobile-wizard-content')
+			.should('not.be.empty');
+
+		// No focus
+		cy.document().its('activeElement.tagName')
+			.should('be.eq', 'BODY');
+
+		// Apply bold
+		cy.get('#Bold')
+			.click();
+
+		cy.get('#Boldimg')
+			.should('have.class', 'selected');
+
+		// No focus
+		cy.document().its('activeElement.tagName')
+			.should('be.eq', 'BODY');
+
+		// Close mobile wizard
+		cy.get('#tb_actionbar_item_mobile_wizard')
+			.click();
+
+		cy.get('#tb_actionbar_item_mobile_wizard table')
+			.should('not.have.class', 'checked');
+
+		// No focus
+		cy.document().its('activeElement.tagName')
+			.should('be.eq', 'BODY');
 	});
 });


More information about the Libreoffice-commits mailing list