1 // Tests for BookReaderPreview.php
3 // Depends on common.js
7 function Book(identifier, previewWidth, coverWidth, titleWidth, bookId = undefined) {
8 this.identifier = identifier;
9 this.previewWidth = previewWidth;
10 this.coverWidth = coverWidth;
11 this.titleWidth = titleWidth;
12 if (bookId === undefined) {
19 new Book('coloritsapplicat00andriala', 1974, 2346, 1974),
20 new Book('lietuvostsrmoksl50liet', 1887, 1747, 1887),
21 new Book('oldtestamentrevi02slsn', 2019, 2371, 2019)
24 for (index in books) {
26 var i = index; // closure
28 asyncTest("Load preview for " + books[index].identifier, function() {
32 var identifier = book.identifier;
34 var pageURI = previewURL(identifier, book.bookId, 'preview');
35 var img = new Image();
36 $(img).bind( 'load error', function(eventObj) {
37 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
38 equals(this.width, book.previewWidth, 'Preview width');
41 .attr('src', pageURI);
46 asyncTest("Load cover for " + books[index].identifier, function() {
50 var identifier = book.identifier;
52 var pageURI = previewURL(identifier, book.bookId, 'cover');
53 var img = new Image();
54 $(img).bind( 'load error', function(eventObj) {
55 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
56 equals(this.width, book.coverWidth, 'Cover width');
59 .attr('src', pageURI);
64 asyncTest("Load title for " + books[index].identifier, function() {
68 var identifier = book.identifier;
70 var pageURI = previewURL(identifier, book.bookId, 'title');
71 var img = new Image();
72 $(img).bind( 'load error', function(eventObj) {
73 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
74 equals(this.width, book.titleWidth, 'Title image width');
77 .attr('src', pageURI);
85 var identifier = 'SubBookTest';
86 asyncTest("Load title for " + identifier, function() {
89 var pageURI = previewURL(identifier, identifier, 'title');
90 var img = new Image();
91 $(img).bind( 'load error', function(eventObj) {
92 equals(eventObj.type, 'error', 'Load image (' + pageURI + '). Event handler called');
95 .attr('src', pageURI);
100 asyncTest("Load title for " + identifier, function() {
103 var pageURI = previewURL(identifier, identifier, 'title');
104 var img = new Image();
105 $(img).bind( 'load error', function(eventObj) {
106 equals(eventObj.type, 'error', 'Load image (' + pageURI + '). Event handler called');
109 .attr('src', pageURI);