summaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorEarl Ou <shunhsingou@google.com>2012-11-14 15:30:51 +0800
committerEarl Ou <shunhsingou@google.com>2012-11-14 15:30:51 +0800
commitd6db57ca0d2b1c9ba554608fdfaabb9f2afb8ce0 (patch)
tree34f97d0eb28b6fe8ece24b4ebbe1782acccdfa61 /tests/src
parent0ce848fd66a1a55984aaf1616a0bd9da2c5bb0e7 (diff)
downloadandroid_packages_apps_Snap-d6db57ca0d2b1c9ba554608fdfaabb9f2afb8ce0.zip
android_packages_apps_Snap-d6db57ca0d2b1c9ba554608fdfaabb9f2afb8ce0.tar.gz
android_packages_apps_Snap-d6db57ca0d2b1c9ba554608fdfaabb9f2afb8ce0.tar.bz2
Use getValueAt() to read different data in ExifTag
Change-Id: I4d8a72523a6ad4ae34e173c4b845a462644e83c7
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/gallery3d/exif/ExifDataTest.java6
-rw-r--r--tests/src/com/android/gallery3d/exif/ExifParserTest.java2
-rw-r--r--tests/src/com/android/gallery3d/exif/ExifReaderTest.java23
-rw-r--r--tests/src/com/android/gallery3d/exif/Util.java6
4 files changed, 14 insertions, 23 deletions
diff --git a/tests/src/com/android/gallery3d/exif/ExifDataTest.java b/tests/src/com/android/gallery3d/exif/ExifDataTest.java
index ba656bf..fed8e1e 100644
--- a/tests/src/com/android/gallery3d/exif/ExifDataTest.java
+++ b/tests/src/com/android/gallery3d/exif/ExifDataTest.java
@@ -42,13 +42,13 @@ public class ExifDataTest extends TestCase {
// check data
assertEquals("test", exifData.getTag(ExifTag.TAG_MAKE).getString());
- assertEquals(1000, exifData.getTag(ExifTag.TAG_IMAGE_WIDTH).getUnsignedLong(0));
- assertEquals(1, exifData.getTag(ExifTag.TAG_ISO_SPEED_RATINGS).getUnsignedShort(0));
+ assertEquals(1000, (int) exifData.getTag(ExifTag.TAG_IMAGE_WIDTH).getValueAt(0));
+ assertEquals(1, (int) exifData.getTag(ExifTag.TAG_ISO_SPEED_RATINGS).getValueAt(0));
assertEquals(new Rational(10, 100),
exifData.getTag(ExifTag.TAG_GPS_ALTITUDE).getRational(0));
assertEquals("inter_test",
exifData.getInteroperabilityTag(ExifTag.TAG_INTEROPERABILITY_INDEX).getString());
assertEquals("test_thumb", exifData.getThumbnailTag(ExifTag.TAG_MAKE).getString());
- assertEquals(100, exifData.getThumbnailTag(ExifTag.TAG_IMAGE_WIDTH).getUnsignedLong(0));
+ assertEquals(100, (int) exifData.getThumbnailTag(ExifTag.TAG_IMAGE_WIDTH).getValueAt(0));
}
}
diff --git a/tests/src/com/android/gallery3d/exif/ExifParserTest.java b/tests/src/com/android/gallery3d/exif/ExifParserTest.java
index e86390e..7a9d6e6 100644
--- a/tests/src/com/android/gallery3d/exif/ExifParserTest.java
+++ b/tests/src/com/android/gallery3d/exif/ExifParserTest.java
@@ -201,7 +201,7 @@ public class ExifParserTest extends ExifXmlDataTestCase {
case ExifParser.EVENT_NEW_TAG:
ExifTag tag = parser.getTag();
if (tag.getTagId() == ExifTag.TAG_COMPRESSION) {
- if (tag.getUnsignedShort(0) == ExifTag.Compression.JPEG) {
+ if (tag.getValueAt(0) == ExifTag.Compression.JPEG) {
mIsContainCompressedImage = true;
}
}
diff --git a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
index 374d5b0..30f34c0 100644
--- a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
+++ b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
@@ -64,8 +64,7 @@ public class ExifReaderTest extends ExifXmlDataTestCase {
String typeTagTruth = typeTagValue.get(0);
- ExifTag typeTag = ifd1.getTag(ExifTag.TAG_COMPRESSION);
- int type = typeTag.getUnsignedShort(0);
+ int type = (int) ifd1.getTag(ExifTag.TAG_COMPRESSION).getValueAt(0);
if (String.valueOf(ExifTag.Compression.JPEG).equals(typeTagTruth)) {
assertTrue(getImageTitle(), type == ExifTag.Compression.JPEG);
@@ -79,7 +78,7 @@ public class ExifReaderTest extends ExifXmlDataTestCase {
int planarType = ExifTag.PlanarConfiguration.CHUNKY;
ExifTag planarTag = ifd1.getTag(ExifTag.TAG_PLANAR_CONFIGURATION);
if (planarTag != null) {
- planarType = planarTag.getUnsignedShort(0);
+ planarType = (int) planarTag.getValueAt(0);
}
if (!ifd1Truth.containsKey(ExifTag.TAG_IMAGE_LENGTH) ||
@@ -91,8 +90,8 @@ public class ExifReaderTest extends ExifXmlDataTestCase {
// Fail the test if required tags are missing
if (heightTag == null || rowPerStripTag == null) fail(getImageTitle());
- int imageLength = getUnsignedIntOrShort(heightTag);
- int rowsPerStrip = getUnsignedIntOrShort(rowPerStripTag);
+ int imageLength = (int) heightTag.getValueAt(0);
+ int rowsPerStrip = (int) rowPerStripTag.getValueAt(0);
int stripCount = ifd1.getTag(
ExifTag.TAG_STRIP_OFFSETS).getComponentCount();
@@ -102,7 +101,7 @@ public class ExifReaderTest extends ExifXmlDataTestCase {
} else {
if (!ifd1Truth.containsKey(ExifTag.TAG_SAMPLES_PER_PIXEL)) return;
ExifTag samplePerPixelTag = ifd1.getTag(ExifTag.TAG_SAMPLES_PER_PIXEL);
- int samplePerPixel = samplePerPixelTag.getUnsignedShort(0);
+ int samplePerPixel = (int) samplePerPixelTag.getValueAt(0);
assertTrue(getImageTitle(),
stripCount ==
(imageLength + rowsPerStrip - 1) / rowsPerStrip * samplePerPixel);
@@ -114,23 +113,15 @@ public class ExifReaderTest extends ExifXmlDataTestCase {
for (int i = 0; i < stripCount; i++) {
if (byteCountDataType == ExifTag.TYPE_UNSIGNED_SHORT) {
assertEquals(getImageTitle(),
- byteCountTag.getUnsignedShort(i), exifData.getStrip(i).length);
+ byteCountTag.getValueAt(i), exifData.getStrip(i).length);
} else {
assertEquals(getImageTitle(),
- byteCountTag.getUnsignedLong(i), exifData.getStrip(i).length);
+ byteCountTag.getValueAt(i), exifData.getStrip(i).length);
}
}
}
}
- private int getUnsignedIntOrShort(ExifTag tag) {
- if (tag.getDataType() == ExifTag.TYPE_UNSIGNED_SHORT) {
- return tag.getUnsignedShort(0);
- } else {
- return (int) tag.getUnsignedLong(0);
- }
- }
-
private void checkIfd(IfdData ifd, Map<Short, List<String>> ifdValue) {
if (ifd == null) {
assertEquals(getImageTitle(), 0 ,ifdValue.size());
diff --git a/tests/src/com/android/gallery3d/exif/Util.java b/tests/src/com/android/gallery3d/exif/Util.java
index 6330630..0e51fd7 100644
--- a/tests/src/com/android/gallery3d/exif/Util.java
+++ b/tests/src/com/android/gallery3d/exif/Util.java
@@ -116,7 +116,7 @@ class Util {
case ExifTag.TYPE_UNSIGNED_LONG:
for(int i = 0, n = tag.getComponentCount(); i < n; i++) {
if(i != 0) sbuilder.append(" ");
- sbuilder.append(tag.getUnsignedLong(i));
+ sbuilder.append(tag.getValueAt(i));
}
break;
case ExifTag.TYPE_RATIONAL:
@@ -130,13 +130,13 @@ class Util {
case ExifTag.TYPE_UNSIGNED_SHORT:
for(int i = 0, n = tag.getComponentCount(); i < n; i++) {
if(i != 0) sbuilder.append(" ");
- sbuilder.append(tag.getUnsignedShort(i));
+ sbuilder.append((int) tag.getValueAt(i));
}
break;
case ExifTag.TYPE_LONG:
for(int i = 0, n = tag.getComponentCount(); i < n; i++) {
if(i != 0) sbuilder.append(" ");
- sbuilder.append(tag.getLong(i));
+ sbuilder.append((int) tag.getValueAt(i));
}
break;
}