Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: ui/file_manager/gallery/js/image_editor/exif_encoder_unittest.js

Issue 936143003: Start to use new metadata item in ImageEncoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ifd: {
16 ifd: { 16 image: {
17 image: { 17 // Manufacture
18 // Manufacture 18 271: {
19 271: { 19 id: 0x10f,
20 id: 0x10f, 20 format: 2,
21 format: 2, 21 componentCount: 12,
22 componentCount: 12, 22 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 }, 23 },
40 exif: { 24 // Device model
41 // Lens model 25 272: {
42 42036: { 26 id: 0x110,
43 id: 0xa434, 27 format: 2,
44 format: 2, 28 componentCount: 12,
45 componentCount: 10, 29 value: 'DeviceModel\0'
46 value: 'LensModel\0'
47 }
48 }, 30 },
49 gps: { 31 // GPS Pointer
50 // GPS latitude ref 32 34853: {
51 1: { 33 id: 0x8825,
52 id: 0x1, 34 format: 4,
53 format: 2, 35 componentCount: 1,
54 componentCount: 2, 36 value: 0 // The value is set by the encoder.
55 value: 'N\0' 37 }
56 } 38 },
39 exif: {
40 // Lens model
41 42036: {
42 id: 0xa434,
43 format: 2,
44 componentCount: 10,
45 value: 'LensModel\0'
46 }
47 },
48 gps: {
49 // GPS latitude ref
50 1: {
51 id: 0x1,
52 format: 2,
53 componentCount: 2,
54 value: 'N\0'
57 } 55 }
58 } 56 }
59 } 57 }
60 }; 58 };
61 59
62 var encoder = ImageEncoder.encodeMetadata(metadata, canvas, 1, 60 var encoder = ImageEncoder.encodeMetadata(metadata, canvas, 1);
63 new Date(2015, 0, 7, 15, 30, 6));
64 61
65 // Assert that ExifEncoder is returned. 62 // Assert that ExifEncoder is returned.
66 assertTrue(encoder instanceof ExifEncoder); 63 assertTrue(encoder instanceof ExifEncoder);
67 64
68 var encodedResult = encoder.encode(); 65 var encodedResult = encoder.encode();
69 66
70 // Decode encoded exif data. 67 // Decode encoded exif data.
71 var exifParser = new ExifParser(this); 68 var exifParser = new ExifParser(this);
72 69
73 // Redirect .log and .vlog to console.log for debugging. 70 // Redirect .log and .vlog to console.log for debugging.
(...skipping 23 matching lines...) Expand all
97 // Lens model 94 // Lens model
98 assertEquals('LensModel\0', parsedMetadata.ifd.exif[0xa434].value); 95 assertEquals('LensModel\0', parsedMetadata.ifd.exif[0xa434].value);
99 // GPS latitude ref 96 // GPS latitude ref
100 assertEquals('N\0', parsedMetadata.ifd.gps[0x1].value); 97 assertEquals('N\0', parsedMetadata.ifd.gps[0x1].value);
101 98
102 // Software should be set as Gallery.app 99 // Software should be set as Gallery.app
103 assertEquals('Chrome OS Gallery App\0', 100 assertEquals('Chrome OS Gallery App\0',
104 parsedMetadata.ifd.image[0x131].value); 101 parsedMetadata.ifd.image[0x131].value);
105 102
106 // Datetime should be updated. 103 // Datetime should be updated.
107 assertEquals('2015:01:07 15:30:06\0', parsedMetadata.ifd.image[0x132].value); 104 assertTrue(!!parsedMetadata.ifd.image[0x132].value);
yawano 2015/02/25 09:19:10 Could you check that this value is valid as exif d
hirono 2015/02/25 13:28:37 I re-thought about it and changed so that the enco
108 105
109 // Thumbnail image 106 // Thumbnail image
110 assert(parsedMetadata.thumbnailTransform); 107 assertTrue(!!parsedMetadata.thumbnailTransform);
111 assert(parsedMetadata.thumbnailURL); 108 assertTrue(!!parsedMetadata.thumbnailURL);
112 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698