diff options
author | Martyn Russell <martyn@lanedo.com> | 2014-02-17 14:01:24 +0000 |
---|---|---|
committer | Martyn Russell <martyn@lanedo.com> | 2014-06-23 05:31:44 +0100 |
commit | a1b2d8ba4b43a0055e6b1f56b830c286e6e41b76 (patch) | |
tree | 44448ea155a754b94d80c479699cd5a77d720a41 /tests/mediaarttest.c | |
parent | aca5903486319bf8ffda7898e24dbb72f6d0d6dc (diff) | |
download | libmediaart-a1b2d8ba4b43a0055e6b1f56b830c286e6e41b76.tar.gz |
extract: Allow error reporting with API using GError
Diffstat (limited to 'tests/mediaarttest.c')
-rw-r--r-- | tests/mediaarttest.c | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/tests/mediaarttest.c b/tests/mediaarttest.c index d02fb68..e94f453 100644 --- a/tests/mediaarttest.c +++ b/tests/mediaarttest.c @@ -203,7 +203,8 @@ test_mediaart_embedded_mp3 (void) "audio/mp3", /* mime */ MEDIA_ART_ALBUM, "King Kilo", /* artist */ - "Lanedo"); /* title */ + "Lanedo", /* title */ + NULL); g_assert_true (retval); @@ -245,7 +246,8 @@ test_mediaart_png (void) "image/png", /* mime */ MEDIA_ART_ALBUM, NULL, /* album */ - "Lanedo"); /* title */ + "Lanedo", /* title */ + NULL); g_assert_true (retval); @@ -283,6 +285,58 @@ test_mediaart_png (void) g_free (path); } +static void +test_mediaart_process_failures (void) +{ + 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*"); + + /* 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_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_message ("code:%d, domain:%d, error:'%s'\n", error->code, error->domain, error->message); */ +} + +static void +test_mediaart_process_failures_subprocess (void) +{ + GError *error = NULL; + + g_assert (!media_art_process (NULL, + NULL, + 0, + "image/png", /* mime */ + MEDIA_ART_ALBUM, + "Foo", /* album */ + "Bar", /* title */ + &error)); + g_assert_no_error (error); +} + int main (int argc, char **argv) { @@ -308,6 +362,10 @@ main (int argc, char **argv) test_mediaart_embedded_mp3); g_test_add_func ("/mediaart/png", test_mediaart_png); + g_test_add_func ("/mediaart/process_failures", + test_mediaart_process_failures); + g_test_add_func ("/mediaart/process_failures/subprocess", + test_mediaart_process_failures_subprocess); success = g_test_run (); |