From 589b566e46067cf9ab322286e3253821c4e29785 Mon Sep 17 00:00:00 2001 From: Michael Ang Date: Fri, 20 May 2011 22:57:41 +0000 Subject: [PATCH] Unit test for getting page region. Fix bug in br.getPageRegionURI --- BookReaderIA/datanode/BookReaderJSIA.php | 6 ++++-- BookReaderIA/test/unit/Images.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/BookReaderIA/datanode/BookReaderJSIA.php b/BookReaderIA/datanode/BookReaderJSIA.php index 009a42e..8b7a4f9 100644 --- a/BookReaderIA/datanode/BookReaderJSIA.php +++ b/BookReaderIA/datanode/BookReaderJSIA.php @@ -220,11 +220,13 @@ br.getRegionURI = function(index, reduce, rotate, sourceX, sourceY, sourceWidth, if (i > 0 ) { page += '_'; } - page += urlKeys[i] + argument[i]; + page += urlKeys[i] + arguments[i]; } } - return 'http://'+this.server+'/BookReader/BookReaderImages.php?zip='+this.zip+'&page='+page; + var itemPath = this.bookPath.replace(new RegExp('/'+this.subPrefix+'$'), ''); // remove trailing subPrefix + + return 'http://'+this.server+'/BookReader/BookReaderImages.php?id=' + this.bookId + '&itemPath=' + itemPath + '&server=' + this.server + '&subPrefix=' + this.subPrefix + '&page=' +page + '.jpg'; } br._getPageFile = function(index) { diff --git a/BookReaderIA/test/unit/Images.js b/BookReaderIA/test/unit/Images.js index 8334cdc..0a2919c 100644 --- a/BookReaderIA/test/unit/Images.js +++ b/BookReaderIA/test/unit/Images.js @@ -184,3 +184,22 @@ asyncTest('Load jpg image from tar file - https://bugs.launchpad.net/bookreader/ }) .attr('src', pageURI); }); + +asyncTest('Load image region from tiff - archive.org/download/fightingflyingc00rickgoog/page/n17_x1944_y1708_w668_h584.jpg', function() { + + $.getScript( jsLocateURL('fightingflyingc00rickgoog'), function() { + + expect(3); + var pageURI = br.getRegionURI(17, undefined, undefined, 1944, 1708, 668, 584); + + var img = new Image(); + $(img).bind( 'load error', function(eventObj) { + equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called'); + equals(this.width, 668, 'Image width'); + equals(this.height, 584, 'Image height'); + start(); + }) + .attr('src', pageURI); + + }); +}); -- 2.20.1