[easytag/wip/musicbrainz-support-merge: 17/75] Merged MusicBrainz test server and client into one
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-support-merge: 17/75] Merged MusicBrainz test server and client into one
- Date: Sat, 30 Aug 2014 07:47:25 +0000 (UTC)
commit 437fe7ccf1f3adfc430af64df7ca31eeebb3ebf0
Author: Abhinav <abhijangda hotmail com>
Date: Sun Jun 15 22:36:47 2014 +0530
Merged MusicBrainz test server and client into one
Client and MusicBrainz test server are merged into one file
test-musicbrainz.c. Added DiscID test.
Makefile.am | 29 +--
configure.ac | 5 +-
po/POTFILES.in | 2 +
src/mb_search.c | 20 ++
tests/discid-release_info.xml | 1 +
tests/discid.xml | 422 +--------------------------------------
tests/test-musicbrainz.c | 393 +++++++++++++++++++++++++++++++++++-
tests/test-musicbrainz_server.c | 245 -----------------------
8 files changed, 419 insertions(+), 698 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 15e4995..8b0ec9c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -415,9 +415,8 @@ test-report perf-report full-report: $(check_PROGRAMS)
}
check_PROGRAMS = \
- tests/test-scan
+ tests/test-scan \
tests/test-musicbrainz
- tests/test-musicbrainz_server
tests_test_scan_CPPFLAGS = \
-I$(top_srcdir)/src \
@@ -438,35 +437,21 @@ tests_test_scan_LDADD = \
tests_test_musicbrainz_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_builddir) \
- $(DEPRECATED_CPPFLAGS)
+ $(DEPRECATED_CPPFLAGS) \
+ -D TEST
tests_test_musicbrainz_CFLAGS = \
$(WARN_CFLAGS) \
- $(EASYTAG_CFLAGS)
+ $(EASYTAG_CFLAGS) \
+ -D TEST
tests_test_musicbrainz_SOURCES = \
- tests/test-musibrainz.c \
- src/mb_search.c \
- src/musicbrainz_dialog.c
+ tests/test-musicbrainz.c \
+ src/mb_search.c
tests_test_musicbrainz_LDADD = \
$(EASYTAG_LIBS)
-tests_test_musicbrainz_server_CPPFLAGS = \
- -I$(top_srcdir)/src \
- -I$(top_builddir) \
- $(DEPRECATED_CPPFLAGS)
-
-tests_test_musicbrainz_server_CFLAGS = \
- $(WARN_CFLAGS) \
- $(EASYTAG_CFLAGS)
-
-tests_test_musicbrainz_server_SOURCES = \
- tests/test-musibrainz_server.c
-
-tests_test_musicbrainz_server_LDADD = \
- $(EASYTAG_LIBS)
-
check_SCRIPTS = \
tests/test-desktop-file-validate.sh
diff --git a/configure.ac b/configure.ac
index b43cb18..4713a50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,6 +166,9 @@ MUSICBRAINZ_DEPS="libmusicbrainz5 >= 5.0"
dnl libdiscid
LIBDISCID_DEPS="libdiscid >= 0.2.2"
+dnl libsoup
+LIBSOUP_DEPS="libsoup-2.4 >= 2.4"
+
dnl Patch from Ben Taylor to fix a Solaris bug (for CDDB)
AC_CHECK_LIB([socket], [recv])
@@ -332,7 +335,7 @@ GIO_DEPS="gio-2.0 >= 2.32.0" dnl For g_file_new_tmp()
GLIB_DEPRECATION_FLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32
-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
GTK_DEPS="gtk+-3.0 >= 3.4.0"
GTK_DEPRECATION_FLAGS="-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4 -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4"
-PKG_CHECK_MODULES([EASYTAG], [$LIBDISCID_DEPS $MUSICBRAINZ_DEPS $GIO_DEPS $GTK_DEPS $OPUS_DEPS $OGG_DEPS
$SPEEX_DEPS $FLAC_DEPS $ID3TAG_DEPS $TAGLIB_DEPS $WAVPACK_DEPS])
+PKG_CHECK_MODULES([EASYTAG], [$LIBDISCID_DEPS $LIBSOUP_DEPS $MUSICBRAINZ_DEPS $GIO_DEPS $GTK_DEPS $OPUS_DEPS
$OGG_DEPS $SPEEX_DEPS $FLAC_DEPS $ID3TAG_DEPS $TAGLIB_DEPS $WAVPACK_DEPS])
dnl Check for winsock
AC_SEARCH_LIBS([gethostbyname], [nsl socket], [],
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 18b2aff..20f56b0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -48,3 +48,5 @@ src/tags/wavpack_header.c
src/tags/wavpack_tag.c
src/win32/win32dep.c
src/musicbrainz_dialog.c
+src/mbentityview.c
+src/mb_search.c
diff --git a/src/mb_search.c b/src/mb_search.c
index 1cb0a93..cb5acd4 100644
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -121,7 +121,9 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
param_values[0] = "artists release-groups";
message = g_strdup_printf (_("Found %d Album(s)"),
mb5_release_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
for (i = 0; i < mb5_release_list_size (list); i++)
@@ -154,7 +156,9 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
buf, i+1,
mb5_release_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
size = mb5_release_get_id ((Mb5Release)release,
@@ -221,7 +225,9 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
track_list = mb5_medium_get_tracklist (medium);
message = g_strdup_printf (_("Found %d Track(s)"),
mb5_track_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
for (j = 0; j < mb5_track_list_size (track_list); j++)
@@ -247,7 +253,9 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
buf, j,
mb5_track_list_size (track_list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
size = mb5_recording_get_id (recording,
@@ -443,7 +451,9 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
param_values [0] = "artists release-groups";
message = g_strdup_printf (_("Found %d Album(s)"),
mb5_release_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
for (i = 0; i < mb5_release_list_size (list); i++)
@@ -477,7 +487,9 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
buf, i,
mb5_release_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
mb5_release_get_id ((Mb5Release)release,
@@ -527,7 +539,9 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
param_values[0] = "releases artists";
message = g_strdup_printf (_("Found %d Track(s)"),
mb5_recording_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
for (i = 0; i < mb5_recording_list_size (list); i++)
@@ -556,7 +570,9 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
buf, i,
mb5_track_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
mb5_recording_get_id (recording,
@@ -607,7 +623,9 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
param_values [0] = "artists release-groups";
message = g_strdup_printf (_("Found %d Album(s)"),
mb5_release_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
for (i = 0; i < mb5_release_list_size (list); i++)
@@ -641,7 +659,9 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
message = g_strdup_printf (_("Retrieving %s (%d/%d)"),
buf, i,
mb5_release_list_size (list));
+#ifndef TEST
et_show_status_msg_in_idle (message);
+#endif
g_free (message);
mb5_release_get_id ((Mb5Release)release,
diff --git a/tests/discid-release_info.xml b/tests/discid-release_info.xml
new file mode 100644
index 0000000..df3ca97
--- /dev/null
+++ b/tests/discid-release_info.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><release
id="30ac9626-4dac-457c-88be-11d0b7d2f5a4"><title>Praat geen
poep</title><status>Official</status><quality>normal</quality><text-representation><language>nld</language><script>Latn</script></text-representation><artist-credit><name-credit><artist
id="e5e9ea46-6f87-49ce-898d-4b81bf9b5bf0"><name>Dingetje</name><sort-name>Dingetje</sort-name></artist></name-credit></artist-credit><date>1994</date><country>NL</country><release-event-list
count="1"><release-event><date>1994</date><area
id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7"><name>Netherlands</name><sort-name>Netherlands</sort-name><iso-3166-1-code-list><iso-3166-1-code>NL</iso-3166-1-code></iso-3166-1-code-list></area></release-event></release-event-list><barcode>042285543223</barcode><cover-art-archive><artwork>false</artwork><count>0</count><front>false</front><back>false</back></cover-art-archive></release></metadata>
diff --git a/tests/discid.xml b/tests/discid.xml
index 30b41e0..a6a72b2 100644
--- a/tests/discid.xml
+++ b/tests/discid.xml
@@ -2,7 +2,7 @@
<metadata>
<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
<sectors>37890</sectors>
-<release-list count="11">
+<release-list count="1">
<release id="30ac9626-4dac-457c-88be-11d0b7d2f5a4">
<title>Praat geen poep</title>
<status>Official</status>
@@ -45,426 +45,6 @@
</medium>
</medium-list>
</release>
-<release id="31f77e60-ad1b-4d06-bf15-813a0efcf5ab">
-<title>Sex met die blonde</title>
-<status>Official</status>
-<quality>normal</quality>
-<text-representation>
-<language>nld</language>
-<script>Latn</script>
-</text-representation>
-<date>1996</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1996</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>8711211961623</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="5424c204-d61b-4941-ab9a-9305b9b6ff1e">
-<title>Koningin van de zigeuners (La Mama)</title>
-<status>Promotion</status>
-<quality>normal</quality>
-<text-representation>
-<language>nld</language>
-<script>Latn</script>
-</text-representation>
-<date>1999</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1999</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>724388655521</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="62d472eb-f875-478e-8ee0-4715813357aa">
-<title>Back to the Shore</title>
-<status>Official</status>
-<quality>normal</quality>
-<text-representation>
-<language>eng</language>
-<script>Latn</script>
-</text-representation>
-<date>1994</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1994</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>743212118322</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="6433ccd9-d814-4c74-b51d-2ca38fa5e1bb">
-<title>HOEST</title>
-<status>Official</status>
-<quality>normal</quality>
-<text-representation>
-<language>nld</language>
-<script>Latn</script>
-</text-representation>
-<date>1998</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1998</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>8712705038258</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="6f55b84c-6e58-4111-ba91-fb485f5c7ca4">
-<title>Congo</title>
-<status>Official</status>
-<quality>normal</quality>
-<text-representation>
-<language>eng</language>
-<script>Latn</script>
-</text-representation>
-<date>1997</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1997</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>724389452327</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="95d33f06-b356-44ae-b290-0a7819e028c1">
-<title>Godver godver</title>
-<status>Promotion</status>
-<quality>normal</quality>
-<text-representation>
-<language>nld</language>
-<script>Latn</script>
-</text-representation>
-<date>1996</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1996</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>8712195732124</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="9b48ce52-3354-43b4-94a2-d71c75353520">
-<title>Contract</title>
-<status>Promotion</status>
-<quality>normal</quality>
-<text-representation>
-<language>nld</language>
-<script>Latn</script>
-</text-representation>
-<date>1998</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1998</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="9fbe550b-f98b-496d-88e8-0d9f45813ac9">
-<title>Da Jonguh</title>
-<status>Official</status>
-<quality>normal</quality>
-<text-representation>
-<language>nld</language>
-<script>Latn</script>
-</text-representation>
-<date>1997</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1997</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>8712944083774</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="b13fde0c-b3a6-4aae-a6aa-20f07ff29265">
-<title>Three Sisters</title>
-<status>Promotion</status>
-<quality>normal</quality>
-<text-representation>
-<language>eng</language>
-<script>Latn</script>
-</text-representation>
-<date>1998</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1998</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>5099766554815</barcode>
-<cover-art-archive>
-<artwork>false</artwork>
-<count>0</count>
-<front>false</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
-<release id="b4f38dad-faed-41f4-9e15-c78383ed42de">
-<title>Eye of Heaven</title>
-<status>Official</status>
-<quality>normal</quality>
-<text-representation>
-<language>eng</language>
-<script>Latn</script>
-</text-representation>
-<date>1991</date>
-<country>NL</country>
-<release-event-list count="1">
-<release-event>
-<date>1991</date>
-<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
-<name>Netherlands</name>
-<sort-name>Netherlands</sort-name>
-<iso-3166-1-code-list>
-<iso-3166-1-code>NL</iso-3166-1-code>
-</iso-3166-1-code-list>
-</area>
-</release-event>
-</release-event-list>
-<barcode>5012394525521</barcode>
-<asin>B003BMES70</asin>
-<cover-art-archive>
-<artwork>true</artwork>
-<count>1</count>
-<front>true</front>
-<back>false</back>
-</cover-art-archive>
-<medium-list count="1">
-<medium>
-<position>1</position>
-<format>CD</format>
-<disc-list count="1">
-<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
-<sectors>37890</sectors>
-</disc>
-</disc-list>
-<track-list count="2"/>
-</medium>
-</medium-list>
-</release>
</release-list>
</disc>
</metadata>
diff --git a/tests/test-musicbrainz.c b/tests/test-musicbrainz.c
index 6da895d..70dd628 100644
--- a/tests/test-musicbrainz.c
+++ b/tests/test-musicbrainz.c
@@ -1,11 +1,89 @@
+/* test-musicbrainz.c - 2014/06/16 */
+/*
+ * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
+ * Copyright (C) 2000-2014 Abhinav Jangda <abhijangda hotmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
#include <glib.h>
+#include <libsoup/soup.h>
+#include <string.h>
#include "mb_search.h"
+/****************
+ * Declarations *
+ ****************/
static gchar name[NAME_MAX_SIZE];
static gchar mbid[NAME_MAX_SIZE];
-void
-mb_search_test ()
+static SoupServer *server;
+
+/**************
+ * Prototypes *
+ **************/
+static void
+mb_search_test (void);
+static void
+mb_search_in_test (void);
+static void
+default_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+westlife_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+westlife_release_info_handler (SoupServer *server, SoupMessage *msg,
+ const char *path, GHashTable *query,
+ SoupClientContext *client, gpointer user_data);
+static void
+i_still_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+never_gone_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+artist_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+release_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+recording_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+discid_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data);
+static void
+discid_release_handler (SoupServer *server, SoupMessage *msg,
+ const char *path, GHashTable *query,
+ SoupClientContext *client,
+ gpointer user_data);
+static gpointer
+run_server (gpointer data);
+
+static void
+mb_search_test (void)
{
GNode *mbTreeNode;
GError *err;
@@ -63,10 +141,29 @@ mb_search_test ()
free_mb_tree (mbTreeNode);
return;
}
+
+ mbTreeNode = g_node_new (NULL);
+
+ if (et_musicbrainz_search ("lwHl8fGzJyLXQR33ug60E8jhf4k-",
+ MB_ENTITY_TYPE_DISCID, mbTreeNode,
+ &err, NULL))
+ {
+ EtMbEntity *etentity;
+
+ etentity = (EtMbEntity *)(g_node_first_child (mbTreeNode)->data);
+ mb5_recording_get_title (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==, "Praat geen poep");
+ free_mb_tree (mbTreeNode);
+ }
+ else
+ {
+ free_mb_tree (mbTreeNode);
+ return;
+ }
}
-void
-mb_search_in_test ()
+static void
+mb_search_in_test (void)
{
GNode *mbTreeNode;
GError *err;
@@ -141,13 +238,291 @@ mb_search_in_test ()
}
}
+static void
+default_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ g_file_get_contents ("./tests/error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ "error", strlen ("error"));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+westlife_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ if (g_file_get_contents ("./tests/artist-westlife_releases.xml",
+ &response_text, &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+}
+
+static void
+westlife_release_info_handler (SoupServer *server, SoupMessage *msg,
+ const char *path, GHashTable *query,
+ SoupClientContext *client, gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ if (g_file_get_contents ("./tests/artist-westlife_release_info.xml",
+ &response_text, &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+}
+
+static void
+i_still_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ if (g_file_get_contents ("./tests/album-i_still_info.xml", &response_text,
+ &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+}
+
+static void
+never_gone_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "inc");
+
+ if (value && !g_strcmp0 (value, "artists release-groups"))
+ {
+ if (g_file_get_contents ("./tests/album-never_gone_info.xml",
+ &response_text, &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+ }
+
+ else if (value && !g_strcmp0 (value, "recordings"))
+ {
+ if (g_file_get_contents ("./tests/album-never_gone_recordings.xml",
+ &response_text, &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+ }
+}
+
+static void
+artist_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "query");
+
+ if (value && !strcmp ((gchar *)value, "artist:Westlife"))
+ {
+ if (g_file_get_contents ("./tests/artist-westlife.xml",
+ &response_text, &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE, response_text,
+ strlen (response_text));
+ soup_message_set_status (msg, 200);
+ return;
+ }
+ }
+
+ g_file_get_contents ("./tests/error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+release_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "query");
+
+ if (value && !strcmp ((gchar *)value, "release:Never Gone"))
+ {
+ if (g_file_get_contents ("./tests/album-never_gone.xml",
+ &response_text, &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE, response_text,
+ strlen (response_text));
+ soup_message_set_status (msg, 200);
+ return;
+ }
+ }
+
+ g_file_get_contents ("./tests/error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+recording_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "query");
+
+ if (value && !strcmp ((gchar *)value, "recordings:I Still"))
+ {
+ if (g_file_get_contents ("./tests/recordings-i_still.xml",
+ &response_text,
+ &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE, response_text,
+ strlen (response_text));
+ soup_message_set_status (msg, 200);
+ return;
+ }
+ }
+
+ g_file_get_contents ("./tests/error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+discid_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ g_file_get_contents ("./tests/discid.xml", &response_text, &length,
+ NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+discid_release_handler (SoupServer *server, SoupMessage *msg,
+ const char *path, GHashTable *query,
+ SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ g_file_get_contents ("./tests/discid-release_info.xml", &response_text,
+ &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static gpointer
+run_server (gpointer data)
+{
+ soup_server_run (server);
+ return NULL;
+}
+
int
-main(int argc, char** argv)
+main (int argc, char** argv)
{
- g_test_init(&argc, &argv, NULL);
+ GThread *thread;
+
+ g_type_init ();
+
+ /* Initializing test functions */
+ g_test_init (&argc, &argv, NULL);
et_musicbrainz_search_set_server_port ("localhost", 8088);
- g_test_add_func("/musicbrainz/mb_search", mb_search_test);
- g_test_add_func("/musicbrainz/mb_search_in", mb_search_in_test);
+ g_test_add_func ("/musicbrainz/mb_search", mb_search_test);
+ g_test_add_func ("/musicbrainz/mb_search_in", mb_search_in_test);
+
+ /* Creating a local MusicBrainz Server */
+ server = soup_server_new (SOUP_SERVER_PORT, 8088, NULL);
+ soup_server_add_handler (server, "/", (SoupServerCallback)default_handler,
+ NULL, NULL);
+ soup_server_add_handler (server, "/ws/2/artist",
+ (SoupServerCallback)artist_handler, NULL, NULL);
+ soup_server_add_handler (server,
+ "/ws/2/artist/5f000e69-3cfd-4871-8f1b-faa7f0d4bcbc",
+ (SoupServerCallback)westlife_handler, NULL, NULL);
+ soup_server_add_handler (server, "/ws/2/release",
+ (SoupServerCallback)release_handler, NULL, NULL);
+ soup_server_add_handler (server,
+ "/ws/2/release/fd77296e-86f0-436e-8ea2-b657151f2167",
+ (SoupServerCallback)never_gone_handler, NULL,
+ NULL);
+ soup_server_add_handler (server,
+ "/ws/2/release/30ac9626-4dac-457c-88be-11d0b7d2f5a4",
+ (SoupServerCallback)discid_release_handler, NULL,
+ NULL);
+ soup_server_add_handler (server,
+ "/ws/2/release/182fbd5e-5f3e-413a-9ff1-8a9a81d052c0",
+ (SoupServerCallback)westlife_release_info_handler,
+ NULL, NULL);
+ soup_server_add_handler (server, "/ws/2/recording",
+ (SoupServerCallback)recording_handler, NULL,
+ NULL);
+ soup_server_add_handler (server,
+ "/ws/2/recording/ddc5fc5c-8a83-4d20-a711-313797030da6",
+ (SoupServerCallback)i_still_handler, NULL,
+ NULL);
+ soup_server_add_handler (server, "/ws/2/discid",
+ (SoupServerCallback)discid_handler, NULL, NULL);
+
+ /* Running Server in a new thread */
+ thread = g_thread_new ("Server", run_server, NULL);
+
+ g_test_run ();
+
+ soup_server_quit (server);
+ g_object_unref (server);
+ g_thread_join (thread);
+ g_thread_unref (thread);
- return g_test_run();
+ return 0;
}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]