X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=BookReaderIA%2Ftest%2Funit%2FImages.js;h=33a2511ab37cc170b7175c636260b2974bb786eb;hb=2cb1704f4f6aeef358bd0bc3a4fcc364fcec9e23;hp=ce5d489845514f1816437a59d8b8a2b9131944c2;hpb=72bf9224622c55a98dc345f120a5c563aa15e7a9;p=bookreader.git diff --git a/BookReaderIA/test/unit/Images.js b/BookReaderIA/test/unit/Images.js index ce5d489..33a2511 100644 --- a/BookReaderIA/test/unit/Images.js +++ b/BookReaderIA/test/unit/Images.js @@ -1,26 +1,61 @@ // Tests for BookReaderImages.php -// $$$ TODO -- make the test host configurable/automagic +// Depends on common.js module("Images"); -// $$$ set to test host -var testHost = 'http://www-mang.archive.org'; +/* Item no longer available +// Test image info - jpeg +asyncTest("JSLocate for armageddonafter00couruoft - jpeg", function() { + expect(1); + $.getScript( jsLocateURL('armageddonafter00couruoft'), function() { + equals(br.bookTitle, 'Armageddon and after', 'Title'); + start(); + }); +}); -// Returns locator URL for the given id -function jsLocateURL(bookId) { - return testHost + '/bookreader/BookReaderJSLocate.php?id=' + bookId; -} +asyncTest("Image info for jpeg", function() { + expect(3); + var expected = {"width":1349,"height":2105,"bits":8,"type":"jpeg"}; + var imageInfoURL = br.getPageURI(8) + '&ext=json&callback=?'; + + $.getJSON(imageInfoURL, function(data) { + equals(data != null, true, 'data is not null'); + if (data != null) { + equals(data.width, expected.width, 'Image width'); + same(data, expected, 'Image info object'); + } + start(); + }); +}); +*/ -// Set up dummy BookReader class for JSLocate -function BookReader() { -}; +// Test image info +asyncTest("JSLocate for zc-f-c-b-4 - 1-bit jp2", function() { + expect(1); + $.getScript( jsLocateURL('zc-f-c-b-4', 'concept-of-infection'), function() { + equals(br.numLeafs, 13, 'numLeafs'); + start(); + }); +}); -BookReader.prototype.init = function() { - return true; -}; +asyncTest("Image info for 1-bit jp2", function() { + expect(3); + var expected = {"width":3295,"height":2561,"bits":1,"type":"jp2"}; + var imageInfoURL = br.getPageURI(0) + '&ext=json&callback=?'; + + $.getJSON(imageInfoURL, function(data) { + equals(data != null, true, 'data is not null'); + if (data != null) { + equals(data.width, expected.width, 'Image width'); + same(data, expected, 'Image info object'); + } + start(); + }); +}); -asyncTest("JSLocate for windwavesatseabr00bige", function() { +/// windwavesatseabr00bige - jp2 zip +asyncTest("JSLocate for windwavesatseabr00bige - Scribe jp2.zip book", function() { expect(1); $.getScript( jsLocateURL('windwavesatseabr00bige'), function(data, textStatus) { equals(br.numLeafs, 224, 'JSLocate successful. numLeafs'); @@ -49,7 +84,49 @@ asyncTest("Load windwavesatseabr00bige image 5", function() { .attr('src', pageURI); }); -asyncTest("JSLocate for asamoandictiona00pragoog - tiff book", function() { + +/// nybc200109 - 1-bit tiff zip +asyncTest("JSLocate for nybc200109 - 1-bit tiff.zip book", function() { + expect(1); + $.getScript( jsLocateURL('nybc200109'), function() { + equals(br.numLeafs, + 694, + 'Number of pages'); + start(); + }); +}); + +asyncTest("Image info for 1-bit tiff", function() { + expect(3); + var expected = {"width":5081,"height":6592,"bits":1,"type":"tiff"}; + var imageInfoURL = br.getPageURI(0) + '&ext=json&callback=?'; + + $.getJSON(imageInfoURL, function(data) { + equals(data != null, true, 'data is not null'); + if (data != null) { + equals(data.width, expected.width, 'Image width'); + same(data, expected, 'Image info object'); + } + start(); + }); +}); + +asyncTest("Load 1-bit tiff image from zip", function() { + expect(2); + var pageURI = br.getPageURI(6, 16); + var img = new Image(); + $(img).bind( 'load error', function(eventObj) { + equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called'); + equals(this.width, 1272, 'Image width'); + start(); + }) + .attr('src', pageURI); +}); + + + +/// asamoandictiona00pragoog - tiff zip +asyncTest("JSLocate for asamoandictiona00pragoog - tiff.zip book", function() { expect(1); $.getScript( jsLocateURL('asamoandictiona00pragoog'), function() { equals(br.bookTitle, @@ -59,14 +136,90 @@ asyncTest("JSLocate for asamoandictiona00pragoog - tiff book", function() { }); }); -asyncTest("Load tiff image", function() { +asyncTest("Image info for 8-bit tiff", function() { + expect(3); + var expected = {"width":1275,"height":1650,"bits":8,"type":"tiff"}; + var imageInfoURL = br.getPageURI(0) + '&ext=json&callback=?'; + + $.getJSON(imageInfoURL, function(data) { + equals(data != null, true, 'data is not null'); + if (data != null) { + equals(data.width, expected.width, 'Image width'); + same(data, expected, 'Image info object'); + } + start(); + }); +}); + +asyncTest("Load tiff image from zip", function() { expect(2); var pageURI = br.getPageURI(23, 8); var img = new Image(); $(img).bind( 'load error', function(eventObj) { equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called'); - equals(this.width, 351, 'Image width'); + equals(this.width, 701, 'Image width'); start(); }) .attr('src', pageURI); -}); \ No newline at end of file +}); + + +/// hccapp56191900uoft - jpeg tar +asyncTest("JSLocate for hccapp56191900uoft - jpg.tar", function() { + expect(1); + $.getScript( jsLocateURL('hccapp56191900uoft'), function() { + equals(br.numLeafs, 1101, 'Number of pages'); + start(); + }); +}); + +asyncTest('Load jpg image from tar file - https://bugs.launchpad.net/bookreader/+bug/323003', function() { + expect(2); + var pageURI = br.getPageURI(6, 8); + var img = new Image(); + $(img).bind( 'load error', function(eventObj) { + equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called'); + equals(this.width, 243, 'Image width'); + start(); + }) + .attr('src', pageURI); +}); + +asyncTest('Load image region from tiff, via br.getRegionURI - fightingflyingc00rickgoog - n17_x1944_y1708_w668_h584', 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); + + }); +}); + +asyncTest('Same image rotated 90 degrees, br.getRegionURI - fightingflyingc00rickgoog - n17_x1944_y1708_w668_h584_rot90', function() { + + $.getScript( jsLocateURL('fightingflyingc00rickgoog'), function() { + + expect(3); + var pageURI = br.getRegionURI(17, undefined, 90, 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, 584, 'Image width'); + equals(this.height, 668, 'Image height'); + start(); + }) + .attr('src', pageURI); + + }); +}); +