// 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');
asyncTest("Load windwavesatseabr00bige image 5", function() {
var pageURI = br.getPageURI(5);
var img = new Image();
- $(img).bind( 'load', 'load handler', function(eventObj) {
- equals(eventObj.data, 'load handler', 'Load image (' + pageURI + '). Event handler called');
+ $(img).bind( 'load error', function(eventObj) {
+ equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
start();
})
+ // Actually load the image
+ .attr('src', pageURI);
+});
+
+
+/// 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=?';
- // Make sure tests are started in case of error loading image
- .bind('error', 'error handler', function(eventObj) {
- equals(eventObj.data, 'load handler', 'Load image (' + pageURI + '). Event handler called');
+ $.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();
})
-
- // Actually load the image
.attr('src', pageURI);
});
-asyncTest("JSLocate for asamoandictiona00pragoog - tiff book", function() {
+
+
+/// asamoandictiona00pragoog - tiff zip
+asyncTest("JSLocate for asamoandictiona00pragoog - tiff.zip book", function() {
expect(1);
$.getScript( jsLocateURL('asamoandictiona00pragoog'), function() {
equals(br.bookTitle,
});
});
-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', 'load handler', function(eventObj) {
- equals(eventObj.data, 'load handler', 'Load image (' + pageURI + '). Event handler called');
- equals(this.width, 351, 'Image width');
+ $(img).bind( 'load error', function(eventObj) {
+ equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
+ equals(this.width, 701, 'Image width');
start();
})
- .bind( 'error', 'error handler', function(eventObj) {
- equals(eventObj.data, 'load handler', 'Load image (' + pageURI + '). Event handler called') ;
- equals(this.width, 351, 'Image width');
+ .attr('src', pageURI);
+});
+
+
+/// 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);
-});
\ No newline at end of file
+});
+
+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);
+
+ });
+});