Merge branch 'master' into jp2levels
[bookreader.git] / BookReaderIA / test / unit / Images.js
index 640250b..8510f92 100644 (file)
@@ -5,7 +5,8 @@
 module("Images");
 
 // $$$ set to test host
-var testHost = 'http://www-mang.archive.org';
+var testHost = 'http://www-testflip.archive.org';
+//var testHost = 'http://www-mang.archive.org';
 
 // Returns locator URL for the given id
 function jsLocateURL(identifier, book) {
@@ -25,6 +26,32 @@ BookReader.prototype.init = function() {
 };
 
 
+// Test image info - jpeg
+asyncTest("JSLocate for armageddonafter00couruoft - jpeg", function() {
+    expect(1);
+    $.getScript( jsLocateURL('armageddonafter00couruoft'), function() {
+        equals(br.bookTitle, 'Armageddon and after', 'Title');
+        start();
+    });
+});
+
+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();
+    });
+});
+
+
+
 // Test image info
 asyncTest("JSLocate for zc-f-c-b-4 - 1-bit jp2", function() {
     expect(1);
@@ -36,7 +63,7 @@ asyncTest("JSLocate for zc-f-c-b-4 - 1-bit jp2", function() {
 
 asyncTest("Image info for 1-bit jp2", function() {
     expect(3);
-    var expected = {"width":3295,"height":2561,"bits":1};
+    var expected = {"width":3295,"height":2561,"bits":1,"type":"jp2"};
     var imageInfoURL = br.getPageURI(0) + '&ext=json&callback=?';
     
     $.getJSON(imageInfoURL, function(data) {
@@ -80,6 +107,46 @@ asyncTest("Load windwavesatseabr00bige image 5", 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);
@@ -91,13 +158,28 @@ asyncTest("JSLocate for asamoandictiona00pragoog - tiff.zip book", 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, 702, 'Image width');
         start();
     })
     .attr('src', pageURI);