loleaflet/spec/tilebench.html             |   52 ++++++++++++++++
 loleaflet/spec/tilebench/TileBenchSpec.js |   93 ++++++++++++++++++++++++++++++
 loleaflet/src/layer/tile/GridLayer.js     |    1 
 loleaflet/src/layer/tile/TileLayer.js     |    8 ++
 4 files changed, 154 insertions(+)

New commits:
commit 16091399081d64a8d90343e4359f6fb96e1ea109
Author: Mihai Varga <[email protected]>
Date:   Thu Jul 23 16:55:38 2015 +0300

    loleaflet: removed console.log call

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 3b54132..24246c9 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -391,7 +391,6 @@ L.TileLayer = L.GridLayer.extend({
                                if (!tile.loaded) {
                                        this._emptyTilesCount -= 1;
                                        if (this._emptyTilesCount === 0) {
-                                               console.log('alltilesloaded');
                                                
this._map.fire('alltilesloaded');
                                        }
                                }
commit 5f368efc320401b2bb7b0ae6576a7f1afc531af7
Author: Mihai Varga <[email protected]>
Date:   Thu Jul 23 16:53:56 2015 +0300

    loleaflet: test if loading a document and scrolling works
    
    To run the test, open tilebench.html in a browser

diff --git a/loleaflet/spec/tilebench.html b/loleaflet/spec/tilebench.html
new file mode 100644
index 0000000..7f3722b
--- /dev/null
+++ b/loleaflet/spec/tilebench.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+       <meta charset="utf-8">
+       <title>LOOL Spec Runner</title>
+       <link rel="stylesheet" type="text/css" 
href="../node_modules/mocha/mocha.css">
+       <link rel="stylesheet" type="text/css" href="../dist/leaflet.css">
+       <link rel="stylesheet" type="text/css" 
href="../src/scrollbar/jquery.mCustomScrollbar.css">
+       <link rel="stylesheet" type="text/css" href="../dist/dialog/vex.css" />
+       <link rel="stylesheet" type="text/css" 
href="../dist/dialog/vex-theme-plain.css" />
+</head>
+<body>
+       <div id="mocha"></div>
+       <script src="expect.js"></script>
+       <script type="text/javascript" 
src="../node_modules/mocha/mocha.js"></script>
+       <script type="text/javascript" 
src="../node_modules/happen/happen.js"></script>
+       <script type="text/javascript" src="sinon.js"></script>
+       <script 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js";></script>
+       <script>window.jQuery || document.write('<script 
src="../src/scrollbar/jquery-1.11.0.min.js"><\/script>')</script>
+       <script src="../src/scrollbar/jquery.mCustomScrollbar.js"></script>
+       <script src="../dist/dialog/vex.combined.min.js"></script>
+       <script>vex.defaultOptions.className = 'vex-theme-plain';</script>
+
+       <!-- source files -->
+       <script type="text/javascript" src="../build/deps.js"></script>
+
+       <script type="text/javascript" 
src="../debug/leaflet-include.js"></script>
+
+       <script>
+               mocha.setup({
+                       ui: 'bdd',
+                       ignoreLeaks: true
+               });
+       </script>
+
+       <!-- spec files -->
+       <script type="text/javascript" 
src="tilebench/TileBenchSpec.js"></script>
+
+       <div id="document-container" style="top:300px">
+               <div id="clipboard-container"><textarea 
id="clipboard"></textarea></div>
+               <div id="map"></div>
+               <div id="scroll-container">
+                       <div id="mock-document">
+                       </div>
+               </div>
+       </div>
+
+       <script>
+               (window.mochaPhantomJS || window.mocha).run();
+       </script>
+</body>
+</html>
diff --git a/loleaflet/spec/tilebench/TileBenchSpec.js 
b/loleaflet/spec/tilebench/TileBenchSpec.js
new file mode 100644
index 0000000..46963e5
--- /dev/null
+++ b/loleaflet/spec/tilebench/TileBenchSpec.js
@@ -0,0 +1,93 @@
+describe('TileBench', function () {
+       // 20 s timeout
+       this.timeout(20000);
+       var map;
+       var loadCount = 0;
+
+       var log = function (msg) {
+               // write custom log messages
+               var cont = document.getElementById('mocha-report');
+               var li = document.createElement('li');
+               li.style.class = 'test pass';
+               li.innerHTML = '<h2>' + msg + '</h2>';
+               cont.appendChild(li);
+       }
+
+       before(function () {
+               // initialize the map and load the document
+               map = L.map('map', 'scroll-container', 'mock-document', {
+                       center: [0, 0],
+                       zoom: 10,
+                       minZoom: 1,
+                       maxZoom: 20,
+                       server: 'ws://localhost:9980',
+                       doubleClickZoom: false
+               });
+
+               var docLayer = new L.TileLayer('', {
+                       doc: 'file:///home/mihai/Desktop/test_docs/eval.odt',
+                       useSocket : true,
+                       edit: true,
+                       readOnly: false
+               });
+               map.addLayer(docLayer);
+
+               ////// Scrollbar /////
+               (function($){
+                               $("#scroll-container").mCustomScrollbar({
+                                       axis: 'yx',
+                                       theme: 'dark-thick',
+                                       scrollInertia: 0,
+                                       callbacks:{
+                                               onScroll: function(){
+                                                       
docLayer._onScrollEnd(this);
+                                               },
+                                               whileScrolling: function(){
+                                                       
docLayer._onScroll(this);
+                                               },
+                                               alwaysTriggerOffsets:false
+                                       }
+                               });
+               })(jQuery);
+       });
+
+       afterEach(function () {
+               map.off('alltilesloaded');
+       });
+
+       after(function () {
+               map.socket.onclose = undefined;
+               map.socket.onerror = undefined;
+               map.socket.close();
+       });
+
+       describe('Benchmarking', function () {
+               it('Load all new tiles', function (done) {
+                       map.on('alltilesloaded', L.bind(function () {
+                               loadCount += 1;
+                               console.log(loadCount);
+                               done();
+                       }, done));
+
+               });
+
+               it('Scroll to the bottom', function (done) {
+                       $('#scroll-container').mCustomScrollbar('scrollTo', 
'bottom', {scrollInertia: 3000});
+                       // check how we're doing 200ms after the scroll has 
ended
+                       // (allow enough time to request new tiles)
+                       this.timeOut = setTimeout(L.bind(function () {
+                               if (map._docLayer._emptyTilesCount === 0) {
+                                       // no pending tile requests
+                                       done();
+                               }
+                               else {
+                                       map.on('alltilesloaded', 
L.bind(function () {
+                                               loadCount += 1;
+                                               clearTimeout(this.timeOut);
+                                               done();
+                                       }, done));
+                               }
+                       }, done), 3200);
+               });
+       });
+});
commit d0553171751de7978a2cf7294bbbe81c2a65f579
Author: Mihai Varga <[email protected]>
Date:   Thu Jul 23 15:45:08 2015 +0300

    loleaflet: notify when all empty tiles have loaded
    
    Will be used for testing

diff --git a/loleaflet/src/layer/tile/GridLayer.js 
b/loleaflet/src/layer/tile/GridLayer.js
index c82490f..4596868 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -523,6 +523,7 @@ L.GridLayer = L.Layer.extend({
                                                delete this._tiles[key];
                                        }
                                }
+                               this._emptyTilesCount = 0;
                        }
 
                        // if its the first batch of tiles to load
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 67c9f88..3b54132 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -90,6 +90,7 @@ L.TileLayer = L.GridLayer.extend({
                        }),
                        draggable: true
                });
+               this._emptyTilesCount = 0;
                this._textArea = L.DomUtil.get('clipboard');
                this._textArea.focus();
        },
@@ -162,6 +163,7 @@ L.TileLayer = L.GridLayer.extend({
                 http://www.w3.org/TR/WCAG20-TECHS/H67
                */
                tile.alt = '';
+               this._emptyTilesCount += 1;
                return tile;
        },
 
@@ -386,6 +388,13 @@ L.TileLayer = L.GridLayer.extend({
                                if (this._tiles[key]._invalidCount > 0) {
                                        this._tiles[key]._invalidCount -= 1;
                                }
+                               if (!tile.loaded) {
+                                       this._emptyTilesCount -= 1;
+                                       if (this._emptyTilesCount === 0) {
+                                               console.log('alltilesloaded');
+                                               
this._map.fire('alltilesloaded');
+                                       }
+                               }
                                tile.el.src = img;
                        }
                        else {
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to