Assamese translation updated
[profile/ivi/rygel.git] / tests / rygel-object-creator-test.vala
index f2cbb45..80b8395 100644 (file)
@@ -108,6 +108,11 @@ public class Rygel.ObjectRemovalQueue : GLib.Object {
     }
 }
 
+public class Rygel.MediaServerPlugin : GLib.Object {
+    public GLib.List<DLNAProfile> upload_profiles = new GLib.List<DLNAProfile>
+        ();
+}
+
 public class Rygel.MediaObject : GLib.Object {
     public string id {get; set; }
     public string ref_id;
@@ -210,10 +215,23 @@ public class Rygel.PlaylistItem : Rygel.MediaItem {
     }
 }
 
+public class Rygel.RootDevice : GLib.Object {
+    public MediaServerPlugin resource_factory;
+
+    public RootDevice () {
+        this.resource_factory = new MediaServerPlugin ();
+    }
+}
+
 public class Rygel.ContentDirectory : GLib.Object {
     public Cancellable cancellable;
     public MediaContainer root_container;
     public HTTPServer http_server;
+    public RootDevice root_device;
+
+    public ContentDirectory () {
+        this.root_device = new RootDevice ();
+    }
 }
 
 public class Rygel.MediaContainer : Rygel.MediaObject {
@@ -221,6 +239,7 @@ public class Rygel.MediaContainer : Rygel.MediaObject {
     public int child_count { get; set; }
     public string sort_criteria = "+dc:title";
     public static const string ANY = "DLNA.ORG_AnyContainer";
+    public static const string UPNP_CLASS = "object.container";
     public static const string STORAGE_FOLDER =
         "object.container.storageFolder";
     public static const string PLAYLIST =
@@ -282,6 +301,7 @@ public class Rygel.SearchableContainer : Rygel.MediaContainer {
 public errordomain Rygel.ContentDirectoryError {
     BAD_METADATA,
     NO_SUCH_OBJECT,
+    NO_SUCH_CONTAINER,
     INVALID_ARGS,
     RESTRICTED_PARENT,
     ERROR
@@ -290,30 +310,6 @@ public errordomain Rygel.ContentDirectoryError {
 public class Rygel.Transcoder {
 }
 
-public class Rygel.TestMediaEngine : Rygel.MediaEngine {
-    private GLib.List<DLNAProfile> dlna_profiles = new GLib.List<DLNAProfile>();
-
-    public override unowned GLib.List<DLNAProfile> get_dlna_profiles () {
-        return dlna_profiles;
-    }
-
-    public override unowned GLib.List<Transcoder>? get_transcoders () {
-        return null;
-    }
-
-    public override DataSource? create_data_source (string uri) {
-        return null;
-    }
-}
-
-public class Rygel.EngineLoader {
-    public EngineLoader () { }
-
-    public MediaEngine load_engine () {
-        return new TestMediaEngine ();
-    }
-}
-
 public static void log_func (string? domain,
                              LogLevelFlags flags,
                              string message) {
@@ -353,12 +349,14 @@ public class Rygel.HTTPObjectCreatorTest : GLib.Object {
 
     // expected errors
     Error no_such_object;
+    Error no_such_container;
     Error restricted_parent;
     Error bad_metadata;
     Error invalid_args;
 
     public HTTPObjectCreatorTest () {
         this.no_such_object = new ContentDirectoryError.NO_SUCH_OBJECT("");
+        this.no_such_container = new ContentDirectoryError.NO_SUCH_CONTAINER("");
         this.restricted_parent = new ContentDirectoryError.RESTRICTED_PARENT("");
         this.bad_metadata = new ContentDirectoryError.BAD_METADATA("");
         this.invalid_args = new ContentDirectoryError.INVALID_ARGS("");
@@ -371,7 +369,7 @@ public class Rygel.HTTPObjectCreatorTest : GLib.Object {
         var action = new ServiceAction (null, "");
         var creator = new ObjectCreator (content_directory, action);
         creator.run.begin ();
-        assert (action.error_code == no_such_object.code);
+        assert (action.error_code == invalid_args.code);
 
         // check elements containing a comment
         action = new ServiceAction ("0", "<!-- This is an XML comment -->");
@@ -428,7 +426,7 @@ public class Rygel.HTTPObjectCreatorTest : GLib.Object {
 
         // test item node with restricted=1
         tmp->set_prop ("restricted", "1");
-        this.test_didl_parsing_step (xml, invalid_args.code);
+        this.test_didl_parsing_step (xml, bad_metadata.code);
 
         // test item node with invalid id
         tmp->unlink ();
@@ -475,13 +473,13 @@ public class Rygel.HTTPObjectCreatorTest : GLib.Object {
         var action = new ServiceAction ("0", DIDL_ITEM);
         var creator = new ObjectCreator (content_directory, action);
         this.test_fetch_container_run (creator);
-        assert (action.error_code == no_such_object.code);
+        assert (action.error_code == no_such_container.code);
 
         // check case when found object is not a container → Error 710
         // cf. ContentDirectory:2 spec, Table 2-22
         root_container.found_object = new MediaObject ();
         this.test_fetch_container_run (creator);
-        assert (action.error_code == no_such_object.code);
+        assert (action.error_code == no_such_container.code);
 
         // check case when found container does not have OCMUpload set
         root_container.found_object = new MediaContainer ();
@@ -505,7 +503,7 @@ public class Rygel.HTTPObjectCreatorTest : GLib.Object {
         content_directory.root_container = new MediaContainer ();
         action.id = "DLNA.ORG_AnyContainer";
         this.test_fetch_container_run (creator);
-        assert (action.error_code == no_such_object.code);
+        assert (action.error_code == no_such_container.code);
 
         // check DLNA.ORG_AnyContainer when no writable container is found
         content_directory.root_container = new SearchableContainer ();