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() {
23 asyncTest("JSLocate for windwavesatseabr00bige", function() {
25 $.getScript( jsLocateURL('windwavesatseabr00bige'), function(data, textStatus) {
26 equals(br.numLeafs, 224, 'JSLocate successful. numLeafs');
31 test("Image URI for windwavesatseabr00bige page index 5", function() {
34 var expectedEnding = "file=windwavesatseabr00bige_jp2/windwavesatseabr00bige_0006.jp2&scale=1&rotate=0";
35 var pageURI = br.getPageURI(index);
36 var reg = new RegExp('file=.*$');
37 var actualEnding = reg.exec(pageURI);
38 equals(actualEnding, expectedEnding, 'URI for page index 5 ends with');
41 asyncTest("Load windwavesatseabr00bige image 5", function() {
42 var pageURI = br.getPageURI(5);
43 var img = new Image();
44 $(img).bind( 'load error', function(eventObj) {
45 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
48 // Actually load the image
49 .attr('src', pageURI);
52 asyncTest("JSLocate for asamoandictiona00pragoog - tiff book", function() {
54 $.getScript( jsLocateURL('asamoandictiona00pragoog'), function() {
56 'A Samoan dictionary: English and Samoan, and Samoan and English;',
62 asyncTest("Load tiff image", function() {
64 var pageURI = br.getPageURI(23, 8);
65 var img = new Image();
66 $(img).bind( 'load error', function(eventObj) {
67 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
68 equals(this.width, 351, 'Image width');
71 .attr('src', pageURI);