[grilo-plugins] tests: local-metadata: Add test



commit 7989e2aed6be9e483b4e9be63ce594173b38912d
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Fri Jun 7 23:27:13 2013 +0000

    tests: local-metadata: Add test
    
    Tests if thumbnail can be obtained from local content.

 test/Makefile.am           |   56 ++++---
 test/main.c                |  412 --------------------------------------------
 test/test_local_metadata.c |   20 ++-
 3 files changed, 42 insertions(+), 446 deletions(-)
---
diff --git a/test/Makefile.am b/test/Makefile.am
index 1cbf21b..77e0144 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -7,29 +7,30 @@
 
 INCLUDES = @DEPS_CFLAGS@
 
-check_tests = test_tmdb_preconditions \
-       test_tmdb_missing_configuration \
-       test_tmdb_fast_resolution \
-       test_tmdb_fast_resolution_by_id \
-       test_tmdb_full_resolution
+TESTS =
 
-# TODO: Add test_local_metadata to check_tests when it runs without errors.
-check_PROGRAMS = test_local_metadata \
-       $(check_tests)
-TESTS =        $(check_tests)
+if LOCALMETADATA_PLUGIN
+TESTS +=       \
+       test_local_metadata
+endif
 
-#noinst_PROGRAMS += test
+if TMDB_PLUGIN
+TESTS +=                                                                               \
+       test_tmdb_fast_resolution                       \
+       test_tmdb_fast_resolution_by_id \
+       test_tmdb_full_resolution                       \
+       test_tmdb_missing_configuration \
+       test_tmdb_preconditions
+endif
 
-#test_SOURCES =        \
-#      main.c
-#
-#test_CFLAGS = \
-#      -DPREFIX=$(prefix)
-#
-#test_LDADD =          \
-#      @DEPS_LIBS@
-#
+check_PROGRAMS = $(TESTS)
 
+# Let the .c source code know about these paths,
+# even when sourcedir!=builddir, such as during make distcheck:
+#
+# We could set GRL_PLUGIN_PATH here in TESTS_ENVIRONMENT, specifying all the paths (separated by :) to all 
the plugins,
+# but it is cleaner to restrict the test to just one plugin by doing it in the code.
+# Note that the tmdb plugin Makefile.am copies the .xml file into .libs so we can use the plugin.
 test_local_metadata_defines = \
        -DGRILO_PLUGINS_TESTS_LOCAL_METADATA_PLUGIN_PATH=\""$(abs_top_builddir)/src/local-metadata/.libs/"\"
 
@@ -46,12 +47,6 @@ test_local_metadata_CFLAGS = \
        @GTHREAD_CFLAGS@ \
        @GIO_CFLAGS@
 
-# Let the .c source code know about these paths,
-# even when sourcedir!=builddir, such as during make distcheck:
-#
-# We could set GRL_PLUGIN_PATH here in TESTS_ENVIRONMENT, specifying all the paths (separated by :) to all 
the plugins,
-# but it is cleaner to restrict the test to just one plugin by doing it in the code.
-# Note that the tmdb plugin Makefile.am copies the .xml file into .libs so we can use the plugin.
 test_tmdb_defines = \
        -DGRILO_PLUGINS_TESTS_TMDB_PLUGIN_PATH=\""$(abs_top_builddir)/src/tmdb/.libs/"\" \
        -DGRILO_PLUGINS_TESTS_TMDB_DATA_PATH=\""$(abs_top_srcdir)/test/test_data/tmdb/"\"
@@ -59,40 +54,51 @@ test_tmdb_defines = \
 test_tmdb_preconditions_SOURCES = \
        test_tmdb_preconditions.c \
        test_tmdb_utils.h test_tmdb_utils.c
+
 test_tmdb_preconditions_LDADD = \
        @DEPS_LIBS@
+
 test_tmdb_preconditions_CFLAGS = \
        -DPREFIX=$(prefix) $(test_tmdb_defines)
 
+
 test_tmdb_missing_configuration_SOURCES = \
        test_tmdb_missing_configuration.c \
        test_tmdb_utils.h test_tmdb_utils.c
