summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2015-09-10 17:12:35 +0200
committerBastien Nocera <hadess@hadess.net>2015-09-14 15:08:22 +0200
commit6dc67fa5854eb5717714805a1736837316490b9f (patch)
tree906116ae70a3816753768b7c912de7a51c746542 /tests
parent37bacc5f08fcc373418837398d71728cec6b8052 (diff)
tests: Port lastfm-albumart test to test spotify-cover
Repurpose the tests to cover the Spotify cover plugin instead of the last.fm one, as the last.fm plugin now requires GOA to be instantiated. https://bugzilla.gnome.org/show_bug.cgi?id=700276
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/lastfm-albumart/Makefile.am35
-rw-r--r--tests/lastfm-albumart/data/network-data.ini11
-rw-r--r--tests/lastfm-albumart/data/resolve-good-found-default.data14
-rw-r--r--tests/lastfm-albumart/data/resolve-good-found.data82
-rw-r--r--tests/spotify-cover/Makefile.am36
-rw-r--r--tests/spotify-cover/data/network-data.ini9
-rw-r--r--tests/spotify-cover/data/resolve-bad-found.data11
-rw-r--r--tests/spotify-cover/data/resolve-good-found.data35
-rw-r--r--tests/spotify-cover/test_spotify_cover.c (renamed from tests/lastfm-albumart/test_lastfm_albumart.c)82
10 files changed, 113 insertions, 210 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7a76f7f..8750acb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,16 +13,12 @@ if DLEYNA_PLUGIN
SUBDIRS += dleyna
endif
-if LASTFM_ALBUMART_PLUGIN
-SUBDIRS += lastfm-albumart
-endif
-
if LOCALMETADATA_PLUGIN
SUBDIRS += local-metadata
endif
if LUA_FACTORY_PLUGIN
-SUBDIRS += lua-factory
+SUBDIRS += lua-factory spotify-cover
endif
if TMDB_PLUGIN
@@ -39,7 +35,7 @@ endif
DIST_SUBDIRS = \
dleyna \
- lastfm-albumart\
+ spotify-cover \
local-metadata \
lua-factory \
tmdb \
diff --git a/tests/lastfm-albumart/Makefile.am b/tests/lastfm-albumart/Makefile.am
deleted file mode 100644
index 534307c..0000000
--- a/tests/lastfm-albumart/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Makefile.am
-#
-# Author: Juan A. Suarez Romero <jasuarez@igalia.com>
-#
-# Copyright (C) 2014 Igalia S.L.
-
-include $(top_srcdir)/gtester.mk
-
-TEST_PROGS += \
- test_lastfm_albumart
-
-test_lastfm_albumart_defines = \
- -DLASTFM_ALBUMART_PLUGIN_PATH=\""$(abs_top_builddir)/src/lastfm-albumart/.libs/"\" \
- -DLASTFM_ALBUMART_DATA_PATH=\""$(abs_top_srcdir)/tests/lastfm-albumart/data/"\"
-
-test_lastfm_albumart_SOURCES = \
- test_lastfm_albumart.c
-
-test_lastfm_albumart_LDADD = \
- @DEPS_LIBS@
-
-test_lastfm_albumart_CFLAGS = \
- @DEPS_CFLAGS@ \
- $(test_lastfm_albumart_defines)
-
-# Distribute the tests data:
-dist_noinst_DATA = \
- data/network-data.ini \
- data/resolve-good-found.data \
- data/resolve-good-found-default.data
-
-noinst_PROGRAMS = $(TEST_PROGS)
-
--include $(top_srcdir)/git.mk
diff --git a/tests/lastfm-albumart/data/network-data.ini b/tests/lastfm-albumart/data/network-data.ini
deleted file mode 100644
index f46f811..0000000
--- a/tests/lastfm-albumart/data/network-data.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-[default]
-version=1
-
-[https://ws.audioscrobbler.com/1.0/album/madonna/frozen/info.xml]
-data=resolve-good-found.data
-
-[https://ws.audioscrobbler.com/1.0/album/madonna/frocen/info.xml]
-data=resolve-good-found-default.data
-
-[https://ws.audioscrobbler.com/1.0/album/madonna/unknown/info.xml]
-data=
diff --git a/tests/lastfm-albumart/data/resolve-good-found-default.data b/tests/lastfm-albumart/data/resolve-good-found-default.data
deleted file mode 100644
index 943005d..0000000
--- a/tests/lastfm-albumart/data/resolve-good-found-default.data
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<album artist="Madonna" title="Frocen">
- <reach>1</reach>
- <url>http://www.last.fm/music/Madonna/Frocen</url>
- <releasedate> </releasedate>
- <coverart>
- <small>http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_medium.png</small>
- <medium>http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_medium.png</medium>
- <large>http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_medium.png</large>
- </coverart>
- <mbid></mbid>
- <tracks>
- </tracks>
-</album> \ No newline at end of file
diff --git a/tests/lastfm-albumart/data/resolve-good-found.data b/tests/lastfm-albumart/data/resolve-good-found.data
deleted file mode 100644
index c00ed82..0000000
--- a/tests/lastfm-albumart/data/resolve-good-found.data
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<album artist="Madonna" title="Frozen">
- <reach>20831</reach>
- <url>http://www.last.fm/music/Madonna/Frozen</url>
- <releasedate> 17 Mar 1998, 00:00</releasedate>
- <coverart>
- <small>http://userserve-ak.last.fm/serve/34s/76737256.png</small>
- <medium>http://userserve-ak.last.fm/serve/64s/76737256.png</medium>
- <large>http://userserve-ak.last.fm/serve/126/76737256.png</large>
- </coverart>
- <mbid>e911cad9-dc8f-4134-8438-c392b9cf1a58</mbid>
- <tracks>
- <track title="Frozen">
- <reach>388796</reach>
- <url>http://www.last.fm/music/Madonna/_/Frozen</url>
- </track>
- <track title="Don't Cry for Me Argentina">
- <reach>55360</reach>
- <url>http://www.last.fm/music/Madonna/_/Don%27t+Cry+for+Me+Argentina</url>
- </track>
- <track title="Like a Prayer">
- <reach>487462</reach>
- <url>http://www.last.fm/music/Madonna/_/Like+a+Prayer</url>
- </track>
- <track title="You'll See">
- <reach>68196</reach>
- <url>http://www.last.fm/music/Madonna/_/You%27ll+See</url>
- </track>
- <track title="Deeper and Deeper">
- <reach>61639</reach>
- <url>http://www.last.fm/music/Madonna/_/Deeper+and+Deeper</url>
- </track>
- <track title="La Isla Bonita">
- <reach>321802</reach>
- <url>http://www.last.fm/music/Madonna/_/La+Isla+Bonita</url>
- </track>
- <track title="Take A Bonita">
- <reach>6</reach>
- <url>http://www.last.fm/music/Madonna/_/Take+A+Bonita</url>
- </track>
- <track title="Holyday">
- <reach>283</reach>
- <url>http://www.last.fm/music/+noredirect/Madonna/_/Holyday</url>
- </track>
- <track title="Crazy for You">
- <reach>167426</reach>
- <url>http://www.last.fm/music/Madonna/_/Crazy+for+You</url>
- </track>
- <track title="Material Girl">
- <reach>358192</reach>
- <url>http://www.last.fm/music/Madonna/_/Material+Girl</url>
- </track>
- <track title="Causing a Commotion">
- <reach>12784</reach>
- <url>http://www.last.fm/music/Madonna/_/Causing+a+Commotion</url>
- </track>
- <track title="You Must Love Me">
- <reach>27327</reach>
- <url>http://www.last.fm/music/Madonna/_/You+Must+Love+Me</url>
- </track>
- <track title="Papa Don't Preach">
- <reach>269903</reach>
- <url>http://www.last.fm/music/Madonna/_/Papa+Don%27t+Preach</url>
- </track>
- <track title="Into The Groode">
- <reach>1</reach>
- <url>http://www.last.fm/music/Madonna/_/Into+The+Groode</url>
- </track>
- <track title="Open Your Heart">
- <reach>169657</reach>
- <url>http://www.last.fm/music/Madonna/_/Open+Your+Heart</url>
- </track>
- <track title="Live to Tell">
- <reach>157781</reach>
- <url>http://www.last.fm/music/Madonna/_/Live+to+Tell</url>
- </track>
- <track title="True Blue">
- <reach>62135</reach>
- <url>http://www.last.fm/music/Madonna/_/True+Blue</url>
- </track>
- </tracks>
-</album> \ No newline at end of file
diff --git a/tests/spotify-cover/Makefile.am b/tests/spotify-cover/Makefile.am
new file mode 100644
index 0000000..3cd1324
--- /dev/null
+++ b/tests/spotify-cover/Makefile.am
@@ -0,0 +1,36 @@
+#
+# Makefile.am
+#
+# Author: Juan A. Suarez Romero <jasuarez@igalia.com>
+#
+# Copyright (C) 2014 Igalia S.L.
+
+include $(top_srcdir)/gtester.mk
+
+TEST_PROGS += \
+ test_spotify_cover
+
+test_spotify_cover_defines = \
+ -DLUA_FACTORY_PLUGIN_PATH=\""$(abs_top_builddir)/src/lua-factory/.libs/"\" \
+ -DLUA_SOURCES_PATH=\""$(abs_top_srcdir)/src/lua-factory/sources/"\" \
+ -DSPOTIFY_COVER_DATA_PATH=\""$(abs_top_srcdir)/tests/spotify-cover/data/"\"
+
+test_spotify_cover_SOURCES = \
+ test_spotify_cover.c
+
+test_spotify_cover_LDADD = \
+ @DEPS_LIBS@
+
+test_spotify_cover_CFLAGS = \
+ @DEPS_CFLAGS@ \
+ $(test_spotify_cover_defines)
+
+# Distribute the tests data:
+dist_noinst_DATA = \
+ data/network-data.ini \
+ data/resolve-bad-found.data \
+ data/resolve-good-found.data
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+-include $(top_srcdir)/git.mk
diff --git a/tests/spotify-cover/data/network-data.ini b/tests/spotify-cover/data/network-data.ini
new file mode 100644
index 0000000..2b9b78d
--- /dev/null
+++ b/tests/spotify-cover/data/network-data.ini
@@ -0,0 +1,9 @@
+[default]
+version=1
+
+[https://api.spotify.com/v1/search?q=album:ray%20of%20light+artist:madonna&type=album&limit=1]
+data=resolve-good-found.data
+
+[https://api.spotify.com/v1/search?q=album:ray%20of%20darkness+artist:madonna&type=album&limit=1]
+data=resolve-bad-found.data
+
diff --git a/tests/spotify-cover/data/resolve-bad-found.data b/tests/spotify-cover/data/resolve-bad-found.data
new file mode 100644
index 0000000..82cf538
--- /dev/null
+++ b/tests/spotify-cover/data/resolve-bad-found.data
@@ -0,0 +1,11 @@
+{
+ "albums" : {
+ "href" : "https://api.spotify.com/v1/search?query=album%3Aray+of+darkness+artist%3Amadonna&offset=0&limit=1&type=album",
+ "items" : [ ],
+ "limit" : 1,
+ "next" : null,
+ "offset" : 0,
+ "previous" : null,
+ "total" : 0
+ }
+} \ No newline at end of file
diff --git a/tests/spotify-cover/data/resolve-good-found.data b/tests/spotify-cover/data/resolve-good-found.data
new file mode 100644
index 0000000..0d3aab4
--- /dev/null
+++ b/tests/spotify-cover/data/resolve-good-found.data
@@ -0,0 +1,35 @@
+{
+ "albums" : {
+ "href" : "https://api.spotify.com/v1/search?query=album%3Aray+of+light+artist%3Amadonna&offset=0&limit=1&type=album",
+ "items" : [ {
+ "album_type" : "album",
+ "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ],
+ "external_urls" : {
+ "spotify" : "https://open.spotify.com/album/6cuNyrSmRjBeekioLdLkvI"
+ },
+ "href" : "https://api.spotify.com/v1/albums/6cuNyrSmRjBeekioLdLkvI",
+ "id" : "6cuNyrSmRjBeekioLdLkvI",
+ "images" : [ {
+ "height" : 640,
+ "url" : "https://i.scdn.co/image/246565c45ea4085d5b3889619fa1112ec6d42eed",
+ "width" : 640
+ }, {
+ "height" : 300,
+ "url" : "https://i.scdn.co/image/f89849d36862a9dd2807be1d6d07eb0159c26673",
+ "width" : 300
+ }, {
+ "height" : 64,
+ "url" : "https://i.scdn.co/image/cfa2d86696ff7cd8ea862f50ed05d086f1d66521",
+ "width" : 64
+ } ],
+ "name" : "Ray Of Light (U.S. Version)",
+ "type" : "album",
+ "uri" : "spotify:album:6cuNyrSmRjBeekioLdLkvI"
+ } ],
+ "limit" : 1,
+ "next" : null,
+ "offset" : 0,
+ "previous" : null,
+ "total" : 1
+ }
+} \ No newline at end of file
diff --git a/tests/lastfm-albumart/test_lastfm_albumart.c b/tests/spotify-cover/test_spotify_cover.c
index 0966068..f907543 100644
--- a/tests/lastfm-albumart/test_lastfm_albumart.c
+++ b/tests/spotify-cover/test_spotify_cover.c
@@ -22,7 +22,7 @@
#include <grilo.h>
-#define LASTFM_ALBUMART_ID "grl-lastfm-albumart"
+#define LASTFM_ALBUMART_ID "grl-spotify-cover"
static GrlMedia *
build_media_audio (const gchar *artist,
@@ -156,7 +156,7 @@ test_resolve_good_found (void)
source = grl_registry_lookup_source (registry, LASTFM_ALBUMART_ID);
g_assert (source);
- media = build_media_audio ("madonna", "frozen");
+ media = build_media_audio ("madonna", "ray of light");
keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
@@ -169,58 +169,16 @@ test_resolve_good_found (void)
/* We should get 5 thumbnails */
expected_n_thumbnails = grl_data_length (GRL_DATA (media), GRL_METADATA_KEY_THUMBNAIL);
- g_assert_cmpuint (expected_n_thumbnails, ==, 5);
+ g_assert_cmpuint (expected_n_thumbnails, ==, 3);
g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 0),
==,
- "http://userserve-ak.last.fm/serve/500/76737256.png");
+ "https://i.scdn.co/image/246565c45ea4085d5b3889619fa1112ec6d42eed");
g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 1),
==,
- "http://userserve-ak.last.fm/serve/252/76737256.png");
+ "https://i.scdn.co/image/f89849d36862a9dd2807be1d6d07eb0159c26673");
g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 2),
==,
- "http://userserve-ak.last.fm/serve/126/76737256.png");
- g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 3),
- ==,
- "http://userserve-ak.last.fm/serve/64s/76737256.png");
- g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 4),
- ==,
- "http://userserve-ak.last.fm/serve/34s/76737256.png");
-
- g_list_free (keys);
- g_object_unref (options);
- g_object_unref (media);
-}
-
-static void
-test_resolve_good_found_default (void)
-{
- GError *error = NULL;
- GList *keys;
- GrlMedia *media;
- GrlOperationOptions *options;
- GrlRegistry *registry;
- GrlSource *source;
- guint expected_n_thumbnails;
-
- registry = grl_registry_get_default ();
- source = grl_registry_lookup_source (registry, LASTFM_ALBUMART_ID);
- g_assert (source);
-
- media = build_media_audio ("madonna", "frocen");
-
- keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
-
- options = grl_operation_options_new (NULL);
- grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
-
- grl_source_resolve_sync (source, media, keys, options, &error);
-
- g_assert_no_error (error);
-
- /* We should get 0 thumbnails */
- expected_n_thumbnails = grl_data_length (GRL_DATA (media), GRL_METADATA_KEY_THUMBNAIL);
- g_assert_cmpuint (expected_n_thumbnails, ==, 0);
- g_assert (!grl_media_get_thumbnail (media));
+ "https://i.scdn.co/image/cfa2d86696ff7cd8ea862f50ed05d086f1d66521");
g_list_free (keys);
g_object_unref (options);
@@ -242,12 +200,12 @@ test_resolve_good_not_found (void)
source = grl_registry_lookup_source (registry, LASTFM_ALBUMART_ID);
g_assert (source);
- media = build_media_audio ("madonna", "unknown");
+ media = build_media_audio ("madonna", "ray of darkness");
keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
options = grl_operation_options_new (NULL);
- grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
+ grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_NORMAL);
grl_source_resolve_sync (source, media, keys, options, &error);
@@ -283,7 +241,7 @@ test_resolve_missing_key (void)
keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
options = grl_operation_options_new (NULL);
- grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
+ grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_NORMAL);
grl_source_resolve_sync (source, media, keys, options, &error);
@@ -302,9 +260,10 @@ test_resolve_missing_key (void)
int
main(int argc, char **argv)
{
- g_setenv ("GRL_PLUGIN_PATH", LASTFM_ALBUMART_PLUGIN_PATH, TRUE);
- g_setenv ("GRL_PLUGIN_LIST", LASTFM_ALBUMART_ID, TRUE);
- g_setenv ("GRL_NET_MOCKED", LASTFM_ALBUMART_DATA_PATH "network-data.ini", TRUE);
+ g_setenv ("GRL_PLUGIN_PATH", LUA_FACTORY_PLUGIN_PATH, TRUE);
+ g_setenv ("GRL_LUA_SOURCES_PATH", LUA_SOURCES_PATH, TRUE);
+ g_setenv ("GRL_PLUGIN_LIST", "grl-lua-factory", TRUE);
+ g_setenv ("GRL_NET_MOCKED", SPOTIFY_COVER_DATA_PATH "network-data.ini", TRUE);
grl_init (&argc, &argv);
g_test_init (&argc, &argv, NULL);
@@ -315,14 +274,13 @@ main(int argc, char **argv)
test_setup ();
- g_test_add_func ("/lastfm-albumart/may-resolve/good", test_may_resolve_good);
- g_test_add_func ("/lastfm-albumart/may-resolve/wrong-key", test_may_resolve_wrong_key);
- g_test_add_func ("/lastfm-albumart/may-resolve/missing-key", test_may_resolve_missing_key);
- g_test_add_func ("/lastfm-albumart/may-resolve/missing-media", test_may_resolve_missing_media);
- g_test_add_func ("/lastfm-albumart/resolve/good-found", test_resolve_good_found);
- g_test_add_func ("/lastfm-albumart/resolve/good-found-default", test_resolve_good_found_default);
- g_test_add_func ("/lastfm-albumart/resolve/good-not-found", test_resolve_good_not_found);
- g_test_add_func ("/lastfm-albumart/resolve/missing-key", test_resolve_missing_key);
+ g_test_add_func ("/spotify-cover/may-resolve/good", test_may_resolve_good);
+ g_test_add_func ("/spotify-cover/may-resolve/wrong-key", test_may_resolve_wrong_key);
+ g_test_add_func ("/spotify-cover/may-resolve/missing-key", test_may_resolve_missing_key);
+ g_test_add_func ("/spotify-cover/may-resolve/missing-media", test_may_resolve_missing_media);
+ g_test_add_func ("/spotify-cover/resolve/good-found", test_resolve_good_found);
+ g_test_add_func ("/spotify-cover/resolve/good-not-found", test_resolve_good_not_found);
+ g_test_add_func ("/spotify-cover/resolve/missing-key", test_resolve_missing_key);
gint result = g_test_run ();