1 // Tests for BookReaderPreview.php
3 // Depends on common.js
7 function Book(identifier, previewWidth, coverWidth, titleWidth) {
8 this.identifier = identifier;
9 this.previewWidth = previewWidth;
10 this.coverWidth = coverWidth;
11 this.titleWidth = titleWidth;
15 new Book('coloritsapplicat00andriala', 1974, 2346, 1974),
16 new Book('lietuvostsrmoksl50liet', 1887, 1747, 1887),
17 new Book('oldtestamentrevi02slsn', 2019, 2371, 2019)
20 for (index in books) {
22 var i = index; // closure
24 asyncTest("Load preview for " + books[index].identifier, function() {
28 var identifier = book.identifier;
30 var pageURI = previewURL(identifier, identifier, 'preview');
31 var img = new Image();
32 $(img).bind( 'load error', function(eventObj) {
33 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
34 equals(this.width, book.previewWidth, 'Preview width');
37 .attr('src', pageURI);
42 asyncTest("Load cover for " + books[index].identifier, function() {
46 var identifier = book.identifier;
48 var pageURI = previewURL(identifier, identifier, 'cover');
49 var img = new Image();
50 $(img).bind( 'load error', function(eventObj) {
51 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
52 equals(this.width, book.coverWidth, 'Cover width');
55 .attr('src', pageURI);
60 asyncTest("Load title for " + books[index].identifier, function() {
64 var identifier = book.identifier;
66 var pageURI = previewURL(identifier, identifier, 'title');
67 var img = new Image();
68 $(img).bind( 'load error', function(eventObj) {
69 equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
70 equals(this.width, book.titleWidth, 'Title image width');
73 .attr('src', pageURI);