1 /*
2 * Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include <glib-object.h>
21
22 #include <libtracker-extract/tracker-extract.h>
23
24 static void
25 test_exif_parse (void)
26 {
27 TrackerExifData *exif;
28 gchar *blob;
29 gsize length;
30
31
32 g_assert (g_file_get_contents (TOP_SRCDIR "/tests/libtracker-extract/exif-img.jpg", &blob, &length, NULL));
33
34 exif = tracker_exif_new (blob, length, "test://file");
pointer targets in passing argument 1 of 'tracker_exif_new' differ in signedness
(emitted by gcc)
35
36 /* Ignored on purpose on the code (?) */
37 //g_assert_cmpstr (exif->x_dimension, ==, );
38 //g_assert_cmpstr (exif->y_dimenstion, ==, );
39 //g_assert_cmpstr (exif->image_width, ==, );
40
41 g_assert_cmpstr (exif->document_name, ==, "test-documentname");
42 //g_assert_cmpstr (exif->time, ==, "test-documentname");
43 g_assert (exif->time_original);
44 g_assert_cmpstr (exif->artist, ==, "EXIFspec"); // -Exif:Artist
45 g_assert_cmpstr (exif->user_comment, ==, "libexif demonstration image");
46 g_assert_cmpstr (exif->description, ==, "Justfortest"); //-Exif:ImageDescription
47 g_assert_cmpstr (exif->make, ==, "Nikon"); //-Exif:Make
48 g_assert_cmpstr (exif->model, ==, "SD3000"); //-Exif:Model
49 g_assert_cmpstr (exif->orientation, ==, "nfo:orientation-left-mirror"); //-n -Exif:Orientation=5
50 g_assert_cmpstr (exif->exposure_time, ==, "0.002"); // -Exif:ExposureTime=1/500
51 g_assert_cmpstr (exif->fnumber, ==, "5.6"); // -Exif:FNumber
52 g_assert_cmpstr (exif->flash, ==, "nmm:flash-off"); // -n -Exif:Flash=88
53 g_assert_cmpstr (exif->focal_length, ==, "35.0"); // -n -Exif:FocalLength=35
54 g_assert_cmpstr (exif->iso_speed_ratings, ==, "400"); // -n -Exif:ISO=400
55 g_assert_cmpstr (exif->metering_mode, ==, "nmm:metering-mode-multispot"); // -n -Exif:MeteringMode=4
56 g_assert_cmpstr (exif->white_balance, ==, "nmm:white-balance-auto"); // -n -Exif:WhiteBalance=0
57 g_assert_cmpstr (exif->copyright, ==, "From the exif demo with exiftool metadata"); // -Exif:Copyright
58 g_assert_cmpstr (exif->software, ==, "bunchof1s"); // -Exif:Software
59 g_assert_cmpstr (exif->x_resolution, ==, "72");
60 g_assert_cmpstr (exif->y_resolution, ==, "72");
61 g_assert_cmpint (exif->resolution_unit, ==, 2);
62
63 g_assert_cmpstr (exif->gps_altitude, ==, "237.000000"); // -n -exif:gpsaltitude=237
64 g_assert_cmpstr (exif->gps_latitude, ==, "-42.500000"); // -exif:gpslatitude="42 30 0.00" -exif:gpslatituderef=S
65 g_assert_cmpstr (exif->gps_longitude, ==, "-10.166675"); // -exif:gpslongitude="10 10 0.03" -exif:gpslongituderef=W
66 g_assert_cmpstr (exif->gps_direction, ==, "12.3"); // -n -Exif:GPSImgDirection=12.3
67
68 tracker_exif_free (exif);
69 }
70
71 static void
72 test_exif_parse_empty (void)
73 {
74 TrackerExifData *exif;
75 gchar *blob;
76 gsize length;
77
78 g_assert (g_file_get_contents (TOP_SRCDIR "/tests/libtracker-extract/exif-free-img.jpg", &blob, &length, NULL));
79
80 exif = tracker_exif_new (blob, length, "test://file");
pointer targets in passing argument 1 of 'tracker_exif_new' differ in signedness
(emitted by gcc)
81
82 tracker_exif_free (exif);
83 }
84
85 int
86 main (int argc, char **argv)
87 {
88 g_test_init (&argc, &argv, NULL);
89
90 g_test_add_func ("/libtracker-extract/exif/parse",
91 test_exif_parse);
92 g_test_add_func ("/libtracker-extract/exif/parse_empty",
93 test_exif_parse_empty);
94
95 return g_test_run ();
96 }