OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function testImageView() { | 5 function testImageView() { |
6 var mockFileSystem = new MockFileSystem('volumeId'); | 6 var mockFileSystem = new MockFileSystem('volumeId'); |
7 var mockEntry = new MockEntry(mockFileSystem, '/test.jpg'); | 7 var mockEntry = new MockEntry(mockFileSystem, '/test.jpg'); |
8 | 8 |
9 // Item has full size cache. | 9 // Item has full size cache. |
10 var itemWithFullCache = new Gallery.Item(mockEntry, null, {}, null, false); | 10 var itemWithFullCache = new GalleryItem(mockEntry, null, {}, null, false); |
11 itemWithFullCache.contentImage = document.createElement('canvas'); | 11 itemWithFullCache.contentImage = document.createElement('canvas'); |
12 assertEquals( | 12 assertEquals( |
13 ImageView.LoadTarget.CACHED_MAIN_IMAGE, | 13 ImageView.LoadTarget.CACHED_MAIN_IMAGE, |
14 ImageView.getLoadTarget(itemWithFullCache, new ImageView.Effect.None())); | 14 ImageView.getLoadTarget(itemWithFullCache, new ImageView.Effect.None())); |
15 | 15 |
16 // Item has screen size cache. | 16 // Item has screen size cache. |
17 var itemWithScreenCache = new Gallery.Item(mockEntry, null, {}, null, false); | 17 var itemWithScreenCache = new GalleryItem(mockEntry, null, {}, null, false); |
18 itemWithScreenCache.screenImage = document.createElement('canvas'); | 18 itemWithScreenCache.screenImage = document.createElement('canvas'); |
19 assertEquals( | 19 assertEquals( |
20 ImageView.LoadTarget.CACHED_THUMBNAIL, | 20 ImageView.LoadTarget.CACHED_THUMBNAIL, |
21 ImageView.getLoadTarget( | 21 ImageView.getLoadTarget( |
22 itemWithScreenCache, new ImageView.Effect.None())); | 22 itemWithScreenCache, new ImageView.Effect.None())); |
23 | 23 |
24 // Item with content thumbnail. | 24 // Item with content thumbnail. |
25 var itemWithContentThumbnail = new Gallery.Item( | 25 var itemWithContentThumbnail = new GalleryItem( |
26 mockEntry, null, {thumbnail: {url: 'url'}}, null, false); | 26 mockEntry, null, {thumbnail: {url: 'url'}}, null, false); |
27 assertEquals( | 27 assertEquals( |
28 ImageView.LoadTarget.THUMBNAIL, | 28 ImageView.LoadTarget.THUMBNAIL, |
29 ImageView.getLoadTarget( | 29 ImageView.getLoadTarget( |
30 itemWithContentThumbnail, new ImageView.Effect.None())); | 30 itemWithContentThumbnail, new ImageView.Effect.None())); |
31 | 31 |
32 // Item with external thumbnail. | 32 // Item with external thumbnail. |
33 var itemWithExternalThumbnail = new Gallery.Item( | 33 var itemWithExternalThumbnail = new GalleryItem( |
34 mockEntry, null, {external: {thumbnailUrl: 'url'}}, null, false); | 34 mockEntry, null, {external: {thumbnailUrl: 'url'}}, null, false); |
35 assertEquals( | 35 assertEquals( |
36 ImageView.LoadTarget.THUMBNAIL, | 36 ImageView.LoadTarget.THUMBNAIL, |
37 ImageView.getLoadTarget( | 37 ImageView.getLoadTarget( |
38 itemWithExternalThumbnail, new ImageView.Effect.None())); | 38 itemWithExternalThumbnail, new ImageView.Effect.None())); |
39 | 39 |
40 // Item with external thumbnail but present localy. | 40 // Item with external thumbnail but present localy. |
41 var itemWithExternalThumbnailPresent = new Gallery.Item( | 41 var itemWithExternalThumbnailPresent = new GalleryItem( |
42 mockEntry, null, {external: {thumbnailUrl: 'url', present: true}}, null, | 42 mockEntry, null, {external: {thumbnailUrl: 'url', present: true}}, null, |
43 false); | 43 false); |
44 assertEquals( | 44 assertEquals( |
45 ImageView.LoadTarget.MAIN_IMAGE, | 45 ImageView.LoadTarget.MAIN_IMAGE, |
46 ImageView.getLoadTarget( | 46 ImageView.getLoadTarget( |
47 itemWithExternalThumbnailPresent, new ImageView.Effect.None())); | 47 itemWithExternalThumbnailPresent, new ImageView.Effect.None())); |
48 | 48 |
49 // Item with external thumbnail shown by slide effect. | 49 // Item with external thumbnail shown by slide effect. |
50 var itemWithExternalThumbnailSlide = new Gallery.Item( | 50 var itemWithExternalThumbnailSlide = new GalleryItem( |
51 mockEntry, null, {external: {thumbnailUrl: 'url'}}, null, false); | 51 mockEntry, null, {external: {thumbnailUrl: 'url'}}, null, false); |
52 assertEquals( | 52 assertEquals( |
53 ImageView.LoadTarget.THUMBNAIL, | 53 ImageView.LoadTarget.THUMBNAIL, |
54 ImageView.getLoadTarget( | 54 ImageView.getLoadTarget( |
55 itemWithExternalThumbnailSlide, new ImageView.Effect.Slide(1))); | 55 itemWithExternalThumbnailSlide, new ImageView.Effect.Slide(1))); |
56 | 56 |
57 // Item with external thumbnail shown by zoom effect. | 57 // Item with external thumbnail shown by zoom effect. |
58 var itemWithExternalThumbnailZoom = new Gallery.Item( | 58 var itemWithExternalThumbnailZoom = new GalleryItem( |
59 mockEntry, null, {external: {thumbnailUrl: 'url'}}, null, false); | 59 mockEntry, null, {external: {thumbnailUrl: 'url'}}, null, false); |
60 assertEquals( | 60 assertEquals( |
61 ImageView.LoadTarget.MAIN_IMAGE, | 61 ImageView.LoadTarget.MAIN_IMAGE, |
62 ImageView.getLoadTarget( | 62 ImageView.getLoadTarget( |
63 itemWithExternalThumbnailZoom, | 63 itemWithExternalThumbnailZoom, |
64 new ImageView.Effect.Zoom(0, 0, null))); | 64 new ImageView.Effect.Zoom(0, 0, null))); |
65 | 65 |
66 // Item without cache/thumbnail. | 66 // Item without cache/thumbnail. |
67 var itemWithoutCacheOrThumbnail = new Gallery.Item( | 67 var itemWithoutCacheOrThumbnail = new GalleryItem( |
68 mockEntry, null, {}, null, false); | 68 mockEntry, null, {}, null, false); |
69 assertEquals( | 69 assertEquals( |
70 ImageView.LoadTarget.MAIN_IMAGE, | 70 ImageView.LoadTarget.MAIN_IMAGE, |
71 ImageView.getLoadTarget( | 71 ImageView.getLoadTarget( |
72 itemWithoutCacheOrThumbnail, new ImageView.Effect.None)); | 72 itemWithoutCacheOrThumbnail, new ImageView.Effect.None)); |
73 } | 73 } |
OLD | NEW |