• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.gallery3d.exif;
18 
19 import junit.framework.TestCase;
20 
21 import java.nio.ByteOrder;
22 
23 public class ExifDataTest extends TestCase {
testAddTag()24     public void testAddTag() {
25         ExifData exifData = new ExifData(ByteOrder.BIG_ENDIAN);
26         // IFD0 tag
27         exifData.addTag(ExifTag.TAG_MAKE).setValue("test");
28         exifData.addTag(ExifTag.TAG_IMAGE_WIDTH).setValue(1000);
29 
30         // EXIF tag
31         exifData.addTag(ExifTag.TAG_ISO_SPEED_RATINGS).setValue(1);
32 
33         // GPS tag
34         exifData.addTag(ExifTag.TAG_GPS_ALTITUDE).setValue(new Rational(10, 100));
35 
36         // Interoperability tag
37         exifData.addInteroperabilityTag(ExifTag.TAG_INTEROPERABILITY_INDEX).setValue("inter_test");
38 
39         // IFD1 tag
40         exifData.addThumbnailTag(ExifTag.TAG_MAKE).setValue("test_thumb");
41         exifData.addThumbnailTag(ExifTag.TAG_IMAGE_WIDTH).setValue(100);
42 
43         // check data
44         assertEquals("test", exifData.getTag(ExifTag.TAG_MAKE).getString());
45         assertEquals(1000, exifData.getTag(ExifTag.TAG_IMAGE_WIDTH).getUnsignedLong(0));
46         assertEquals(1, exifData.getTag(ExifTag.TAG_ISO_SPEED_RATINGS).getUnsignedShort(0));
47         assertEquals(new Rational(10, 100),
48                 exifData.getTag(ExifTag.TAG_GPS_ALTITUDE).getRational(0));
49         assertEquals("inter_test",
50                 exifData.getInteroperabilityTag(ExifTag.TAG_INTEROPERABILITY_INDEX).getString());
51         assertEquals("test_thumb", exifData.getThumbnailTag(ExifTag.TAG_MAKE).getString());
52         assertEquals(100, exifData.getThumbnailTag(ExifTag.TAG_IMAGE_WIDTH).getUnsignedLong(0));
53     }
54 }
55