1 // Tests for BookReaderImages.php
3 // Depends on common.js
7 /* Item no longer available
8 // Test image info - jpeg
9 asyncTest("JSLocate for armageddonafter00couruoft - jpeg", function() {
11 $.getScript( jsLocateURL('armageddonafter00couruoft'), function() {
12 equals(br.bookTitle, 'Armageddon and after', 'Title');
17 asyncTest("Image info for jpeg", function() {
19 var expected = {"width":1349,"height":2105,"bits":8,"type":"jpeg"};
20 var imageInfoURL = br.getPageURI(8) + '&ext=json&callback=?';
22 $.getJSON(imageInfoURL, function(data) {
23 equals(data != null, true, 'data is not null');
25 equals(data.width, expected.width, 'Image width');
26 same(data, expected, 'Image info object');
34 asyncTest("JSLocate for zc-f-c-b-4 - 1-bit jp2", function() {
36 $.getScript( jsLocateURL('zc-f-c-b-4', 'concept-of-infection'), function() {
37 equals(br.numLeafs, 13, 'numLeafs');
42 asyncTest("Image info for 1-bit jp2", function() {
44 var expected = {"width":3295,"height":2561,"bits":1,"type":"jp2"};
45 var imageInfoURL = br.getPageURI(0) + '&ext=json&callback=?';
47 $.getJSON(imageInfoURL, function(data) {
48 equals(data != null, true, 'data is not null');
50 equals(data.width, expected.width, 'Image width');
51 same(data, expected, 'Image info object');
57 /// windwavesatseabr00bige - jp2 zip
58 asyncTest("JSLocate for windwavesatseabr00bige - Scribe jp2.zip book", function() {
60 $.getScript( jsLocateURL('windwavesatseabr00bige'), function(data, textStatus) {
61 equals(br.numLeafs, 224, 'JSLocate successful. numLeafs');
66 test("Image URI for windwavesatseabr00bige page index 5", function() {
69 var expectedEnding = "file=windwavesatseabr00bige_jp2/windwavesatseabr00bige_0006.jp2&scale=1&rotate=0";
70 var pageURI = br.getPageURI(index);
71 var reg = new RegExp('file=.*$');
72 var actualEnding = reg.exec(pageURI);
73 equals(actualEnding, expectedEnding, 'URI for page index 5 ends with');
76 asyncTest("Load windwavesatseabr00bige image 5", function() {
77 var pageURI = br.getPageURI(5);
78 var img = new Image();
79 $(img).bind( 'load error', function(eventObj) {
80 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
83 // Actually load the image
84 .attr('src', pageURI);
88 /// nybc200109 - 1-bit tiff zip
89 asyncTest("JSLocate for nybc200109 - 1-bit tiff.zip book", function() {
91 $.getScript( jsLocateURL('nybc200109'), function() {
99 asyncTest("Image info for 1-bit tiff", function() {
101 var expected = {"width":5081,"height":6592,"bits":1,"type":"tiff"};
102 var imageInfoURL = br.getPageURI(0) + '&ext=json&callback=?';
104 $.getJSON(imageInfoURL, function(data) {
105 equals(data != null, true, 'data is not null');
107 equals(data.width, expected.width, 'Image width');
108 same(data, expected, 'Image info object');
114 asyncTest("Load 1-bit tiff image from zip", function() {
116 var pageURI = br.getPageURI(6, 16);
117 var img = new Image();
118 $(img).bind( 'load error', function(eventObj) {
119 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
120 equals(this.width, 1272, 'Image width');
123 .attr('src', pageURI);
128 /// asamoandictiona00pragoog - tiff zip
129 asyncTest("JSLocate for asamoandictiona00pragoog - tiff.zip book", function() {
131 $.getScript( jsLocateURL('asamoandictiona00pragoog'), function() {
133 'A Samoan dictionary: English and Samoan, and Samoan and English;',
139 asyncTest("Image info for 8-bit tiff", function() {
141 var expected = {"width":1275,"height":1650,"bits":8,"type":"tiff"};
142 var imageInfoURL = br.getPageURI(0) + '&ext=json&callback=?';
144 $.getJSON(imageInfoURL, function(data) {
145 equals(data != null, true, 'data is not null');
147 equals(data.width, expected.width, 'Image width');
148 same(data, expected, 'Image info object');
154 asyncTest("Load tiff image from zip", function() {
156 var pageURI = br.getPageURI(23, 8);
157 var img = new Image();
158 $(img).bind( 'load error', function(eventObj) {
159 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
160 equals(this.width, 701, 'Image width');
163 .attr('src', pageURI);
167 /// hccapp56191900uoft - jpeg tar
168 asyncTest("JSLocate for hccapp56191900uoft - jpg.tar", function() {
170 $.getScript( jsLocateURL('hccapp56191900uoft'), function() {
171 equals(br.numLeafs, 1101, 'Number of pages');
176 asyncTest('Load jpg image from tar file - https://bugs.launchpad.net/bookreader/+bug/323003', function() {
178 var pageURI = br.getPageURI(6, 8);
179 var img = new Image();
180 $(img).bind( 'load error', function(eventObj) {
181 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
182 equals(this.width, 243, 'Image width');
185 .attr('src', pageURI);
188 asyncTest('Load image region - /download/populationsc18400378unit/page/n800_x1544_y4144_w1192_h848_s4.jpg', function() {
190 var pageURI = testHost() + '/download/populationsc18400378unit/page/n800_x1544_y4144_w1192_h848_s4.jpg';
192 var img = new Image();
193 $(img).bind( 'load error', function(eventObj) {
194 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
195 equals(this.width, 299, 'Image width');
196 equals(this.height, 212, 'Image height');
199 .attr('src', pageURI);
203 asyncTest('Load image region using decimal coordinates - /download/populationsc18400378unit/page/n800_x0.75_y0.75_w0.25_h0.25_s4.jpg', function() {
205 var pageURI = testHost() + '/download/populationsc18400378unit/page/n800_x0.75_y0.75_w0.25_h0.25_s4.jpg';
207 var img = new Image();
208 $(img).bind( 'load error', function(eventObj) {
209 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
210 equals(this.width, 337, 'Image width');
211 equals(this.height, 342, 'Image height');
214 .attr('src', pageURI);
219 asyncTest('Load image region - /download/tomslademotorcyc00fitz/page/page3_x256_y96_w1720_h152_s4.jpg', function() {
221 var pageURI = testHost() + '/download/tomslademotorcyc00fitz/page/page3_x256_y96_w1720_h152_s4.jpg';
223 var img = new Image();
224 $(img).bind( 'load error', function(eventObj) {
225 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
226 equals(this.width, 430, 'Image width');
227 equals(this.height, 38, 'Image height');
230 .attr('src', pageURI);
234 asyncTest('Load cover, fitting within 400x400', function() {
236 var pageURI = testHost() + '/download/mechanicstheor00loverich/page/cover_w400_h400.jpg';
238 var img = new Image();
239 $(img).bind( 'load error', function(eventObj) {
240 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
241 equals(this.width, 264, 'Image width');
242 equals(this.height, 487, 'Image height');
245 .attr('src', pageURI);
249 asyncTest('Load cover, fitting within 100x400', function() {
251 var pageURI = testHost() + '/download/mechanicstheor00loverich/page/cover_w100_h400.jpg';
253 var img = new Image();
254 $(img).bind( 'load error', function(eventObj) {
255 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
256 equals(this.width, 132, 'Image width');
257 equals(this.height, 244, 'Image height');
260 .attr('src', pageURI);
265 asyncTest('Load image region from tiff, via br.getRegionURI - fightingflyingc00rickgoog - n17_x1944_y1708_w668_h584', function() {
267 $.getScript( jsLocateURL('fightingflyingc00rickgoog'), function() {
270 var pageURI = br.getRegionURI(17, undefined, undefined, 1944, 1708, 668, 584);
272 var img = new Image();
273 $(img).bind( 'load error', function(eventObj) {
274 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
275 equals(this.width, 668, 'Image width');
276 equals(this.height, 584, 'Image height');
279 .attr('src', pageURI);
284 asyncTest('Same image rotated 90 degrees, br.getRegionURI - fightingflyingc00rickgoog - n17_x1944_y1708_w668_h584_rot90', function() {
286 $.getScript( jsLocateURL('fightingflyingc00rickgoog'), function() {
289 var pageURI = br.getRegionURI(17, undefined, 90, 1944, 1708, 668, 584);
291 var img = new Image();
292 $(img).bind( 'load error', function(eventObj) {
293 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
294 equals(this.width, 584, 'Image width');
295 equals(this.height, 668, 'Image height');
298 .attr('src', pageURI);