loleaflet/spec/loleaflet/control/SearchSpec.js |   49 +++++++++++++++++++++----
 1 file changed, 42 insertions(+), 7 deletions(-)

New commits:
commit 1ab3caa192af9c1747cb58257ee741ee03cd434d
Author: Pranav Kant <[email protected]>
Date:   Fri Feb 19 21:20:01 2016 +0530

    loleaflet: Make SearchSpec work again
    
    This broke after we changed 'searchAll' to 'highlightAll'.
    
    Change-Id: I257b20a458a9ad3334b5e20fc110d0932eb63733
    Reviewed-on: https://gerrit.libreoffice.org/22508
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Andras Timar <[email protected]>

diff --git a/loleaflet/spec/loleaflet/control/SearchSpec.js 
b/loleaflet/spec/loleaflet/control/SearchSpec.js
index 6135945..b5a54a7 100644
--- a/loleaflet/spec/loleaflet/control/SearchSpec.js
+++ b/loleaflet/spec/loleaflet/control/SearchSpec.js
@@ -42,6 +42,10 @@ describe('Search', function () {
        });
 
        describe('Search', function () {
+               afterEach(function () {
+                       map.off('search');
+               });
+
                it('Search forward', function (done) {
                        map.once('search', function (e) {
                                expect(e.originalPhrase).to.be('doc');
@@ -77,25 +81,54 @@ describe('Search', function () {
                });
        });
 
-       describe('Search all', function () {
-               it('Search forward', function (done) {
+       describe('Search with highlight all', function () {
+               afterEach(function () {
+                       map.off('search');
+               });
+
+               it('Highlight all', function (done) {
                        map.once('search', function (e) {
                                expect(e.originalPhrase).to.be('doc');
+                               expect(e.highlightAll).to.be('true');
                                expect(e.count).to.be(5);
                                expect(e.results.length).to.be(5);
+                               // first 4 results are in first page
+                               for (var i = 0; i < e.count - 1; i++) {
+                                       
expect(map.getPageSizes().pixels[0].contains(e.results[i].rectangles[0])).to.be.ok();
+                               }
+                               // last result is in second page
+                               
expect(map.getPageSizes().pixels[1].contains(e.results[e.count - 
1].rectangles[0])).to.be.ok();
                                done();
                        });
-                       map.searchAll('doc');
+                       map.highlightAll('doc');
+               });
+
+               it('Search forward', function (done) {
+                       map.once('search', function (e) {
+                               expect(e.originalPhrase).to.be('doc');
+                               expect(e.count).to.be(1);
+                               expect(e.results.length).to.be(1);
+                               // Output of previous highlight all operation 
is still cached
+                               
expect(map._docLayer._searchResults.length).to.be(5);
+                               // the first page contains the search result
+                               
expect(map.getPageSizes().pixels[0].contains(e.results[0].rectangles[0])).to.be.ok();
+                               done();
+                       });
+                       map.search('doc');
                });
 
                it('Search backward', function (done) {
                        map.once('search', function (e) {
                                expect(e.originalPhrase).to.be('doc');
-                               expect(e.count).to.be(5);
-                               expect(e.results.length).to.be(5);
+                               expect(e.count).to.be(1);
+                               expect(e.results.length).to.be(1);
+                               // Output of previous highlight all operation 
is still cached
+                               
expect(map._docLayer._searchResults.length).to.be(5);
+                               // the second page contains the search result
+                               
expect(map.getPageSizes().pixels[1].contains(e.results[0].rectangles[0])).to.be.ok();
                                done();
                        });
-                       map.searchAll('doc', true);
+                       map.search('doc', true);
                });
 
                it('Search not found', function (done) {
@@ -103,9 +136,11 @@ describe('Search', function () {
                                
expect(e.originalPhrase).to.be('something-not-found');
                                expect(e.count).to.be(0);
                                expect(e.results).to.be(undefined);
+                               // All cached search results from previous 
highlight all operations are cleared
+                               
expect(map._docLayer._searchResults).to.be(null);
                                done();
                        });
-                       map.searchAll('something-not-found', true);
+                       map.search('something-not-found');
                });
        });
 });
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to