[rygel] test: Add unit tests for media art spec



commit 1258144d5de05d1ac0ce9a3a4e67bc95e0b241d6
Author: Jens Georg <mail jensge org>
Date:   Thu Jul 8 23:31:46 2010 +0300

    test: Add unit tests for media art spec
    
    Full spec can be found here: http://live.gnome.org/MediaArtStorageSpec.

 tests/Makefile.am                    |    7 +++
 tests/rygel-album-art-spec-test.vala |   97 ++++++++++++++++++++++++++++++++++
 tests/rygel-media-art-store.vala     |    1 +
 3 files changed, 105 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e3141aa..b35da2c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -31,6 +31,7 @@ check_PROGRAMS = rygel-http-item-uri-test \
 		 rygel-http-byte-seek-test \
 		 rygel-http-time-seek-test \
 		 rygel-http-get-test \
+		 rygel-album-art-spec-test \
 		 rygel-http-post-test
 
 TESTS = $(check_PROGRAMS)
@@ -75,3 +76,9 @@ rygel_http_post_test_SOURCES = rygel-http-post-test.vala \
 			       rygel-http-request_http-post.vala \
 			       rygel-http-item-uri_http-post.vala \
 			       rygel-state-machine_http-post.vala
+
+rygel_album_art_spec_test_SOURCES = rygel-album-art-spec-test.vala \
+			       rygel-media-art-store.vala \
+				   ../src/rygel/rygel-thumbnail.vala \
+				   ../src/rygel/rygel-icon-info.vala \
+				   ../src/rygel/rygel-album-art.vala
diff --git a/tests/rygel-album-art-spec-test.vala b/tests/rygel-album-art-spec-test.vala
new file mode 100644
index 0000000..5e08db6
--- /dev/null
+++ b/tests/rygel-album-art-spec-test.vala
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2010 Jens Georg.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel 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 program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+public class Rygel.MediaItem : GLib.Object {
+    public string title;
+    public string author;
+    public string album;
+}
+
+private class Rygel.AlbumArtSpecTest : GLib.Object {
+    public static int main (string[] args) {
+        var test = new AlbumArtSpecTest ();
+
+        test.run ();
+
+        return 0;
+    }
+
+    public void run() {
+        this.test_full_spec ();
+        //this.test_simple_spec ();
+    }
+
+    public void test_full_spec () {
+        var store = MediaArtStore.get_default ();
+        var item = new MediaItem ();
+        item.author = "metallica";
+        item.album = "and justice for all";
+        item.title = "Enter Sandman";
+        var file = store.get_media_art_file ("album", item);
+        assert (file != null);
+        assert (file.get_uri ().has_suffix
+                ("album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
+
+        file = store.get_media_art_file ("artist", item);
+        assert (file != null);
+        assert (file.get_uri ().has_suffix
+                ("artist-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
+
+        item = new MediaItem ();
+        item.title = "radio ga ga";
+        file = store.get_media_art_file ("radio", item);
+        assert (file != null);
+        assert (file.get_uri ().has_suffix
+                ("radio-b924ce08955675c6a30c745d18286d21-7215ee9c7d9dc229d2921a40e899ec5f.jpeg"));
+
+        item = new MediaItem ();
+        item.author = "met[xXx]allica";
+        item.album = "and justice f[{]}or all";
+        item.title = "Enter Sandman";
+        file = store.get_media_art_file ("album", item);
+        assert (file != null);
+        assert (file.get_uri ().has_suffix
+                ("album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
+
+        // check block removal algorithm - normalizes to "metallica" and not
+        // "metca"
+        item = new MediaItem ();
+        item.author = "met[xX[x]alli]ca";
+        item.album = "and justice for all";
+        item.title = "Enter Sandman";
+        file = store.get_media_art_file ("album", item);
+        assert (file != null);
+        assert (file.get_uri ().has_suffix
+                ("album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
+
+        /* Fails due to unclear spec
+        item = new MediaItem ();
+        item.author = "World Soccer";
+        item.title = "Daily Podcast";
+        file = store.get_media_art_file ("podcast", item);
+        assert (file != null);
+        assert (file.get_uri ().has_suffix
+                ("podcast-d717b10ec8fb35b11644995deb04b721-08d299536e562915eb133e2676396d3f.jpeg"));
+                */
+    }
+}
diff --git a/tests/rygel-media-art-store.vala b/tests/rygel-media-art-store.vala
new file mode 120000
index 0000000..ce7e89c
--- /dev/null
+++ b/tests/rygel-media-art-store.vala
@@ -0,0 +1 @@
+../src/rygel/rygel-media-art-store.vala
\ No newline at end of file



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]