[tracker/tracker-0.12] tests/libtracker-extract: Unit tests for tracker-exif
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.12] tests/libtracker-extract: Unit tests for tracker-exif
- Date: Thu, 20 Oct 2011 12:44:25 +0000 (UTC)
commit f4fa988d8850b943becdb4c94b2fb1da1774b869
Author: Ivan Frade <ivan frade gmail com>
Date: Fri Oct 14 16:10:07 2011 +0300
tests/libtracker-extract: Unit tests for tracker-exif
tests/libtracker-extract/Makefile.am | 14 ++++-
tests/libtracker-extract/exif-free-img.jpg | Bin 0 -> 839 bytes
tests/libtracker-extract/exif-img.jpg | Bin 0 -> 1637 bytes
tests/libtracker-extract/tracker-exif-test.c | 78 ++++++++++++++++++++++++++
4 files changed, 90 insertions(+), 2 deletions(-)
---
diff --git a/tests/libtracker-extract/Makefile.am b/tests/libtracker-extract/Makefile.am
index a68ca57..1f3283d 100644
--- a/tests/libtracker-extract/Makefile.am
+++ b/tests/libtracker-extract/Makefile.am
@@ -5,7 +5,8 @@ noinst_PROGRAMS = $(TEST_PROGS)
TEST_PROGS += \
tracker-test-utils \
tracker-test-xmp \
- tracker-extract-info-test
+ tracker-extract-info-test \
+ tracker-exif-test
if HAVE_ENCA
TEST_PROGS += tracker-encoding
@@ -40,4 +41,13 @@ tracker_test_xmp_SOURCES = tracker-test-xmp.c
tracker_extract_info_test_SOURCES = tracker-extract-info-test.c
-EXTRA_DIST = encoding-detect.bin areas.xmp areas-with-contacts.xmp areas-ns.xmp nb282393.xmp nb282393_simple.xmp
+tracker_exif_test_SOURCES = tracker-exif-test.c
+
+EXTRA_DIST = encoding-detect.bin \
+ areas.xmp \
+ areas-with-contacts.xmp \
+ areas-ns.xmp \
+ nb282393.xmp \
+ nb282393_simple.xmp \
+ exif-img.jpg \
+ exif-free-img.jpg
diff --git a/tests/libtracker-extract/exif-free-img.jpg b/tests/libtracker-extract/exif-free-img.jpg
new file mode 100644
index 0000000..6ac4a45
Binary files /dev/null and b/tests/libtracker-extract/exif-free-img.jpg differ
diff --git a/tests/libtracker-extract/exif-img.jpg b/tests/libtracker-extract/exif-img.jpg
new file mode 100644
index 0000000..2a3c7cc
Binary files /dev/null and b/tests/libtracker-extract/exif-img.jpg differ
diff --git a/tests/libtracker-extract/tracker-exif-test.c b/tests/libtracker-extract/tracker-exif-test.c
new file mode 100644
index 0000000..3dc64bd
--- /dev/null
+++ b/tests/libtracker-extract/tracker-exif-test.c
@@ -0,0 +1,78 @@
+#include <glib.h>
+#include <glib-object.h>
+#include <libtracker-extract/tracker-exif.h>
+
+void
+test_exif_parse ()
+{
+ TrackerExifData *exif;
+ gchar *blob;
+ gsize length;
+
+
+ g_assert (g_file_get_contents ("./exif-img.jpg", &blob, &length, NULL));
+
+ exif = tracker_exif_new (blob, length, "test://file");
+
+ /* Ignored on purpose on the code (?) */
+ //g_assert_cmpstr (exif->x_dimension, ==, );
+ //g_assert_cmpstr (exif->y_dimenstion, ==, );
+ //g_assert_cmpstr (exif->image_width, ==, );
+
+ g_assert_cmpstr (exif->document_name, ==, "test-documentname");
+ //g_assert_cmpstr (exif->time, ==, "test-documentname");
+ g_assert_cmpstr (exif->time_original, ==, "2011-10-13T16:16:00+0300");
+ g_assert_cmpstr (exif->artist, ==, "EXIFspec"); // -Exif:Artist
+ g_assert_cmpstr (exif->user_comment, ==, "libexif demonstration image");
+ g_assert_cmpstr (exif->description, ==, "Justfortest"); //-Exif:ImageDescription
+ g_assert_cmpstr (exif->make, ==, "Nikon"); //-Exif:Make
+ g_assert_cmpstr (exif->model, ==, "SD3000"); //-Exif:Model
+ g_assert_cmpstr (exif->orientation, ==, "nfo:orientation-left-mirror"); //-n -Exif:Orientation=5
+ g_assert_cmpstr (exif->exposure_time, ==, "0.002"); // -Exif:ExposureTime=1/500
+ g_assert_cmpstr (exif->fnumber, ==, "5.6"); // -Exif:FNumber
+ g_assert_cmpstr (exif->flash, ==, "nmm:flash-off"); // -n -Exif:Flash=88
+ g_assert_cmpstr (exif->focal_length, ==, "35.0"); // -n -Exif:FocalLength=35
+ g_assert_cmpstr (exif->iso_speed_ratings, ==, "400"); // -n -Exif:ISO=400
+ g_assert_cmpstr (exif->metering_mode, ==, "nmm:metering-mode-multispot"); // -n -Exif:MeteringMode=4
+ g_assert_cmpstr (exif->white_balance, ==, "nmm:white-balance-auto"); // -n -Exif:WhiteBalance=0
+ g_assert_cmpstr (exif->copyright, ==, "From the exif demo with exiftool metadata"); // -Exif:Copyright
+ g_assert_cmpstr (exif->software, ==, "bunchof1s"); // -Exif:Software
+ g_assert_cmpstr (exif->x_resolution, ==, "72");
+ g_assert_cmpstr (exif->y_resolution, ==, "72");
+ g_assert_cmpint (exif->resolution_unit, ==, 2);
+
+ g_assert_cmpstr (exif->gps_altitude, ==, "237.000000"); // -n -exif:gpsaltitude=237
+ g_assert_cmpstr (exif->gps_latitude, ==, "-42.500000"); // -exif:gpslatitude="42 30 0.00" -exif:gpslatituderef=S
+ g_assert_cmpstr (exif->gps_longitude, ==, "-10.166675"); // -exif:gpslongitude="10 10 0.03" -exif:gpslongituderef=W
+ g_assert_cmpstr (exif->gps_direction, ==, "12.3"); // -n -Exif:GPSImgDirection=12.3
+
+ tracker_exif_free (exif);
+}
+
+void
+test_exif_parse_empty ()
+{
+ TrackerExifData *exif;
+ gchar *blob;
+ gsize length;
+
+ g_assert (g_file_get_contents ("./exif-free-img.jpg", &blob, &length, NULL));
+
+ exif = tracker_exif_new (blob, length, "test://file");
+
+ tracker_exif_free (exif);
+}
+
+int
+main (int argc, char **argv)
+{
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/libtracker-extract/exif/parse",
+ test_exif_parse);
+ g_test_add_func ("/libtracker-extract/exif/parse_empty",
+ test_exif_parse_empty);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]