Commit 4cf1f7c9 authored by Ivan Frade's avatar Ivan Frade

tests/libtracker-extract: Unit tests for tracker-exif

parent 32e348fb
......@@ -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
#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 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment