Skip to content

Commit 01ed96b

Browse files
ashishkumar468maskaravivek
authored andcommitted
Added unit-tests to cover all possible tags from preferences (commons-app#3253)
1 parent dd578f7 commit 01ed96b

File tree

1 file changed

+70
-2
lines changed

1 file changed

+70
-2
lines changed

app/src/test/kotlin/fr/free/nrw/commons/upload/FileMetadataUtilsTest.kt

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,81 @@ import java.util.*
1111
class FileMetadataUtilsTest {
1212

1313
/**
14-
* Test method to verify EXIF tags
14+
* Test method to verify EXIF tags for "Author"
1515
*/
1616
@Test
17-
fun getTagsFromPref() {
17+
fun getTagsFromPrefAuthor() {
1818
val author = FileMetadataUtils.getTagsFromPref("Author")
1919
val authorRef = arrayOf(TAG_ARTIST, TAG_CAMARA_OWNER_NAME);
2020

2121
assertTrue(Arrays.deepEquals(author, authorRef))
2222
}
23+
24+
/**
25+
* Test method to verify EXIF tags for "Location"
26+
*/
27+
@Test
28+
fun getTagsFromPrefLocation() {
29+
val author = FileMetadataUtils.getTagsFromPref("Location")
30+
val authorRef = arrayOf(TAG_GPS_LATITUDE, TAG_GPS_LATITUDE_REF,
31+
TAG_GPS_LONGITUDE, TAG_GPS_LONGITUDE_REF,
32+
TAG_GPS_ALTITUDE, TAG_GPS_ALTITUDE_REF)
33+
34+
assertTrue(Arrays.deepEquals(author, authorRef))
35+
}
36+
37+
/**
38+
* Test method to verify EXIF tags for "Copyright"
39+
*/
40+
@Test
41+
fun getTagsFromPrefCopyWright() {
42+
val author = FileMetadataUtils.getTagsFromPref("Copyright")
43+
val authorRef = arrayOf(TAG_COPYRIGHT)
44+
45+
assertTrue(Arrays.deepEquals(author, authorRef))
46+
}
47+
48+
/**
49+
* Test method to verify EXIF tags for "Camera Model"
50+
*/
51+
@Test
52+
fun getTagsFromPrefCameraModel() {
53+
val author = FileMetadataUtils.getTagsFromPref("Camera Model")
54+
val authorRef = arrayOf(TAG_MAKE, TAG_MODEL)
55+
56+
assertTrue(Arrays.deepEquals(author, authorRef))
57+
}
58+
59+
/**
60+
* Test method to verify EXIF tags for "Lens Model"
61+
*/
62+
@Test
63+
fun getTagsFromPrefLensModel() {
64+
val author = FileMetadataUtils.getTagsFromPref("Lens Model")
65+
val authorRef = arrayOf(TAG_LENS_MAKE, TAG_LENS_MODEL, TAG_LENS_SPECIFICATION)
66+
67+
assertTrue(Arrays.deepEquals(author, authorRef))
68+
}
69+
70+
/**
71+
* Test method to verify EXIF tags for "Serial Numbers"
72+
*/
73+
@Test
74+
fun getTagsFromPrefSerialNumbers() {
75+
val author = FileMetadataUtils.getTagsFromPref("Serial Numbers")
76+
val authorRef = arrayOf(TAG_BODY_SERIAL_NUMBER, TAG_LENS_SERIAL_NUMBER)
77+
78+
assertTrue(Arrays.deepEquals(author, authorRef))
79+
}
80+
81+
/**
82+
* Test method to verify EXIF tags for "Software"
83+
*/
84+
@Test
85+
fun getTagsFromPrefSoftware() {
86+
val author = FileMetadataUtils.getTagsFromPref("Software")
87+
val authorRef = arrayOf(TAG_SOFTWARE)
88+
89+
assertTrue(Arrays.deepEquals(author, authorRef))
90+
}
2391
}

0 commit comments

Comments
 (0)