Add rotation support for non-jp2 images
[bookreader.git] / BookReaderIA / test / unit / Permalinks.js
1
2 // Depends on common.js
3
4 module("Permalinks");
5
6 test("Permalink format - /download/{itemid}/page/{page specifier}.jpg", function() {
7     expect(1);
8     var page = 'page4.jpg';
9     var itemId = 'handbookofdorking00denn';
10
11     var pageURI = imagePermalink(itemId, null, page);
12     equals(pageURI, common.testHost + '/download/handbookofdorking00denn/page/page4.jpg');
13 });
14
15 (function() {
16     var page = 'page4.jpg';
17     var itemId = 'handbookofdorking00denn';
18
19     asyncTest("Page " + page + " from " + itemId, function() {
20         expect(2);
21     
22         
23         var pageURI = imagePermalink(itemId, null, page);
24         
25         var img = new Image();
26         $(img).bind( 'load error', function(eventObj) {
27             equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
28             equals(this.width, 1566, 'Image width');
29             start();
30         })
31         .attr('src', pageURI);
32         
33         img = null;
34     });
35 })();
36
37 (function() {
38     var itemId = 'SubBookTest';
39     var page = 'n9.jpg';
40     var subPrefix = 'subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume';
41     
42     asyncTest("Sub-dir book - Page " + page + " from " + itemId + '/' + subPrefix, function() {
43         expect(2);
44         
45         var pageURI = imagePermalink(itemId, subPrefix, page);
46         
47         var img = new Image();    
48         $(img).bind( 'load error', function(eventObj) {
49             equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
50             equals(this.width, 5100, 'Image width');
51             start();
52         })
53         .attr('src', pageURI);
54         
55         img = null;
56     });
57 })();
58
59 (function() {
60     var itemId = 'nasa_techdoc_20050157919';
61     var page = 'n20_thumb_rotate90.jpg';
62     var subPrefix = '20050157919';
63     
64     asyncTest("Rotated thumbnail - Page " + page + " from " + itemId + '/' + subPrefix, function() {
65         expect(2);
66         
67         var pageURI = imagePermalink(itemId, subPrefix, page);
68         
69         var img = new Image();    
70         $(img).bind( 'load error', function(eventObj) {
71             equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
72             equals(this.width, 179, 'Image width');
73             start();
74         })
75         .attr('src', pageURI);
76         
77         img = null;
78     });
79 })();
80
81 (function() {
82     var itemId = 'nasa_techdoc_20050157919';
83     var page = 'preview_thumb.jpg';
84     var subPrefix = null;
85     
86     asyncTest("Preview image for book in subdir without specifying sub-dir - Page " + page + " from " + itemId, function() {
87         expect(2);
88         
89         var pageURI = imagePermalink(itemId, subPrefix, page);
90         
91         var img = new Image();    
92         $(img).bind( 'load error', function(eventObj) {
93             equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
94             equals(this.width, 122, 'Image width');
95             start();
96         })
97         .attr('src', pageURI);
98         
99         img = null;
100     });
101 })();