diff options
author | Earl Ou <shunhsingou@google.com> | 2012-08-03 13:26:35 +0800 |
---|---|---|
committer | Earl Ou <shunhsingou@google.com> | 2012-08-06 17:16:23 +0800 |
commit | bdcdb15ad345633bbab6505207008f018059f107 (patch) | |
tree | b59cebd0559750ec57dc3dc86b0253dbbb02e014 /tests/src | |
parent | 9fae341c1a958285d93d86698ea7ff28dc4bde89 (diff) | |
download | android_packages_apps_Camera2-bdcdb15ad345633bbab6505207008f018059f107.tar.gz android_packages_apps_Camera2-bdcdb15ad345633bbab6505207008f018059f107.tar.bz2 android_packages_apps_Camera2-bdcdb15ad345633bbab6505207008f018059f107.zip |
Remove TYPE_SUB_IFD for next() in IfdParser
We should not read the offset because there are
too many exception. Users should check the id of the tag
and decide how to read the block by themselves.
Change-Id: Ie3f162c5c6dc25f15107e193adc080c7b51112b5
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/gallery3d/exif/ExifParserTest.java | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/tests/src/com/android/gallery3d/exif/ExifParserTest.java b/tests/src/com/android/gallery3d/exif/ExifParserTest.java index 3c9d276e5..a2c53831f 100644 --- a/tests/src/com/android/gallery3d/exif/ExifParserTest.java +++ b/tests/src/com/android/gallery3d/exif/ExifParserTest.java @@ -120,8 +120,10 @@ public class ExifParserTest extends ActivityTestCase { switch (type) { case IfdParser.TYPE_NEW_TAG: ExifTag tag = ifdParser.readTag(); - if (tag.getOffset() > 0) { - ifdParser.waitValueOfTag(tag); + if (tag.getDataSize() > 4 || tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { + long offset = ifdParser.readUnsignedInt(); + assertTrue(offset <= Integer.MAX_VALUE); + ifdParser.waitValueOfTag(tag, offset); } else { checkTag(tag, ifdParser, IFD0_VALUE); tagNumber++; @@ -130,14 +132,14 @@ public class ExifParserTest extends ActivityTestCase { case IfdParser.TYPE_NEXT_IFD: parseIfd1(ifdParser.parseIfdBlock()); break; - case IfdParser.TYPE_SUB_IFD: - assertEquals(ExifTag.TIFF_TAG.TAG_EXIF_IFD, - ifdParser.getCorrespodingExifTag().getTagId()); - parseExifIfd(ifdParser.parseIfdBlock()); - break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: - checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, IFD0_VALUE); - tagNumber++; + tag = ifdParser.getCorrespodingExifTag(); + if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { + parseExifIfd(ifdParser.parseIfdBlock()); + } else { + checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, IFD0_VALUE); + tagNumber++; + } break; } type = ifdParser.next(); @@ -153,8 +155,10 @@ public class ExifParserTest extends ActivityTestCase { switch (type) { case IfdParser.TYPE_NEW_TAG: ExifTag tag = ifdParser.readTag(); - if (tag.getOffset() > 0) { - ifdParser.waitValueOfTag(tag); + if (tag.getDataSize() > 4) { + long offset = ifdParser.readUnsignedInt(); + assertTrue(offset <= Integer.MAX_VALUE); + ifdParser.waitValueOfTag(tag, offset); } else { checkTag(tag, ifdParser, IFD1_VALUE); tagNumber++; @@ -163,9 +167,6 @@ public class ExifParserTest extends ActivityTestCase { case IfdParser.TYPE_NEXT_IFD: fail("Find a ifd after ifd1"); break; - case IfdParser.TYPE_SUB_IFD: - fail("Find a sub ifd in ifd1"); - break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, IFD1_VALUE); tagNumber++; @@ -184,8 +185,10 @@ public class ExifParserTest extends ActivityTestCase { switch (type) { case IfdParser.TYPE_NEW_TAG: ExifTag tag = ifdParser.readTag(); - if (tag.getOffset() > 0) { - ifdParser.waitValueOfTag(tag); + if (tag.getDataSize() > 4) { + long offset = ifdParser.readUnsignedInt(); + assertTrue(offset <= Integer.MAX_VALUE); + ifdParser.waitValueOfTag(tag, offset); } else { checkTag(tag, ifdParser, EXIF_IFD_VALUE); tagNumber++; @@ -194,9 +197,6 @@ public class ExifParserTest extends ActivityTestCase { case IfdParser.TYPE_NEXT_IFD: fail("Find a ifd after exif ifd"); break; - case IfdParser.TYPE_SUB_IFD: - fail("Find a sub ifd in exif ifd"); - break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, EXIF_IFD_VALUE); tagNumber++; @@ -282,10 +282,6 @@ public class ExifParserTest extends ActivityTestCase { case IfdParser.TYPE_NEXT_IFD: parseIfd1(ifdParser.parseIfdBlock()); break; - case IfdParser.TYPE_SUB_IFD: - // We won't get this since to skip everything - fail("Get sub ifd but we've skip everything"); - break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: // We won't get this since to skip everything fail("Get value of previous tag but we've skip everything"); @@ -304,23 +300,25 @@ public class ExifParserTest extends ActivityTestCase { case IfdParser.TYPE_NEW_TAG: ExifTag tag = ifdParser.readTag(); // only interested in these two tags - if (tag.getOffset() > 0) { + if (tag.getDataSize() > 4 || tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_MODEL || tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { - ifdParser.waitValueOfTag(tag); + long offset = ifdParser.readUnsignedInt(); + assertTrue(offset <= Integer.MAX_VALUE); + ifdParser.waitValueOfTag(tag, offset); } } break; case IfdParser.TYPE_NEXT_IFD: parseIfd1(ifdParser.parseIfdBlock()); break; - case IfdParser.TYPE_SUB_IFD: - assertEquals(ExifTag.TIFF_TAG.TAG_EXIF_IFD, - ifdParser.getCorrespodingExifTag().getTagId()); - parseExifIfd(ifdParser.parseIfdBlock()); - break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: - checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, IFD0_VALUE); + tag = ifdParser.getCorrespodingExifTag(); + if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { + parseExifIfd(ifdParser.parseIfdBlock()); + } else { + checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, IFD0_VALUE); + } break; } type = ifdParser.next(); |