summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author1PunMan <saurabhsingh412@gmail.com>2018-06-04 23:58:14 +0530
committerVictor Toso <me@victortoso.com>2018-07-26 16:58:25 +0200
commitd11f0a0d23309060e0bb4f55c43549159da707fa (patch)
tree1cacb9733ce90a4fa447a50fd637e1298c36ca95 /tests
parentbfb35597c8bd0e1fd0d2c3a66cbc26eac64217c3 (diff)
downloadgrilo-plugins-d11f0a0d23309060e0bb4f55c43549159da707fa.tar.gz
test: Add test to check unregistered keys
This test checks whether an unregistered system key is able to register itself as a plugin specific key after source resolution. Related: https://gitlab.gnome.org/GNOME/grilo/issues/1
Diffstat (limited to 'tests')
-rw-r--r--tests/games/test_games.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/games/test_games.c b/tests/games/test_games.c
index dddc2b7..92b656e 100644
--- a/tests/games/test_games.c
+++ b/tests/games/test_games.c
@@ -267,6 +267,74 @@ test_resolve_genres_found (void)
g_object_unref (options);
}
+static void
+test_resolve_key_found (GrlRegistry *registry,
+ GrlSource *source,
+ GList *keys,
+ GrlOperationOptions *options,
+ const gchar *key_name,
+ const gchar *title,
+ const gchar *mime,
+ guint no_of_values)
+{
+ GError *error = NULL;
+ GrlMedia *media;
+ GrlKeyID key;
+ guint expected_n_values;
+
+ media = build_game_media (title);
+ grl_media_set_mime (media, mime);
+
+ grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
+
+ key = grl_registry_lookup_metadata_key (registry, key_name);
+
+ g_assert_cmpuint (key, ==, GRL_METADATA_KEY_INVALID);
+
+ grl_source_resolve_sync (source, media, keys, options, &error);
+
+ g_assert_no_error (error);
+
+ key = grl_registry_lookup_metadata_key (registry, key_name);
+
+ g_assert_cmpuint (key, !=, GRL_METADATA_KEY_INVALID);
+
+ /* We should get a value */
+ expected_n_values = grl_data_length (GRL_DATA (media), key);
+ g_assert_cmpuint (expected_n_values, ==, no_of_values);
+
+ g_object_unref (media);
+}
+
+static void
+test_resolve_keys_found (void)
+{
+ GList *keys;
+ GrlOperationOptions *options;
+ GrlRegistry *registry;
+ GrlSource *source;
+
+ registry = grl_registry_get_default ();
+ source = grl_registry_lookup_source (registry, THEGAMESDB);
+ g_assert (source);
+
+ keys = grl_metadata_key_list_new (GRL_METADATA_KEY_GENRE,
+ NULL);
+
+ options = grl_operation_options_new (NULL);
+ grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
+
+ test_resolve_key_found (registry, source, keys, options,
+ "developer",
+ "Kirby & the Amazing Mirror",
+ "application/x-gba-rom",
+ 1);
+
+ g_list_free (keys);
+ g_object_unref (options);
+}
+
+
int
main(int argc, char **argv)
{
@@ -280,6 +348,8 @@ main(int argc, char **argv)
test_setup ();
+ /* FIXME: Move tests to g_test_add() to init/deinit the registry for each test */
+ g_test_add_func ("/thegamesdb/resolve/keys-found", test_resolve_keys_found);
g_test_add_func ("/thegamesdb/resolve/good-found", test_resolve_good_found);
g_test_add_func ("/thegamesdb/resolve/thumbnails-found", test_resolve_thumbnails_found);
g_test_add_func ("/thegamesdb/resolve/genre-found", test_resolve_genres_found);