[grilo-plugins/upstream: 1/3] tests: grl-metrolyrics (lua source)
- From: Victor Toso de Carvalho <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins/upstream: 1/3] tests: grl-metrolyrics (lua source)
- Date: Thu, 5 Mar 2015 17:25:39 +0000 (UTC)
commit aa1bad79a8181cf4698a8bffd4e2d28de45e87b5
Author: Victor Toso <me victortoso com>
Date: Thu Dec 18 01:07:54 2014 +0100
tests: grl-metrolyrics (lua source)
https://bugzilla.gnome.org/show_bug.cgi?id=741784
configure.ac | 2 +
tests/Makefile.am | 5 +
tests/lua-factory/Makefile.am | 19 +++
tests/lua-factory/sources/Makefile.am | 53 +++++++++
.../lua-factory/sources/data/lyrics_back_it_up.txt | 85 +++++++++++++
.../sources/data/lyrics_bohemian_rhapsody.txt | 64 ++++++++++
.../sources/data/lyrics_nobodys_perfect.txt | 71 +++++++++++
.../sources/data/lyrics_ring_of_fire.txt | 38 ++++++
tests/lua-factory/sources/test_lua_factory_utils.c | 93 +++++++++++++++
tests/lua-factory/sources/test_lua_factory_utils.h | 36 ++++++
tests/lua-factory/sources/test_lua_metrolyrics.c | 124 ++++++++++++++++++++
.../sources/test_lua_metrolyrics.gresource.xml | 9 ++
12 files changed, 599 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 80e3786..db16b5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1450,6 +1450,8 @@ AC_CONFIG_FILES([
tests/dleyna/dbusmock/dleyna-server-mock.service
tests/lastfm-albumart/Makefile
tests/local-metadata/Makefile
+ tests/lua-factory/Makefile
+ tests/lua-factory/sources/Makefile
tests/thetvdb/Makefile
tests/tmdb/Makefile
tests/vimeo/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8230b5d..58ff889 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -29,6 +29,10 @@ if LOCALMETADATA_PLUGIN
SUBDIRS += local-metadata
endif
+if LUA_FACTORY_PLUGIN
+SUBDIRS += lua-factory
+endif
+
if TMDB_PLUGIN
SUBDIRS += tmdb
endif
@@ -47,6 +51,7 @@ DIST_SUBDIRS = \
dleyna \
lastfm-albumart\
local-metadata \
+ lua-factory \
tmdb \
thetvdb \
vimeo
diff --git a/tests/lua-factory/Makefile.am b/tests/lua-factory/Makefile.am
new file mode 100644
index 0000000..e7cf96e
--- /dev/null
+++ b/tests/lua-factory/Makefile.am
@@ -0,0 +1,19 @@
+#
+# Makefile.am
+#
+# Author: Victor Toso <me victortoso com>
+#
+# Copyright (C) 2014 Victor Toso. All rights reserved.
+
+include $(top_srcdir)/gtester.mk
+
+SUBDIRS = sources
+
+DIST_SUBDIRS = \
+ sources
+
+MAINTAINERCLEANFILES = \
+ *.in \
+ *~
+
+DISTCLEANFILES = $(MAINTAINERCLEANFILES)
diff --git a/tests/lua-factory/sources/Makefile.am b/tests/lua-factory/sources/Makefile.am
new file mode 100644
index 0000000..890a836
--- /dev/null
+++ b/tests/lua-factory/sources/Makefile.am
@@ -0,0 +1,53 @@
+#
+# Makefile.am
+#
+# Author: Victor Toso <me victortoso com>
+#
+# Copyright (C) 2015 Victor Toso. All rights reserved.
+
+include $(top_srcdir)/gtester.mk
+
+TEST_PROGS += \
+ test_lua_metrolyrics
+
+test_lua_factory_defines = \
+ -DLUA_FACTORY_PLUGIN_PATH=\""$(abs_top_builddir)/src/lua-factory/.libs/"\" \
+ -DLUA_FACTORY_SOURCES_PATH=\""$(abs_top_builddir)/src/lua-factory/sources/"\" \
+ -DLUA_FACTORY_PLUGIN_TEST_DATA_PATH=\""$(abs_top_builddir)/tests/lua-factory/sources/"\"
+
+test_lua_metrolyrics_SOURCES = \
+ test_lua_metrolyrics.c \
+ metrolyricsresources.h metrolyricsresources.c \
+ test_lua_factory_utils.h test_lua_factory_utils.c
+
+test_lua_metrolyrics_LDADD = \
+ @DEPS_LIBS@
+
+test_lua_metrolyrics_CFLAGS = \
+ @DEPS_CFLAGS@ \
+ $(test_lua_factory_defines)
+
+metrolyrics_resources_files = \
+ data/lyrics_back_it_up.txt \
+ data/lyrics_bohemian_rhapsody.txt \
+ data/lyrics_nobodys_perfect.txt \
+ data/lyrics_ring_of_fire.txt
+
+metrolyricsresources.h: test_lua_metrolyrics.gresource.xml
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/test_lua_metrolyrics.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --c-name _grl_lua_metrolyrics --generate-header
+metrolyricsresources.c: test_lua_metrolyrics.gresource.xml metrolyricsresources.h
$(metrolyrics_resources_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/test_lua_metrolyrics.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --c-name _grl_lua_metrolyrics --generate-source
+
+CLEANFILES = \
+ metrolyricsresources.h \
+ metrolyricsresources.c
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+MAINTAINERCLEANFILES = \
+ *.in \
+ *~
+
+DISTCLEANFILES = $(MAINTAINERCLEANFILES)
diff --git a/tests/lua-factory/sources/data/lyrics_back_it_up.txt
b/tests/lua-factory/sources/data/lyrics_back_it_up.txt
new file mode 100644
index 0000000..fc10054
--- /dev/null
+++ b/tests/lua-factory/sources/data/lyrics_back_it_up.txt
@@ -0,0 +1,85 @@
+I can't stop shakin'
+The room has a groove and the floor
+It's almost earthquakin'
+Uhuh
+
+Look what we're makin'
+History out on the floor
+And it's just awakin'
+Uhuh
+
+So get that needle in the core
+Scratch that back and gimme more
+You know zactly what I came here for
+Back it up and do it again
+
+From the middle to the top to the end
+Ba dlu dla dlun dloday
+Ba dlu dla dlun dloday
+Back to the middle to the front to the end
+Za dlu dla dlun dloday
+Everybody ba dlun dloday
+I don't care if he's a friend
+From the front to the middle to the back to the end
+
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back it up and do it again
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+
+Gimme some of that funky
+The kind that the Duke used to play
+And make it more swingy
+Heyey
+
+And then give me some hornay
+You know the bub-pu-pa bub-pu-pa-bay
+Come on, give it to me, Hmmm hmmm
+
+Slam that bass and make it sing
+Give those strings that rip 'n zing
+You know zactly what I came here for
+Back it up and do it again
+
+From the middle to the top to the end
+Ba dlu dla dlun dloday
+Ba dlu dla dlun dloday
+Back to the middle to the front to the end
+Za dlu dla dlun dloday
+Everybody ba dlun dloday
+I don't care if he's a friend
+From the front to the middle to the back to the end
+
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back it up and do it again
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+
+Get that needle in the core
+Scratch that back and gimme more
+You know zactly what I came here for
+Back it up and do it again
+
+From the middle to the top to the end
+Ba dlu dla dlun dloday
+Ba dlu dla dlun dloday
+Back to the middle to the front to the end
+Za dlu dla dlun dloday
+Everybody ba dlun dloday
+I don't care if he's a friend
+From the front to the middle to the back to the end
+
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back it up and do it again
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back, back, back, back it up (I wanna)
+Back it up and do it again
diff --git a/tests/lua-factory/sources/data/lyrics_bohemian_rhapsody.txt
b/tests/lua-factory/sources/data/lyrics_bohemian_rhapsody.txt
new file mode 100644
index 0000000..00e49ee
--- /dev/null
+++ b/tests/lua-factory/sources/data/lyrics_bohemian_rhapsody.txt
@@ -0,0 +1,64 @@
+Is this the real life?
+Is this just fantasy?
+Caught in a landslide
+No escape from reality
+Open your eyes
+Look up to the skies and see
+I'm just a poor boy, I need no sympathy
+Because I'm easy come, easy go
+A little high, little low
+Anyway the wind blows, doesn't really matter to me, to me
+
+Mama, just killed a man
+Put a gun against his head
+Pulled my trigger, now he's dead
+Mama, life had just begun
+But now I've gone and thrown it all away
+Mama, ooo
+Didn't mean to make you cry
+If I'm not back again this time tomorrow
+Carry on, carry on, as if nothing really matters
+
+Too late, my time has come
+Sends shivers down my spine
+Body's aching all the time
+Goodbye everybody I've got to go
+Gotta leave you all behind and face the truth
+Mama, ooo (anyway the wind blows)
+I don't want to die
+I sometimes wish I'd never been born at all
+
+I see a little silhouetto of a man
+Scaramouch, scaramouch will you do the fandango
+Thunderbolt and lightning very very frightening me
+Gallileo, Gallileo,
+Gallileo, Gallileo,
+Gallileo Figaro - magnifico
+
+But I'm just a poor boy and nobody loves me
+He's just a poor boy from a poor family
+Spare him his life from this monstrosity
+Easy come easy go will you let me go
+Bismillah! No we will not let you go - let him go
+Bismillah! We will not let you go - let him go
+Bismillah! We will not let you go let me go
+Will not let you go let me go (never)
+Never let you go let me go
+Never let me go ooo
+No, no, no, no, no, no, no
+Oh mama mia, mama mia, mama mia let me go
+Beelzebub has a devil put aside for me
+For me
+For me
+
+So you think you can stone me and spit in my eye
+So you think you can love me and leave me to die
+Oh baby can't do this to me baby
+Just gotta get out just gotta get right outta here
+
+Ooh yeah, ooh yeah
+Nothing really matters
+Anyone can see
+Nothing really matters nothing really matters to me
+
+Anyway the wind blows
diff --git a/tests/lua-factory/sources/data/lyrics_nobodys_perfect.txt
b/tests/lua-factory/sources/data/lyrics_nobodys_perfect.txt
new file mode 100644
index 0000000..56ff243
--- /dev/null
+++ b/tests/lua-factory/sources/data/lyrics_nobodys_perfect.txt
@@ -0,0 +1,71 @@
+When I'm nervous I have this thing yeah I talk too much
+Sometimes I just can't shut the hell up
+It's like I need to tell someone anyone who'll listen
+And that's where I seem to fuck up, yeah
+I forget about the consequences,
+For a minute there I lose my senses
+And in the heat of the moment
+My mouth starts going the words start flowing
+
+But I never meant to hurt you,
+I know it's time that I learned to
+Treat the people I love like I wanna be loved
+This is a lesson learned,
+I hate that I let you down and I feel so bad about it
+I guess karma comes back around
+'Cause now I'm the one that's hurting yeah
+And I hate that I made you think that the trust we had is broken
+So don't tell me you can't forgive me
+'Cause nobody's perfect,
+No, no, no, no, no, no, no, nobody's perfect
+
+If I could turn back the hands of time
+I swear I never woulda cross that line
+I should of kept it between us
+But no I went and told the whole world how I feelin', oh
+So I sit and I realize with these tears falling from my eyes
+I gotta change if I wanna keep you forever
+I promise that I'm gonna try
+
+But I never meant to hurt you,
+I know it's time that I learn to
+Treat the people I love like I wanna be loved
+This is a lesson learned
+I hate that I let you down
+And I feel so bad about it
+I guess karma comes back around
+'Cause now I'm the one that's hurting yeah
+And I hate that I made you think
+That the trust we had is broken
+
+So don't tell me you can't forgive me
+'Cause nobody's perfect,
+No, no, no, no, no, no, no, nobody's perfect
+
+I'm not a saint no not at all,
+But what I did it wasn't cool
+But I swear that I'll never do that again to you
+I'm not a saint, no not at all,
+But what I did it wasn't cool
+But I swear that I'll never do that again to you
+
+I hate that I let you down,
+And I feel so bad about it
+I guess karma comes back around
+'Cause now I'm the one that's hurting yeah
+And I hate that I made you think
+That the trust we had is broken
+So don't tell me you can't forgive me
+'Cause nobody's perfect, no
+
+And I hate that I let you down
+And I feel so bad about it
+I guess karma comes back around
+'Cause I'm the one that's hurting, yeah
+And I hate that I made you think
+That the trust we had is broken
+So don't tell me you can't forgive me
+'Cause nobody's perfect, yeah yeah
+Don't tell me, don't tell me
+Don't tell me, you cant forgive, no, no, no
+Because nobody's perfect, no
diff --git a/tests/lua-factory/sources/data/lyrics_ring_of_fire.txt
b/tests/lua-factory/sources/data/lyrics_ring_of_fire.txt
new file mode 100644
index 0000000..575fb7b
--- /dev/null
+++ b/tests/lua-factory/sources/data/lyrics_ring_of_fire.txt
@@ -0,0 +1,38 @@
+Love is a burnin' thing,
+And it makes a fiery ring
+Bound by wild desire
+I fell into a ring of fire.
+
+I fell into a burnin' ring of fire
+I went down, down, down
+And the flames went higher,
+And it burns, burns, burns,
+The ring of fire, the ring of fire.
+
+I fell into a burnin' ring of fire
+I went down, down, down
+And the flames went higher,
+And it burns, burns, burns,
+The ring of fire, the ring of fire.
+
+The taste of love is sweet
+When hearts like ours meet.
+I fell for you like a child
+Oh, but the fire went wild.
+
+I fell into a burnin' ring of fire
+I went down, down, down
+And the flames went higher,
+And it burns, burns, burns,
+The ring of fire, the ring of fire.
+
+I fell into a burnin' ring of fire
+I went down, down, down,
+And the flames went higher,
+And it burns, burns, burns,
+The ring of fire, the ring of fire.
+
+And it burns, burns, burns,
+The ring of fire, the ring of fire.
+The ring of fire, the ring of fire
+The ring of fire
diff --git a/tests/lua-factory/sources/test_lua_factory_utils.c
b/tests/lua-factory/sources/test_lua_factory_utils.c
new file mode 100644
index 0000000..15e3115
--- /dev/null
+++ b/tests/lua-factory/sources/test_lua_factory_utils.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2015. All rights reserved.
+ *
+ * Author: Victor Toso <me victortoso com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "test_lua_factory_utils.h"
+
+void
+test_lua_factory_init (gint *p_argc,
+ gchar ***p_argv,
+ gboolean net_mocked)
+{
+ g_setenv ("GRL_PLUGIN_PATH", LUA_FACTORY_PLUGIN_PATH, TRUE);
+ g_setenv ("GRL_PLUGIN_LIST", LUA_FACTORY_ID, TRUE);
+ g_setenv ("GRL_LUA_SOURCES_PATH", LUA_FACTORY_SOURCES_PATH, TRUE);
+
+ /* For some sources it doesn't make sense to mock the network request,
+ * mainly because is hard to track changes in the provider of data.
+ * (e.g. if source rely on a website) */
+ if (net_mocked) {
+ g_setenv ("GRL_NET_MOCKED", LUA_FACTORY_PLUGIN_TEST_DATA_PATH "config.ini", TRUE);
+ }
+
+ grl_init (p_argc, p_argv);
+ g_test_init (p_argc, p_argv, NULL);
+
+#if !GLIB_CHECK_VERSION(2,32,0)
+ g_thread_init (NULL);
+#endif
+}
+
+void
+test_lua_factory_setup (GrlConfig *config)
+{
+ GrlRegistry *registry;
+ GError *error = NULL;
+
+ registry = grl_registry_get_default ();
+
+ if (config != NULL) {
+ grl_registry_add_config (registry, config, &error);
+ g_assert_no_error (error);
+ }
+
+ grl_registry_load_plugin_by_id (registry, LUA_FACTORY_ID, &error);
+ g_assert_no_error (error);
+}
+
+GrlSource*
+test_lua_factory_get_source (gchar *source_id,
+ GrlSupportedOps source_ops)
+{
+ GrlRegistry *registry = grl_registry_get_default ();
+ GrlSource *source = grl_registry_lookup_source (registry, source_id);
+ g_assert_nonnull (source);
+ g_assert (grl_source_supported_operations (source) & source_ops);
+ return source;
+}
+
+void
+test_lua_factory_shutdown (void)
+{
+ GrlRegistry *registry;
+ GError *error = NULL;
+
+ registry = grl_registry_get_default ();
+ grl_registry_unload_plugin (registry, LUA_FACTORY_ID, &error);
+ g_assert_no_error (error);
+}
+
+void
+test_lua_factory_deinit (void)
+{
+ grl_deinit ();
+}
+
diff --git a/tests/lua-factory/sources/test_lua_factory_utils.h
b/tests/lua-factory/sources/test_lua_factory_utils.h
new file mode 100644
index 0000000..ccb4613
--- /dev/null
+++ b/tests/lua-factory/sources/test_lua_factory_utils.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015. All rights reserved.
+ *
+ * Author: Victor Toso <me victortoso com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef _GRL_LUA_FACTORY_TEST_UTILS_H_
+#define _GRL_LUA_FACTORY_TEST_UTILS_H_
+
+#define LUA_FACTORY_ID "grl-lua-factory"
+
+#include <grilo.h>
+
+void test_lua_factory_init (gint *p_argc, gchar ***p_argv, gboolean net_mocked);
+void test_lua_factory_setup (GrlConfig *config);
+void test_lua_factory_shutdown (void);
+void test_lua_factory_deinit (void);
+GrlSource* test_lua_factory_get_source (gchar *source_id, GrlSupportedOps source_ops);
+
+#endif /* _GRL_LUA_FACTORY_TEST_UTILS_H_ */
diff --git a/tests/lua-factory/sources/test_lua_metrolyrics.c
b/tests/lua-factory/sources/test_lua_metrolyrics.c
new file mode 100644
index 0000000..6414323
--- /dev/null
+++ b/tests/lua-factory/sources/test_lua_metrolyrics.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2015. All rights reserved.
+ *
+ * Author: Victor Toso <me victortoso com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "test_lua_factory_utils.h"
+
+#define METROLYRICS_ID "grl-metrolyrics"
+#define METROLYRICS_OPS GRL_OP_RESOLVE
+
+#define GRESOURCE_PREFIX "resource:///org/gnome/grilo/plugins/test/metrolyrics/data/"
+
+#define LYRICS_RING_OF_FIRE GRESOURCE_PREFIX "lyrics_ring_of_fire.txt"
+#define LYRICS_BACK_IT_UP GRESOURCE_PREFIX "lyrics_back_it_up.txt"
+#define LYRICS_BOHEMIAN_RHAPSODY GRESOURCE_PREFIX "lyrics_bohemian_rhapsody.txt"
+#define LYRICS_NOBODYS_PERFECT GRESOURCE_PREFIX "lyrics_nobodys_perfect.txt"
+
+static gchar *
+get_lyrics (GrlSource *source,
+ const gchar *artist,
+ const gchar *title)
+{
+ GList *keys;
+ GrlMediaAudio *audio;
+ GrlOperationOptions *options;
+ GError *error = NULL;
+ gchar *lyrics;
+
+ audio = GRL_MEDIA_AUDIO (grl_media_audio_new ());
+ grl_media_audio_set_artist (audio, artist);
+ grl_media_set_title (GRL_MEDIA (audio), title);
+
+ keys = grl_metadata_key_list_new (GRL_METADATA_KEY_LYRICS, NULL);
+ options = grl_operation_options_new (NULL);
+ grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_NORMAL);
+
+ grl_source_resolve_sync (source,
+ GRL_MEDIA (audio),
+ keys,
+ options,
+ &error);
+ g_assert_no_error (error);
+
+ lyrics = g_strdup (grl_media_audio_get_lyrics (audio));
+
+ g_list_free (keys);
+ g_object_unref (options);
+ g_object_unref (audio);
+ return lyrics;
+}
+
+static void
+test_resolve_metrolyrics (void)
+{
+ GrlSource *source;
+ guint i;
+
+ struct {
+ gchar *title;
+ gchar *artist;
+ gchar *lyrics_file;
+ } audios[] = {
+ { "ring of fire", "johnny cash", LYRICS_RING_OF_FIRE },
+ { "back it up", "caro emerald", LYRICS_BACK_IT_UP },
+ { "bohemian rhapsody", "queen", LYRICS_BOHEMIAN_RHAPSODY },
+ { "nobodys perfect", "jessie j", LYRICS_NOBODYS_PERFECT },
+ };
+
+ source = test_lua_factory_get_source (METROLYRICS_ID, METROLYRICS_OPS);
+
+ for (i = 0; i < G_N_ELEMENTS (audios); i++) {
+ gchar *lyrics, *data;
+ GFile *file;
+ gsize size;
+ GError *error = NULL;
+
+ file = g_file_new_for_uri (audios[i].lyrics_file);
+ g_file_load_contents (file, NULL, &data, &size, NULL, &error);
+ g_assert_no_error (error);
+ g_clear_pointer (&file, g_object_unref);
+
+ lyrics = get_lyrics (source, audios[i].artist, audios[i].title);
+ g_assert_nonnull (lyrics);
+ if (g_ascii_strncasecmp (lyrics, data, size - 1) != 0) {
+ g_warning ("Lyrics of '%s' from '%s' changed. Check if metrolyrics.com changed",
+ audios[i].title, audios[i].artist);
+ }
+ g_clear_pointer (&lyrics, g_free);
+ g_clear_pointer (&data, g_free);
+ }
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ test_lua_factory_init (&argc, &argv, FALSE);
+ test_lua_factory_setup (NULL);
+
+ g_test_add_func ("/lua_factory/sources/metrolyrics", test_resolve_metrolyrics);
+
+ gint result = g_test_run ();
+
+ test_lua_factory_shutdown ();
+ test_lua_factory_deinit ();
+
+ return result;
+}
diff --git a/tests/lua-factory/sources/test_lua_metrolyrics.gresource.xml
b/tests/lua-factory/sources/test_lua_metrolyrics.gresource.xml
new file mode 100644
index 0000000..fd77fdf
--- /dev/null
+++ b/tests/lua-factory/sources/test_lua_metrolyrics.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/grilo/plugins/test/metrolyrics">
+ <file compressed="false">data/lyrics_back_it_up.txt</file>
+ <file compressed="false">data/lyrics_bohemian_rhapsody.txt</file>
+ <file compressed="false">data/lyrics_nobodys_perfect.txt</file>
+ <file compressed="false">data/lyrics_ring_of_fire.txt</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]