summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartyn Russell <martyn@lanedo.com>2014-02-25 12:03:25 +0000
committerMartyn Russell <martyn@lanedo.com>2014-06-23 05:31:44 +0100
commit1ba4e37af21ecfd1beefbe33eb95aef846d4f408 (patch)
treee7fbf5889e432ce55c3e17be7020224daed2faf4 /tests
parent4e14f48b052c06c6f00e14d3437e67b162775aff (diff)
downloadlibmediaart-1ba4e37af21ecfd1beefbe33eb95aef846d4f408.tar.gz
extract: Switch to initable MediaArtProcess object from _init/_shutdown()
Diffstat (limited to 'tests')
-rw-r--r--tests/mediaarttest.c100
1 files changed, 67 insertions, 33 deletions
diff --git a/tests/mediaarttest.c b/tests/mediaarttest.c
index 893c585..11cd31a 100644
--- a/tests/mediaarttest.c
+++ b/tests/mediaarttest.c
@@ -76,9 +76,17 @@ struct {
};
static void
-test_mediaart_init (void)
+test_mediaart_new (void)
{
- g_assert_true (media_art_init ());
+ MediaArtProcess *process;
+ GError *error = NULL;
+
+ /* Test: creation of object */
+ process = media_art_process_new (&error);
+ g_assert_no_error (error);
+ g_assert (process != NULL);
+
+ g_object_unref (process);
}
static void
@@ -185,6 +193,7 @@ test_mediaart_location_path (void)
static void
test_mediaart_embedded_mp3 (void)
{
+ MediaArtProcess *process;
GError *error = NULL;
GFile *file = NULL;
gchar *dir, *path;
@@ -197,7 +206,11 @@ test_mediaart_embedded_mp3 (void)
file = g_file_new_for_path (path);
g_free (path);
- retval = media_art_process_file (file,
+ process = media_art_process_new (&error);
+ g_assert_no_error (error);
+
+ retval = media_art_process_file (process,
+ file,
NULL,
0,
"audio/mp3", /* mime */
@@ -211,11 +224,14 @@ test_mediaart_embedded_mp3 (void)
g_object_unref (file);
g_free (dir);
+
+ g_object_unref (process);
}
static void
test_mediaart_png (void)
{
+ MediaArtProcess *process;
GError *error = NULL;
GFile *file = NULL;
gchar *dir, *path;
@@ -229,6 +245,9 @@ test_mediaart_png (void)
file = g_file_new_for_path (path);
g_free (dir);
+ process = media_art_process_new (&error);
+ g_assert_no_error (error);
+
/* Check data is not cached currently */
media_art_get_path ("Lanedo", /* artist / title */
NULL, /* album */
@@ -241,7 +260,8 @@ test_mediaart_png (void)
g_free (out_uri);
/* Process data */
- retval = media_art_process_file (file,
+ retval = media_art_process_file (process,
+ file,
NULL,
0,
"image/png", /* mime */
@@ -284,58 +304,74 @@ test_mediaart_png (void)
g_object_unref (file);
g_free (path);
+
+ g_object_unref (process);
}
static void
test_mediaart_process_failures (void)
{
+ MediaArtProcess *process;
GError *error = NULL;
g_test_trap_subprocess ("/mediaart/process_failures/subprocess", 0, 0 /*G_TEST_SUBPROCESS_INHERIT_STDOUT | G_TEST_SUBPROCESS_INHERIT_STDERR*/);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*assertion 'uri != NULL' failed*");
+ process = media_art_process_new (&error);
+ g_assert_no_error (error);
+
/* Test: invalid file */
- g_assert (!media_art_process ("file:///invalid/path.png",
- NULL,
- 0,
- "image/png", /* mime */
- MEDIA_ART_ALBUM,
- "Foo", /* album */
- "Bar", /* title */
- &error));
+ g_assert (!media_art_process_uri (process,
+ "file:///invalid/path.png",
+ NULL,
+ 0,
+ "image/png", /* mime */
+ MEDIA_ART_ALBUM,
+ "Foo", /* album */
+ "Bar", /* title */
+ &error));
g_assert_error (error, g_io_error_quark(), G_IO_ERROR_NOT_FOUND);
g_clear_error (&error);
-
/* Test: Invalid mime type */
- /* g_assert (!media_art_process ("file:///invalid/path.png", */
- /* NULL, */
- /* 0, */
- /* "image/png", /\* mime *\/ */
- /* MEDIA_ART_ALBUM, */
- /* "Foo", /\* album *\/ */
- /* "Bar", /\* title *\/ */
- /* &error)); */
+ /* g_assert (!media_art_process_uri (process, */
+ /* "file:///invalid/path.png", */
+ /* NULL, */
+ /* 0, */
+ /* "image/png", /\* mime *\/ */
+ /* MEDIA_ART_ALBUM, */
+ /* "Foo", /\* album *\/ */
+ /* "Bar", /\* title *\/ */
+ /* &error)); */
/* g_message ("code:%d, domain:%d, error:'%s'\n", error->code, error->domain, error->message); */
+
+ g_object_unref (process);
}
static void
test_mediaart_process_failures_subprocess (void)
{
+ MediaArtProcess *process;
GError *error = NULL;
- g_assert (!media_art_process (NULL,
- NULL,
- 0,
- "image/png", /* mime */
- MEDIA_ART_ALBUM,
- "Foo", /* album */
- "Bar", /* title */
- &error));
+ process = media_art_process_new (&error);
g_assert_no_error (error);
+
+ g_assert (!media_art_process_uri (process,
+ NULL,
+ NULL,
+ 0,
+ "image/png", /* mime */
+ MEDIA_ART_ALBUM,
+ "Foo", /* album */
+ "Bar", /* title */
+ &error));
+ g_assert_no_error (error);
+
+ g_object_unref (process);
}
int
@@ -345,8 +381,8 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/mediaart/init",
- test_mediaart_init);
+ g_test_add_func ("/mediaart/new",
+ test_mediaart_new);
g_test_add_func ("/mediaart/stripping",
test_mediaart_stripping);
g_test_add_func ("/mediaart/stripping_failures",
@@ -370,7 +406,5 @@ main (int argc, char **argv)
success = g_test_run ();
- media_art_shutdown ();
-
return success;
}