Commit 2c81eca7 authored by Saurabh Sabharwal's avatar Saurabh Sabharwal
Browse files

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.
parent c07d6ffc
Pipeline #21455 passed with stage
in 3 minutes and 3 seconds
......@@ -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);
......
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