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 'use strict'; | 4 'use strict'; |
5 | 5 |
6 /** | 6 /** |
7 * Test case for ordinal exif encoding and decoding. | 7 * Test case for ordinal exif encoding and decoding. |
8 */ | 8 */ |
9 function testExifEncodeAndDecode() { | 9 function testExifEncodeAndDecode() { |
10 var canvas = getSampleCanvas(); | 10 var canvas = getSampleCanvas(); |
11 var data = canvas.toDataURL('image/jpeg'); | 11 var data = canvas.toDataURL('image/jpeg'); |
12 | 12 |
13 var metadata = { | 13 var metadata = { |
14 media: { | 14 mediaMimeType: 'image/jpeg', |
15 mimeType: 'image/jpeg', | 15 modificationTime: new Date(2015, 0, 7, 15, 30, 6), |
16 ifd: { | 16 ifd: { |
17 image: { | 17 image: { |
18 // Manufacture | 18 // Manufacture |
19 271: { | 19 271: { |
20 id: 0x10f, | 20 id: 0x10f, |
21 format: 2, | 21 format: 2, |
22 componentCount: 12, | 22 componentCount: 12, |
23 value: 'Manufacture\0' | 23 value: 'Manufacture\0' |
24 }, | |
25 // Device model | |
26 272: { | |
27 id: 0x110, | |
28 format: 2, | |
29 componentCount: 12, | |
30 value: 'DeviceModel\0' | |
31 }, | |
32 // GPS Pointer | |
33 34853: { | |
34 id: 0x8825, | |
35 format: 4, | |
36 componentCount: 1, | |
37 value: 0 // The value is set by the encoder. | |
38 } | |
39 }, | 24 }, |
40 exif: { | 25 // Device model |
41 // Lens model | 26 272: { |
42 42036: { | 27 id: 0x110, |
43 id: 0xa434, | 28 format: 2, |
44 format: 2, | 29 componentCount: 12, |
45 componentCount: 10, | 30 value: 'DeviceModel\0' |
46 value: 'LensModel\0' | |
47 } | |
48 }, | 31 }, |
49 gps: { | 32 // GPS Pointer |
50 // GPS latitude ref | 33 34853: { |
51 1: { | 34 id: 0x8825, |
52 id: 0x1, | 35 format: 4, |
53 format: 2, | 36 componentCount: 1, |
54 componentCount: 2, | 37 value: 0 // The value is set by the encoder. |
55 value: 'N\0' | 38 } |
56 } | 39 }, |
| 40 exif: { |
| 41 // Lens model |
| 42 42036: { |
| 43 id: 0xa434, |
| 44 format: 2, |
| 45 componentCount: 10, |
| 46 value: 'LensModel\0' |
| 47 } |
| 48 }, |
| 49 gps: { |
| 50 // GPS latitude ref |
| 51 1: { |
| 52 id: 0x1, |
| 53 format: 2, |
| 54 componentCount: 2, |
| 55 value: 'N\0' |
57 } | 56 } |
58 } | 57 } |
59 } | 58 } |
60 }; | 59 }; |
61 | 60 |
62 var encoder = ImageEncoder.encodeMetadata(metadata, canvas, 1, | 61 var encoder = ImageEncoder.encodeMetadata(metadata, canvas, 1); |
63 new Date(2015, 0, 7, 15, 30, 6)); | |
64 | 62 |
65 // Assert that ExifEncoder is returned. | 63 // Assert that ExifEncoder is returned. |
66 assertTrue(encoder instanceof ExifEncoder); | 64 assertTrue(encoder instanceof ExifEncoder); |
67 | 65 |
68 var encodedResult = encoder.encode(); | 66 var encodedResult = encoder.encode(); |
69 | 67 |
70 // Decode encoded exif data. | 68 // Decode encoded exif data. |
71 var exifParser = new ExifParser(this); | 69 var exifParser = new ExifParser(this); |
72 | 70 |
73 // Redirect .log and .vlog to console.log for debugging. | 71 // Redirect .log and .vlog to console.log for debugging. |
(...skipping 26 matching lines...) Expand all Loading... |
100 assertEquals('N\0', parsedMetadata.ifd.gps[0x1].value); | 98 assertEquals('N\0', parsedMetadata.ifd.gps[0x1].value); |
101 | 99 |
102 // Software should be set as Gallery.app | 100 // Software should be set as Gallery.app |
103 assertEquals('Chrome OS Gallery App\0', | 101 assertEquals('Chrome OS Gallery App\0', |
104 parsedMetadata.ifd.image[0x131].value); | 102 parsedMetadata.ifd.image[0x131].value); |
105 | 103 |
106 // Datetime should be updated. | 104 // Datetime should be updated. |
107 assertEquals('2015:01:07 15:30:06\0', parsedMetadata.ifd.image[0x132].value); | 105 assertEquals('2015:01:07 15:30:06\0', parsedMetadata.ifd.image[0x132].value); |
108 | 106 |
109 // Thumbnail image | 107 // Thumbnail image |
110 assert(parsedMetadata.thumbnailTransform); | 108 assertTrue(!!parsedMetadata.thumbnailTransform); |
111 assert(parsedMetadata.thumbnailURL); | 109 assertTrue(!!parsedMetadata.thumbnailURL); |
112 } | 110 } |
OLD | NEW |