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

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Mon May 18 16:41:55 UTC 2020


 cypress_test/integration_tests/common/helper.js                  |   17 +
 cypress_test/integration_tests/desktop/writer/form_field_spec.js |   89 ++++++++++
 loleaflet/src/layer/FormFieldButtonLayer.js                      |    9 -
 3 files changed, 112 insertions(+), 3 deletions(-)

New commits:
commit 18325d8889f716ac5c5b243dfb27a43761ff49ef
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon May 18 13:16:15 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Mon May 18 18:41:48 2020 +0200

    MSForms: make list items's font size relative to the button size.
    
    Change-Id: I05149e704ca248584ba190f2e637e69082ca33fa
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94420
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js
index 8d68cfb38..b2053c4a7 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -188,6 +188,22 @@ function initAliasToNegative(aliasName) {
 	cy.log('Initializing alias to a negative value - end.');
 }
 
+function initAliasToEmptyString(aliasName) {
+	cy.log('Initializing alias to empty string - start.');
+	cy.log('Param - aliasName: ' + aliasName);
+
+	// Do an empty slice to generate empty string
+	cy.get('#copy-paste-container')
+		.invoke('css', 'display')
+		.invoke('slice', '0', '0')
+		.as(aliasName);
+
+	cy.get('@' + aliasName)
+		.should('be.equal', '');
+
+	cy.log('Initializing alias to empty string - end.');
+}
+
 function isCalc() {
 	return Cypress.$('.spreadsheet-header-columns').length != 0;
 }
@@ -221,6 +237,7 @@ module.exports.clearAllText = clearAllText;
 module.exports.expectTextForClipboard = expectTextForClipboard;
 module.exports.afterAll = afterAll;
 module.exports.initAliasToNegative = initAliasToNegative;
+module.exports.initAliasToEmptyString = initAliasToEmptyString;
 module.exports.isCalc = isCalc;
 module.exports.isImpress = isImpress;
 module.exports.isWriter = isWriter;
diff --git a/cypress_test/integration_tests/desktop/writer/form_field_spec.js b/cypress_test/integration_tests/desktop/writer/form_field_spec.js
index 1d2528472..6aba35888 100644
--- a/cypress_test/integration_tests/desktop/writer/form_field_spec.js
+++ b/cypress_test/integration_tests/desktop/writer/form_field_spec.js
@@ -315,5 +315,75 @@ describe('Form field button tests.', function() {
 		cy.contains('#tb_actionbar_item_zoom', '120')
 			.should('exist');
 	});
+
+	it.skip('Test dynamic font size.', function() {
+		helper.loadTestDoc('form_field.odt', 'writer');
+
+		// Move the cursor next to the form field
+		cy.get('textarea.clipboard')
+			.type('{rightArrow}');
+
+		buttonShouldExist();
+
+		// Get the initial font size from the style
+		helper.initAliasToEmptyString('prevFontSize');
+
+		cy.get('.drop-down-field-list-item')
+			.invoke('css', 'font-size')
+			.as('prevFontSize');
+
+		cy.get('@prevFontSize')
+			.should('not.be.equal', '');
+
+		// Do a zoom in
+		cy.get('#tb_actionbar_item_zoom')
+			.click();
+
+		cy.contains('.menu-text', '280')
+			.click();
+
+		cy.contains('#tb_actionbar_item_zoom', '280')
+			.should('exist');
+
+		buttonShouldExist();
+
+		// Check that the font size was changed
+		cy.get('@prevFontSize')
+			.then(function(prevFontSize) {
+				cy.get('.drop-down-field-list-item')
+					.should(function(items) {
+						var prevSize = parseInt(prevFontSize, 10);
+						var currentSize = parseInt(items.css('font-size'), 10);
+						expect(currentSize).to.be.greaterThan(prevSize);
+					});
+			});
+
+		cy.get('.drop-down-field-list-item')
+			.invoke('css', 'font-size')
+			.as('prevFontSize');
+
+		// Do a zoom out
+		cy.get('#tb_actionbar_item_zoom')
+			.click();
+
+		cy.contains('.menu-text', '85')
+			.click();
+
+		cy.contains('#tb_actionbar_item_zoom', '85')
+			.should('exist');
+
+		buttonShouldExist();
+
+		// Check that the font size was changed
+		cy.get('@prevFontSize')
+			.then(function(prevFontSize) {
+				cy.get('.drop-down-field-list-item')
+					.should(function(items) {
+						var prevSize = parseInt(prevFontSize, 10);
+						var currentSize = parseInt(items.css('font-size'), 10);
+						expect(currentSize).to.be.lessThan(prevSize);
+					});
+			});
+	});
 });
 
