[rygel] tests: Update test against latest MediaItem changes



commit 3df772e437e20b883bf0a6904acf659cf0218c81
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Aug 25 19:23:46 2010 +0300

    tests: Update test against latest MediaItem changes

 tests/rygel-album-art-spec-test.vala |   32 ++++++++++++++-----------
 tests/rygel-http-get-test.vala       |   42 ++++++++++++++++++++++++++++++---
 tests/rygel-http-time-seek-test.vala |   19 ++++++++++-----
 3 files changed, 69 insertions(+), 24 deletions(-)
---
diff --git a/tests/rygel-album-art-spec-test.vala b/tests/rygel-album-art-spec-test.vala
index 7e27099..b3979a7 100644
--- a/tests/rygel-album-art-spec-test.vala
+++ b/tests/rygel-album-art-spec-test.vala
@@ -20,10 +20,14 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-
-public class Rygel.MediaItem : GLib.Object {
+public abstract class Rygel.MediaItem : GLib.Object {
     public string title;
-    public string author;
+}
+
+public class Rygel.AudioItem : MediaItem {}
+
+public class Rygel.MusicItem : AudioItem {
+    public string artist;
     public string album;
 }
 
@@ -43,8 +47,8 @@ private class Rygel.AlbumArtSpecTest : GLib.Object {
 
     public void test_full_spec () {
         var store = MediaArtStore.get_default ();
-        var item = new MediaItem ();
-        item.author = "metallica";
+        var item = new MusicItem ();
+        item.artist = "metallica";
         item.album = "and justice for all";
         item.title = "Enter Sandman";
         var file = store.get_media_art_file ("album", item);
@@ -57,15 +61,15 @@ private class Rygel.AlbumArtSpecTest : GLib.Object {
         assert (file.get_uri ().has_suffix
                 ("artist-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
 
-        item = new MediaItem ();
+        item = new MusicItem ();
         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 = new MusicItem ();
+        item.artist = "met[xXx]allica";
         item.album = "and justice f[{]}or all";
         item.title = "Enter Sandman";
         file = store.get_media_art_file ("album", item);
@@ -75,8 +79,8 @@ private class Rygel.AlbumArtSpecTest : GLib.Object {
 
         // check block removal algorithm - normalizes to "metallica" and not
         // "metca"
-        item = new MediaItem ();
-        item.author = "met[xX[x]alli]ca";
+        item = new MusicItem ();
+        item.artist = "met[xX[x]alli]ca";
         item.album = "and justice for all";
         item.title = "Enter Sandman";
         file = store.get_media_art_file ("album", item);
@@ -85,8 +89,8 @@ private class Rygel.AlbumArtSpecTest : GLib.Object {
                 ("album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
 
         /* Fails due to unclear spec
-        item = new MediaItem ();
-        item.author = "World Soccer";
+        item = new MusicItem ();
+        item.artist = "World Soccer";
         item.title = "Daily Podcast";
         file = store.get_media_art_file ("podcast", item);
         assert (file != null);
@@ -95,8 +99,8 @@ private class Rygel.AlbumArtSpecTest : GLib.Object {
                 */
 
         // test banshee spec
-        item = new MediaItem ();
-        item.author = "Peter Fox";
+        item = new MusicItem ();
+        item.artist = "Peter Fox";
         item.album = "Stadtaffe";
         item.title = "Schwarz zu Blau";
         file = store.get_media_art_file ("album", item, true);
diff --git a/tests/rygel-http-get-test.vala b/tests/rygel-http-get-test.vala
index df202dd..010c878 100644
--- a/tests/rygel-http-get-test.vala
+++ b/tests/rygel-http-get-test.vala
@@ -220,7 +220,7 @@ public class Rygel.MediaContainer : Rygel.MediaObject {
         yield;
 
         if (item_id == ITEM_ID) {
-            return new MediaItem ();
+            return new VideoItem ();
         } else {
             return null;
         }
@@ -244,15 +244,47 @@ internal class Rygel.HTTPIdentityHandler : Rygel.HTTPGetHandler {
     public HTTPIdentityHandler (Cancellable cancellable) {}
 }
 
-public class Rygel.MediaItem : Rygel.MediaObject {
+public abstract class Rygel.MediaItem : Rygel.MediaObject {
     public long size = 1024;
-    public long duration = 1024;
     public ArrayList<Subtitle> subtitles = new ArrayList<Subtitle> ();
     public ArrayList<Thumbnail> thumbnails = new ArrayList<Thumbnail> ();
 
     public bool should_stream () {
         return true;
     }
+
+    public bool streamable () {
+        return true;
+    }
+}
+
+private class Rygel.AudioItem : MediaItem {
+    public int64 duration = 2048;
+}
+
+private interface Rygel.VisualItem : MediaItem {
+    public abstract int width { get; set; }
+    public abstract int height { get; set; }
+    public abstract int pixel_width { get; set; }
+    public abstract int pixel_height { get; set; }
+    public abstract int color_depth { get; set; }
+
+    public abstract ArrayList<Thumbnail> thumbnails { get; protected set; }
+}
+
+private class Rygel.VideoItem : AudioItem, VisualItem {
+    public int width { get; set; default = -1; }
+    public int height { get; set; default = -1; }
+    public int pixel_width { get; set; default = -1; }
+    public int pixel_height { get; set; default = -1; }
+    public int color_depth { get; set; default = -1; }
+
+    public ArrayList<Thumbnail> thumbnails { get; protected set; }
+    public ArrayList<Subtitle> subtitles;
+}
+
+private class Rygel.MusicItem : AudioItem {
+    public Thumbnail album_art;
 }
 
 public class Rygel.Thumbnail {
@@ -292,6 +324,8 @@ internal class Rygel.HTTPResponse : Rygel.StateMachine, GLib.Object {
     }
 }
 
+public class Rygel.MediaObject {
+    public string id;
+}
 
 public class Rygel.Transcoder {}
-public class Rygel.MediaObject {}
diff --git a/tests/rygel-http-time-seek-test.vala b/tests/rygel-http-time-seek-test.vala
index 56e0b18..afe493c 100644
--- a/tests/rygel-http-time-seek-test.vala
+++ b/tests/rygel-http-time-seek-test.vala
@@ -29,8 +29,7 @@ private errordomain Rygel.TestError {
 
 private class Rygel.HTTPTranscodeHandler : GLib.Object {}
 
-private class Rygel.MediaItem : GLib.Object {
-    public int64 duration = 2048;
+private abstract class Rygel.MediaItem : GLib.Object {
     public int64 size = -1;
 
     public virtual bool should_stream () {
@@ -38,6 +37,10 @@ private class Rygel.MediaItem : GLib.Object {
     }
 }
 
+private class Rygel.AudioItem : MediaItem {
+    public int64 duration = 2048;
+}
+
 private class Rygel.Thumbnail : GLib.Object {}
 private class Rygel.Subtitle : GLib.Object {}
 
@@ -53,7 +56,7 @@ private class Rygel.HTTPGet : GLib.Object {
 
     public HTTPGet (Thumbnail? thumbnail, Subtitle? subtitle) {
         this.msg = new Soup.Message ("HTTP", ITEM_URI);
-        this.item = new MediaItem ();
+        this.item = new AudioItem ();
         this.handler = new HTTPTranscodeHandler ();
         this.thumbnail = thumbnail;
         this.subtitle = subtitle;
@@ -134,16 +137,18 @@ private class Rygel.HTTPTimeSeekTest : GLib.Object {
     private void test_no_seek (Thumbnail? thumbnail,
                                Subtitle?  subtitle) throws HTTPSeekError {
         var request = new HTTPGet (thumbnail, subtitle);
+        var audio_item = request.item as AudioItem;
 
-        this.test_seek (request, 0, request.item.duration - 1);
+        this.test_seek (request, 0, audio_item.duration - 1);
     }
 
     private void test_start_only_seek (Thumbnail? thumbnail,
                                        Subtitle?  subtitle)
                                        throws HTTPSeekError {
         var request = new HTTPGet.seek_start (128, thumbnail, subtitle);
+        var audio_item = request.item as AudioItem;
 
-        this.test_seek (request, 128, request.item.duration - 1);
+        this.test_seek (request, 128, audio_item.duration - 1);
     }
 
     private void test_stop_only_seek (Thumbnail? thumbnail,
@@ -177,7 +182,9 @@ private class Rygel.HTTPTimeSeekTest : GLib.Object {
         assert (seek.start == start * SECOND);
         assert (seek.stop == stop * SECOND);
         assert (seek.length == seek.stop + 1 - seek.start);
-        assert (seek.total_length == request.item.duration * SECOND);
+
+        var audio_item = request.item as AudioItem;
+        assert (seek.total_length == audio_item.duration * SECOND);
 
         var header = request.msg.response_headers.get_one (
                                         "TimeSeekRange.dlna.org");



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