1 // Tests for BookReaderPreview.php
3 // Depends on common.js
7 function Book(identifier, previewWidth, coverWidth, titleWidth, imageSize, bookId) {
8 this.identifier = identifier;
9 this.previewWidth = previewWidth;
10 this.coverWidth = coverWidth;
11 this.titleWidth = titleWidth;
12 if (bookId === undefined) {
19 // Old books using title page as cover (ignoring marked cover)
20 new Book('coloritsapplicat00andriala', 1974, 1974, 1974),
21 new Book('lietuvostsrmoksl50liet', 1887, 1887, 1887),
22 new Book('oldtestamentrevi02slsn', 2019, 2019, 2019),
24 // Protected book with marked cover returned as cover
25 new Book('joyofsoaringtrai00conw', 2571, 2571, 2419)
29 for (index in books) {
31 var i = index; // closure
33 asyncTest("Load preview for " + books[index].identifier, function() {
37 var identifier = book.identifier;
39 var pageURI = previewURL(identifier, book.bookId, 'preview');
40 var img = new Image();
41 $(img).bind( 'load error', function(eventObj) {
42 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
43 equals(this.width, book.previewWidth, 'Preview width');
46 .attr('src', pageURI);
51 asyncTest("Load cover for " + books[index].identifier, function() {
55 var identifier = book.identifier;
57 var pageURI = previewURL(identifier, book.bookId, 'cover');
58 var img = new Image();
59 $(img).bind( 'load error', function(eventObj) {
60 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
61 equals(this.width, book.coverWidth, 'Cover width');
64 .attr('src', pageURI);
69 asyncTest("Load title for " + books[index].identifier, function() {
73 var identifier = book.identifier;
75 var pageURI = previewURL(identifier, book.bookId, 'title');
76 var img = new Image();
77 $(img).bind( 'load error', function(eventObj) {
78 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
79 equals(this.width, book.titleWidth, 'Title image width');
82 .attr('src', pageURI);
90 var identifier = 'SubBookTest';
91 asyncTest("Load title for book without title specified " + identifier, function() {
94 var pageURI = previewURL(identifier, identifier, 'title');
95 var img = new Image();
96 $(img).bind( 'load error', function(eventObj) {
97 equals(eventObj.type, 'error', 'Load image (' + pageURI + '). Event handler called');
100 .attr('src', pageURI);
105 var subPrefix = 'subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume';
106 asyncTest("Load preview for book in sub-dir " + identifier + '/' + subPrefix, function() {
109 var pageURI = previewURL(identifier, subPrefix, 'title');
110 var img = new Image();
111 $(img).bind( 'load error', function(eventObj) {
112 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
113 equals(this.width, 5100, 'Preview image width');
116 .attr('src', pageURI);