1 // Tests for BookReaderImages.php
3 // $$$ TODO -- make the test host configurable/automagic
7 // $$$ set to test host
8 var testHost = 'http://www-mang.archive.org';
10 // Returns locator URL for the given id
11 function jsLocateURL(bookId) {
12 return testHost + '/bookreader/BookReaderJSLocate.php?id=' + bookId;
15 // Set up dummy BookReader class for JSLocate
16 function BookReader() {
19 BookReader.prototype.init = function() {
24 /// windwavesatseabr00bige - jp2 zip
25 asyncTest("JSLocate for windwavesatseabr00bige - Scribe jp2.zip book", function() {
27 $.getScript( jsLocateURL('windwavesatseabr00bige'), function(data, textStatus) {
28 equals(br.numLeafs, 224, 'JSLocate successful. numLeafs');
33 test("Image URI for windwavesatseabr00bige page index 5", function() {
36 var expectedEnding = "file=windwavesatseabr00bige_jp2/windwavesatseabr00bige_0006.jp2&scale=1&rotate=0";
37 var pageURI = br.getPageURI(index);
38 var reg = new RegExp('file=.*$');
39 var actualEnding = reg.exec(pageURI);
40 equals(actualEnding, expectedEnding, 'URI for page index 5 ends with');
43 asyncTest("Load windwavesatseabr00bige image 5", function() {
44 var pageURI = br.getPageURI(5);
45 var img = new Image();
46 $(img).bind( 'load error', function(eventObj) {
47 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
50 // Actually load the image
51 .attr('src', pageURI);
55 /// asamoandictiona00pragoog - tiff zip
56 asyncTest("JSLocate for asamoandictiona00pragoog - tiff.zip book", function() {
58 $.getScript( jsLocateURL('asamoandictiona00pragoog'), function() {
60 'A Samoan dictionary: English and Samoan, and Samoan and English;',
66 asyncTest("Load tiff image from zip", function() {
68 var pageURI = br.getPageURI(23, 8);
69 var img = new Image();
70 $(img).bind( 'load error', function(eventObj) {
71 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
72 equals(this.width, 351, 'Image width');
75 .attr('src', pageURI);
79 /// hccapp56191900uoft - jpeg tar
80 asyncTest("JSLocate for hccapp56191900uoft - jpg.tar", function() {
82 $.getScript( jsLocateURL('hccapp56191900uoft'), function() {
83 equals(br.numLeafs, 1101, 'Number of pages');
88 asyncTest('Load jpg image from tar file - https://bugs.launchpad.net/bookreader/+bug/323003', function() {
90 var pageURI = br.getPageURI(6, 8);
91 var img = new Image();
92 $(img).bind( 'load error', function(eventObj) {
93 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
94 equals(this.width, 244, 'Image width');
97 .attr('src', pageURI);