diff --git a/loleaflet/src/layer/FormFieldButtonLayer.js b/loleaflet/src/layer/FormFieldButtonLayer.js
index 42f4d5ff8..9db313c36 100644
--- a/loleaflet/src/layer/FormFieldButtonLayer.js
+++ b/loleaflet/src/layer/FormFieldButtonLayer.js
@@ -109,17 +109,18 @@ L.FormFieldButton = L.Layer.extend({
 		var selected = parseInt(this._buttonData.params.selected);
 
 		for (var i = 0; i < itemList.length; ++i) {
-			this._buildListItem(dropDownList, itemList[i], i === selected);
+			this._buildListItem(dropDownList, itemList[i], frameHeight, i === selected);
 		}
 
 		if (this._buttonData.params.items.length === 0) {
-			this._buildListItem(dropDownList, this._buttonData.params.placeholderText, false);
+			this._buildListItem(dropDownList, this._buttonData.params.placeholderText, frameHeight, false);
 		}
 	},
 
-	_buildListItem: function(parent, text, selected) {
+	_buildListItem: function(parent, text, frameHeight, selected) {
 		var option = L.DomUtil.create('div', 'drop-down-field-list-item', parent);
 		option.innerHTML = text;
+		option.style.fontSize = frameHeight * 0.7 + 'px';
 
 		option.addEventListener('click', this._onListItemSelect);
 		option.map = this.map;
commit 43d1567b9d53e5841621b283415a768aa75ec747
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon May 18 12:41:08 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Mon May 18 18:41:37 2020 +0200

    MSForms: stop listening on zoom events after button is removed.
    
    Change-Id: I96e484b5fa7309b7d1a6f0a3ec4269f21bb93496
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94410
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/integration_tests/desktop/writer/form_field_spec.js b/cypress_test/integration_tests/desktop/writer/form_field_spec.js
index a1554fa3b..1d2528472 100644
--- a/cypress_test/integration_tests/desktop/writer/form_field_spec.js
+++ b/cypress_test/integration_tests/desktop/writer/form_field_spec.js
@@ -295,6 +295,25 @@ describe('Form field button tests.', function() {
 			.should('exist');
 
 		buttonShouldExist();
+
+		// Now check that event listener does not do
+		// anything stupid after the button is removed.
+
+		// Move the cursor away from the field
+		cy.get('textarea.clipboard')
+			.type('{leftArrow}');
+
+		buttonShouldNotExist();
+
+		// Do a zoom in again
+		cy.get('#tb_actionbar_item_zoom')
+			.click();
+
+		cy.contains('.menu-text', '120')
+			.click();
+
+		cy.contains('#tb_actionbar_item_zoom', '120')
+			.should('exist');
 	});
 });
 
diff --git a/loleaflet/src/layer/FormFieldButtonLayer.js b/loleaflet/src/layer/FormFieldButtonLayer.js
index a8c268872..42f4d5ff8 100644
--- a/loleaflet/src/layer/FormFieldButtonLayer.js
+++ b/loleaflet/src/layer/FormFieldButtonLayer.js
@@ -135,6 +135,8 @@ L.FormFieldButton = L.Layer.extend({
 
 	onRemove: function () {
 		this._clearButton();
+		this.map.off('zoomstart', this._onZoomStart, this);
+		this.map.off('zoomend', this._onZoomEnd, this);
 	},
 
 	_onClickDropDown: function(event) {


More information about the Libreoffice-commits mailing list