+
 test_tmdb_missing_configuration_LDADD = \
        @DEPS_LIBS@
+
 test_tmdb_missing_configuration_CFLAGS = \
        -DPREFIX=$(prefix) $(test_tmdb_defines)
 
 test_tmdb_fast_resolution_SOURCES = \
        test_tmdb_fast_resolution.c \
        test_tmdb_utils.h test_tmdb_utils.c
+
 test_tmdb_fast_resolution_LDADD = \
        @DEPS_LIBS@
+
 test_tmdb_fast_resolution_CFLAGS = \
        -DPREFIX=$(prefix) $(test_tmdb_defines)
 
 test_tmdb_fast_resolution_by_id_SOURCES = \
        test_tmdb_fast_resolution_by_id.c \
        test_tmdb_utils.h test_tmdb_utils.c
+
 test_tmdb_fast_resolution_by_id_LDADD = \
        @DEPS_LIBS@
+
 test_tmdb_fast_resolution_by_id_CFLAGS = \
        -DPREFIX=$(prefix) $(test_tmdb_defines)
 
 test_tmdb_full_resolution_SOURCES = \
        test_tmdb_full_resolution.c \
        test_tmdb_utils.h test_tmdb_utils.c
+
 test_tmdb_full_resolution_LDADD = \
        @DEPS_LIBS@
+
 test_tmdb_full_resolution_CFLAGS = \
        -DPREFIX=$(prefix) $(test_tmdb_defines)
 
diff --git a/test/test_local_metadata.c b/test/test_local_metadata.c
index c21d27a..82a49bc 100644
--- a/test/test_local_metadata.c
+++ b/test/test_local_metadata.c
@@ -154,9 +154,7 @@ setup (void)
   grl_registry_load_all_plugins (registry, &error);
   g_assert_no_error (error);
 
-  local_source =
-    GRL_SOURCE (grl_registry_lookup_source (registry,
-                                            LOCAL_SOURCE_ID));
+  local_source = grl_registry_lookup_source (registry, LOCAL_SOURCE_ID);
 
 finish:
   return ret;
@@ -184,6 +182,7 @@ static gboolean
 test_image_thumbnail (void)
 {
   GrlMedia *media = NULL;
+  GrlOperationOptions *options;
   GError *error = NULL;
   GList *keys = NULL;
   gboolean ret = TRUE;
@@ -198,8 +197,9 @@ test_image_thumbnail (void)
 
   keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
 
-  media = grl_source_resolve_sync (GRL_SOURCE (local_source), media, keys,
-                                   GRL_RESOLVE_NORMAL, &error);
+  options = grl_operation_options_new (NULL);
+  grl_operation_options_set_flags (options, GRL_RESOLVE_NORMAL);
+  media = grl_source_resolve_sync (local_source, media, keys, options, &error);
   if (error) {
     g_clear_error (&error);
     ret = FALSE;
@@ -225,7 +225,7 @@ cleanup:
     g_free (expected_thumbnail_path);
   if (expected_thumbnail_uri)
     g_free (expected_thumbnail_uri);
-
+  g_object_unref (options);
   return ret;
 }
 
@@ -233,6 +233,7 @@ static gboolean
 test_image_no_thumbnail (void)
 {
   GrlMedia *media = NULL;
+  GrlOperationOptions *options;
   GError *error = NULL;
   GList *keys = NULL;
   gboolean ret = TRUE;
@@ -242,8 +243,9 @@ test_image_no_thumbnail (void)
 
   keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
 
-  media = grl_source_resolve_sync (GRL_SOURCE (local_source), media, keys,
-                                   GRL_RESOLVE_NORMAL, &error);
+  options = grl_operation_options_new (NULL);
+  grl_operation_options_set_flags (options, GRL_RESOLVE_NORMAL);
+  media = grl_source_resolve_sync (local_source, media, keys, options, &error);
   if (error) {
     g_clear_error (&error);
     ret = FALSE;
@@ -260,7 +262,7 @@ cleanup:
     g_object_unref (media);
   if (keys)
     g_list_free (keys);
-
+  g_object_unref (options);
   return ret;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]