summaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/gallery3d/exif/ExifParserTest.java9
-rw-r--r--tests/src/com/android/gallery3d/exif/ExifReaderTest.java7
-rw-r--r--tests/src/com/android/gallery3d/exif/ExifXmlReader.java22
3 files changed, 21 insertions, 17 deletions
diff --git a/tests/src/com/android/gallery3d/exif/ExifParserTest.java b/tests/src/com/android/gallery3d/exif/ExifParserTest.java
index eb5a574..422d127 100644
--- a/tests/src/com/android/gallery3d/exif/ExifParserTest.java
+++ b/tests/src/com/android/gallery3d/exif/ExifParserTest.java
@@ -21,7 +21,6 @@ import android.graphics.BitmapFactory;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class ExifParserTest extends ExifXmlDataTestCase {
private static final String TAG = "ExifParserTest";
@@ -34,7 +33,7 @@ public class ExifParserTest extends ExifXmlDataTestCase {
super(imgPath, xmlPath);
}
- private List<Map<Short, Set<String>>> mGroundTruth;
+ private List<Map<Short, List<String>>> mGroundTruth;
@Override
public void setUp() throws Exception {
@@ -76,7 +75,7 @@ public class ExifParserTest extends ExifXmlDataTestCase {
}
private void checkTag(ExifTag tag) {
- Set<String> truth = mGroundTruth.get(tag.getIfd()).get(tag.getTagId());
+ List<String> truth = mGroundTruth.get(tag.getIfd()).get(tag.getTagId());
if (truth == null) {
fail(String.format("Unknown Tag %02x", tag.getTagId()) + ", " + getImageTitle());
@@ -93,7 +92,7 @@ public class ExifParserTest extends ExifXmlDataTestCase {
private void parseOneIfd(int ifd, int options) throws Exception {
try {
- Map<Short, Set<String>> expectedResult = mGroundTruth.get(ifd);
+ Map<Short, List<String>> expectedResult = mGroundTruth.get(ifd);
int numOfTag = 0;
ExifParser parser = ExifParser.parse(getImageInputStream(), options);
int event = parser.next();
@@ -127,7 +126,7 @@ public class ExifParserTest extends ExifXmlDataTestCase {
}
event = parser.next();
}
- assertEquals(expectedResult.size(), numOfTag);
+ assertEquals(getImageTitle(), ExifXmlReader.getTrueTagNumber(expectedResult), numOfTag);
} catch (Exception e) {
throw new Exception(getImageTitle(), e);
}
diff --git a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
index 82dcdc7..4049462 100644
--- a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
+++ b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
@@ -20,7 +20,6 @@ import android.graphics.BitmapFactory;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class ExifReaderTest extends ExifXmlDataTestCase {
private static final String TAG = "ExifReaderTest";
@@ -37,7 +36,7 @@ public class ExifReaderTest extends ExifXmlDataTestCase {
try {
ExifReader reader = new ExifReader();
ExifData exifData = reader.read(getImageInputStream());
- List<Map<Short, Set<String>>> groundTruth = ExifXmlReader.readXml(getXmlParser());
+ List<Map<Short, List<String>>> groundTruth = ExifXmlReader.readXml(getXmlParser());
for (int i = 0; i < IfdId.TYPE_IFD_COUNT; i++) {
checkIfd(exifData.getIfdData(i), groundTruth.get(i));
}
@@ -105,14 +104,14 @@ public class ExifReaderTest extends ExifXmlDataTestCase {
}
}
- private void checkIfd(IfdData ifd, Map<Short, Set<String>> ifdValue) {
+ private void checkIfd(IfdData ifd, Map<Short, List<String>> ifdValue) {
if (ifd == null) {
assertEquals(getImageTitle(), 0 ,ifdValue.size());
return;
}
ExifTag[] tags = ifd.getAllTags();
for (ExifTag tag : tags) {
- Set<String> truth = ifdValue.get(tag.getTagId());
+ List<String> truth = ifdValue.get(tag.getTagId());
assertNotNull(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(), truth);
if (truth.contains(null)) continue;
assertTrue(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(),
diff --git a/tests/src/com/android/gallery3d/exif/ExifXmlReader.java b/tests/src/com/android/gallery3d/exif/ExifXmlReader.java
index 5d19709..bb08ccd 100644
--- a/tests/src/com/android/gallery3d/exif/ExifXmlReader.java
+++ b/tests/src/com/android/gallery3d/exif/ExifXmlReader.java
@@ -22,10 +22,8 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class ExifXmlReader {
private static final String TAG_EXIF = "exif";
@@ -48,13 +46,13 @@ public class ExifXmlReader {
* @throws XmlPullParserException
* @throws IOException
*/
- static public List<Map<Short, Set<String>>> readXml(XmlPullParser parser)
+ static public List<Map<Short, List<String>>> readXml(XmlPullParser parser)
throws XmlPullParserException, IOException {
- List<Map<Short, Set<String>>> exifData =
- new ArrayList<Map<Short, Set<String>>>(IfdId.TYPE_IFD_COUNT);
+ List<Map<Short, List<String>>> exifData =
+ new ArrayList<Map<Short, List<String>>>(IfdId.TYPE_IFD_COUNT);
for (int i = 0; i < IfdId.TYPE_IFD_COUNT; i++) {
- exifData.add(new HashMap<Short, Set<String>>());
+ exifData.add(new HashMap<Short, List<String>>());
}
while (parser.next() != XmlPullParser.END_DOCUMENT) {
@@ -83,9 +81,9 @@ public class ExifXmlReader {
if (ifdId < 0) {
// TODO: the MarkerNote segment.
} else {
- Set<String> tagData = exifData.get(ifdId).get(id);
+ List<String> tagData = exifData.get(ifdId).get(id);
if (tagData == null) {
- tagData = new HashSet<String>();
+ tagData = new ArrayList<String>();
exifData.get(ifdId).put(id, tagData);
}
if (NO_VALUE.equals(value)) {
@@ -116,4 +114,12 @@ public class ExifXmlReader {
return -1;
}
}
+
+ static public int getTrueTagNumber(Map<Short, List<String>> ifdData) {
+ int size = 0;
+ for (List<String> tag: ifdData.values()) {
+ size += tag.size();
+ }
+ return size;
+ }
}