[Libreoffice-commits] online.git: 3 commits - loleaflet/spec loleaflet/src

Mihai Varga mihai.varga at collabora.com
Fri Sep 11 03:22:09 PDT 2015


 loleaflet/spec/loleaflet/loleafletSpec.js |   64 ++++++++++++++----------------
 loleaflet/src/control/Toolbar.js          |    4 -
 loleaflet/src/layer/tile/GridLayer.js     |    4 -
 3 files changed, 34 insertions(+), 38 deletions(-)

New commits:
commit 5c99a3f132dc6eac247ac268614595ca54702416
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Sep 11 13:21:37 2015 +0300

    loleaflet: fixed the unit test

diff --git a/loleaflet/spec/loleaflet/loleafletSpec.js b/loleaflet/spec/loleaflet/loleafletSpec.js
index 692d656..f575693 100644
--- a/loleaflet/spec/loleaflet/loleafletSpec.js
+++ b/loleaflet/spec/loleaflet/loleafletSpec.js
@@ -23,6 +23,11 @@ describe('TileBench', function () {
 			edit: false,
 			readOnly: false
 		});
+
+		map.on('scrollto', function (e) {
+			map.scrollTop(e.y);
+			map.scrollLeft(e.x);
+		});
 	});
 
 	afterEach(function () {
@@ -66,16 +71,7 @@ describe('TileBench', function () {
 			map.setPermission('view');
 		});
 
-		it('Place the coursor by clicking', function (done) {
-			map.on('statusindicator', function (e) {
-				expect(e).to.have.property('statusType');
-				if (e.statusType === 'setvalue') {
-					expect(e).to.have.property('value');
-				}
-				if (e.statusType === 'finish') {
-					done();
-				}
-			});
+		it('Place the coursor by clicking', function () {
 			map._docLayer._postMouseEvent('buttondown', 2500, 3515, 1);
 			map._docLayer._postMouseEvent('buttonup', 2500, 3515, 1);
 			map.setPermission('edit');
@@ -90,31 +86,10 @@ describe('TileBench', function () {
 			map.toggleCommandState('Bold')
 		});
 
-		it('Search backwards', function (done) {
-			map.once('scrollto', function (e) {
-				//expect(e.x).to.be(0);
-				//expect(e.y).to.be.above(0);
-				//expect(e.y).to.be(2321);
-				done();
-			});
-			map.search('document', true);
-		});
-
-		it('Search not found', function (done) {
-			map.once('search', function (e) {
-				expect(e.originalPhrase).to.be('something-not-found');
-				expect(e.count).to.be(0);
-				done();
-			});
-			map.search('something-not-found');
-		});
-
-
 		it('Get document size', function () {
 			var size = map.getDocSize();
-			// TODO assert
-			//expect(size.x).to.be();
-			//expect(size.y).to.be();
+			expect(Math.round(size.x)).to.be(1064);
+			expect(Math.round(size.y)).to.be(2946);
 		});
 
 		it('Get document type', function () {
@@ -127,15 +102,36 @@ describe('TileBench', function () {
 			expect(map.getCurrentPageNumber()).to.be(0);
 		});
 
-		it('Go to the next page', function () {
+		it('Go to the next page', function (done) {
 			map.once('pagenumberchanged', function (e) {
 				expect(e.currentPage).to.be(1);
 				expect(e.pages).to.be(2);
 				expect(e.docType).to.be('text');
 				done();
 			});
+			map.goToPage(1);
+		});
+
+		it('Search backwards', function (done) {
+			map.once('scrollto', function (e) {
+				expect(e.x).to.be(0);
+				expect(e.y).to.be(174);
+				//expect(e.y).to.be(2321);
+				done();
+			});
+			map.search('document', true);
 		});
 
+		it('Search not found', function (done) {
+			map.once('search', function (e) {
+				expect(e.originalPhrase).to.be('something-not-found');
+				expect(e.count).to.be(0);
+				done();
+			});
+			map.search('something-not-found');
+		});
+
+
 		it('Scroll to the top', function (done) {
 			map.once('updatescrolloffset', function (e) {
 				expect(e.x).to.be(0);
commit 61531c88cea3e40ef1a78d9980bb5b3a814192c0
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Sep 11 13:20:39 2015 +0300

    loleaflet: request toolbar items in this order
    
    The other way around causes LOK to crash
    TODO - this needs fixing

diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 16790d4..9a1bbfa 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -5,8 +5,8 @@ L.Map.include({
 
 	// a mapping of uno commands to more readable toolbar items
 	unoToolbarCommands: [
-		'.uno:CharFontName',
-		'.uno:StyleApply'
+		'.uno:StyleApply',
+		'.uno:CharFontName'
 	],
 
 	applyFont: function (fontName) {
commit 41fd4783ad270c3ccb896d811ac347b5a404ff6e
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Sep 11 13:20:29 2015 +0300

    loleaflet: round the scroll offset

diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 30cdcb9..9843c24 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -390,8 +390,8 @@ L.GridLayer = L.Layer.extend({
 	_updateScrollOffset: function () {
 		var centerPixel = this._map.project(this._map.getCenter());
 		var newScrollPos = centerPixel.subtract(this._map.getSize().divideBy(2));
-		var x = newScrollPos.x < 0 ? 0 : newScrollPos.x;
-		var y = newScrollPos.y < 0 ? 0 : newScrollPos.y;
+		var x = Math.round(newScrollPos.x < 0 ? 0 : newScrollPos.x);
+		var y = Math.round(newScrollPos.y < 0 ? 0 : newScrollPos.y);
 		this._map.fire('updatescrolloffset', {x: x, y: y});
 	},
 


More information about the Libreoffice-commits mailing list