[libdmapsharing] Fixes for test code
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Fixes for test code
- Date: Thu, 22 Mar 2018 06:33:18 +0000 (UTC)
commit 221542ebe88c4fd3d4421d912df81f6eb2a3b713
Author: W. Michael Petullo <mike flyn org>
Date: Thu Mar 22 02:32:50 2018 -0400
Fixes for test code
Signed-off-by: W. Michael Petullo <mike flyn org>
libdmapsharing/dmap-mdns-browser-avahi.c | 9 ++--
libdmapsharing/dmap-mdns-browser-dnssd.c | 7 +--
tests/dmapcopy.vala | 1 -
tests/dmapserve.c | 6 +++
tests/dmapserve.vala | 2 +
tests/test-dmap-client-python | 20 ++++-----
tests/test-dmap-client.c | 61 +++++++++++++++++++++++------
tests/test-dmap-server-python | 28 +++++++-------
tests/test-dmap-server.c | 4 ++
tests/testpython.py | 34 ++++++++---------
10 files changed, 106 insertions(+), 66 deletions(-)
---
diff --git a/libdmapsharing/dmap-mdns-browser-avahi.c b/libdmapsharing/dmap-mdns-browser-avahi.c
index 055f78b..7abedde 100644
--- a/libdmapsharing/dmap-mdns-browser-avahi.c
+++ b/libdmapsharing/dmap-mdns-browser-avahi.c
@@ -202,13 +202,12 @@ dmap_mdns_browser_new (DmapMdnsServiceType type)
{
DmapMdnsBrowser *browser_object;
- g_return_val_if_fail (type >= DMAP_MDNS_SERVICE_TYPE_INVALID
- && type <= DMAP_MDNS_SERVICE_TYPE_LAST,
- NULL);
+ g_assert(type > DMAP_MDNS_SERVICE_TYPE_INVALID);
+ g_assert(type <= DMAP_MDNS_SERVICE_TYPE_LAST);
browser_object =
- DMAP_MDNS_BROWSER (g_object_new
- (DMAP_TYPE_MDNS_BROWSER, NULL));
+ DMAP_MDNS_BROWSER (g_object_new (DMAP_TYPE_MDNS_BROWSER, NULL));
+
browser_object->priv->service_type = type;
return browser_object;
diff --git a/libdmapsharing/dmap-mdns-browser-dnssd.c b/libdmapsharing/dmap-mdns-browser-dnssd.c
index b56a9c5..f633edf 100644
--- a/libdmapsharing/dmap-mdns-browser-dnssd.c
+++ b/libdmapsharing/dmap-mdns-browser-dnssd.c
@@ -515,14 +515,13 @@ dmap_mdns_browser_class_init (DmapMdnsBrowserClass * klass)
DmapMdnsBrowser *
dmap_mdns_browser_new (DmapMdnsServiceType type)
{
- DmapMdnsBrowser *browser_object = 0;
+ DmapMdnsBrowser *browser_object;
g_assert(type > DMAP_MDNS_SERVICE_TYPE_INVALID);
g_assert(type <= DMAP_MDNS_SERVICE_TYPE_LAST);
- browser_object = DMAP_MDNS_BROWSER (g_object_new
- (DMAP_TYPE_MDNS_BROWSER,
- NULL));
+ browser_object =
+ DMAP_MDNS_BROWSER (g_object_new (DMAP_TYPE_MDNS_BROWSER, NULL));
browser_object->priv->service_type = type;
diff --git a/tests/dmapcopy.vala b/tests/dmapcopy.vala
index 8a4902b..60a48ea 100644
--- a/tests/dmapcopy.vala
+++ b/tests/dmapcopy.vala
@@ -30,7 +30,6 @@ private class DPAPCopy {
GLib.debug ("%" + int64.FORMAT + " entries\n", db.count ());
db.foreach ((k, v) => {
-
stdout.printf ("%s\n", ((ValaImageRecord) v).location);
/* Uncomment to copy the data:
diff --git a/tests/dmapserve.c b/tests/dmapserve.c
index 76a9986..bbe5079 100644
--- a/tests/dmapserve.c
+++ b/tests/dmapserve.c
@@ -138,6 +138,8 @@ DPAPServe* dpap_serve_construct (GType object_type, GError** error) {
ValaDmapDb* _tmp5_;
ValaDmapContainerDb* _tmp6_;
DmapImageShare* _tmp7_;
+ DmapImageShare* _tmp8_;
+ DmapImageShare* _tmp9_;
self = (DPAPServe*) g_type_create_instance (object_type);
_tmp0_ = vala_image_record_new ();
_g_object_unref0 (self->priv->record);
@@ -156,6 +158,10 @@ DPAPServe* dpap_serve_construct (GType object_type, GError** error) {
_tmp7_ = dmap_image_share_new ("dmapserve", NULL, _tmp5_, _tmp6_, NULL);
_g_object_unref0 (self->priv->share);
self->priv->share = _tmp7_;
+ _tmp8_ = self->priv->share;
+ dmap_share_serve ((DmapShare*) _tmp8_);
+ _tmp9_ = self->priv->share;
+ dmap_share_publish ((DmapShare*) _tmp9_);
return self;
}
diff --git a/tests/dmapserve.vala b/tests/dmapserve.vala
index 82bd5a0..cde90c1 100644
--- a/tests/dmapserve.vala
+++ b/tests/dmapserve.vala
@@ -32,6 +32,8 @@ private class DPAPServe {
db.add (record);
container_db = new ValaDmapContainerDb ();
share = new Dmap.ImageShare ("dmapserve", null, db, container_db, null);
+ share.serve();
+ share.publish();
}
}
diff --git a/tests/test-dmap-client-python b/tests/test-dmap-client-python
index 905dba8..a829f2a 100755
--- a/tests/test-dmap-client-python
+++ b/tests/test-dmap-client-python
@@ -3,23 +3,21 @@
import gi
import sys
-gi.require_version('DMAP', '4.0')
-gi.require_version('DAAP', '4.0')
+gi.require_version('Dmap', '4.0')
from gi.repository import GObject
from gi.repository import GLib
-from gi.repository import DMAP
-from gi.repository import DAAP
+from gi.repository import Dmap
import testpython
-class TestDMAPClient(GObject.GObject):
+class TestDmapClient(GObject.GObject):
def __init__(self):
- super(TestDMAPClient, self).__init__()
+ super(TestDmapClient, self).__init__()
- self.factory = testpython.PyDAAPRecordFactory()
- self.db = testpython.PyDMAPDb()
- self.browser = DMAP.MdnsBrowser.new(DMAP.MdnsServiceType.DAAP)
+ self.factory = testpython.PyDaapRecordFactory()
+ self.db = testpython.PyDmapDb()
+ self.browser = Dmap.MdnsBrowser.new(Dmap.MdnsServiceType.DAAP)
def start(self):
self.browser.connect('service-added', self.service_added_cb, None)
@@ -66,10 +64,10 @@ class TestDMAPClient(GObject.GObject):
host = service.get_property('host')
port = service.get_property('port')
- connection = DAAP.Connection.new(service_name, host, port, self.db, self.factory)
+ connection = Dmap.AvConnection.new(service_name, host, port, self.db, self.factory)
connection.connect('authenticate', self.authenticate_cb)
connection.start(self.connected_cb, self.db)
-client = TestDMAPClient ()
+client = TestDmapClient ()
client.start ()
GLib.MainLoop().run()
diff --git a/tests/test-dmap-client.c b/tests/test-dmap-client.c
index de61fc2..b97f878 100644
--- a/tests/test-dmap-client.c
+++ b/tests/test-dmap-client.c
@@ -38,19 +38,35 @@ static guint conn_type = DAAP;
static void
print_record (guint id, DmapRecord *record, gpointer user_data)
{
- gboolean has_video;
- gchar *artist, *title;
-
- g_object_get (record,
- "has-video", &has_video,
- "songartist", &artist,
- "title", &title,
- NULL);
-
- g_print ("%d: %s %s (has video: %s)\n", id, artist, title, has_video ? "Y" : "N");
-
- g_free (artist);
- g_free (title);
+ if (IS_DMAP_AV_RECORD(record)) {
+ gboolean has_video;
+ gchar *artist, *title;
+
+ g_object_get (record,
+ "has-video", &has_video,
+ "songartist", &artist,
+ "title", &title,
+ NULL);
+
+ g_print ("%d: %s %s (has video: %s)\n", id, artist, title, has_video ? "Y" : "N");
+
+ g_free (artist);
+ g_free (title);
+ } else if (IS_DMAP_IMAGE_RECORD(record)) {
+ gchar *format, *location;
+
+ g_object_get (record,
+ "format", &format,
+ "location", &location,
+ NULL);
+
+ g_print ("%d: %s %s\n", id, format, location);
+
+ g_free (format);
+ g_free (location);
+ } else {
+ g_assert_not_reached();
+ }
}
static void
@@ -133,11 +149,30 @@ service_added_cb (DmapMdnsBrowser *browser,
g_free(host);
}
+static void
+_log_printf(const char *log_domain,
+ GLogLevelFlags level,
+ const gchar *message,
+ gpointer user_data)
+{
+ g_printerr("%s: %s\n", log_domain, message);
+}
+
int main(int argc, char **argv)
{
DmapMdnsBrowser *browser;
GError *error = NULL;
+ g_log_set_handler ("libdmapsharing",
+ G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ _log_printf,
+ NULL);
+
+ g_log_set_handler ("dmapd",
+ G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ _log_printf,
+ NULL);
+
if (argc == 2)
conn_type = atoi (argv[1]);
diff --git a/tests/test-dmap-server-python b/tests/test-dmap-server-python
index 7614147..56c5e5a 100755
--- a/tests/test-dmap-server-python
+++ b/tests/test-dmap-server-python
@@ -3,28 +3,26 @@
import gi
import sys
-gi.require_version('DMAP', '4.0')
-gi.require_version('DAAP', '4.0')
+gi.require_version('Dmap', '4.0')
from gi.repository import GObject
from gi.repository import GLib
-from gi.repository import DMAP
-from gi.repository import DAAP
+from gi.repository import Dmap
import testpython
-class TestDMAPServer(GObject.GObject):
+class TestDmapServer(GObject.GObject):
def __init__(self):
- super(TestDMAPServer, self).__init__()
+ super(TestDmapServer, self).__init__()
name = 'Python libdmapsharing test'
- self.container_record = testpython.PyDMAPContainerRecord()
- self.container_db = testpython.PyDMAPContainerDb()
- self.factory = testpython.PyDAAPRecordFactory()
- self.db = testpython.PyDMAPDb()
+ self.container_record = testpython.PyDmapContainerRecord()
+ self.container_db = testpython.PyDmapContainerDb()
+ self.factory = testpython.PyDaapRecordFactory()
+ self.db = testpython.PyDmapDb()
- record = testpython.PyDAAPRecord()
+ record = testpython.PyDaapRecord()
record.set_property('title', 'test-title')
record.set_property('songalbum', 'test-album')
@@ -43,11 +41,13 @@ class TestDMAPServer(GObject.GObject):
record.set_property('disc', 7)
record.set_property('bitrate', 8)
record.set_property('has-video', False)
- record.set_property('mediakind', DMAP.MediaKind.MUSIC)
+ record.set_property('mediakind', Dmap.MediaKind.MUSIC)
self.db.add(record)
- self.share = DAAP.Share.new(name, 'password', self.db, self.container_db, 'audio/mp3')
+ self.share = Dmap.AvShare.new(name, 'password', self.db, self.container_db, 'audio/mp3')
+ self.share.serve()
+ self.share.publish()
-server = TestDMAPServer ()
+server = TestDmapServer ()
GLib.MainLoop().run()
diff --git a/tests/test-dmap-server.c b/tests/test-dmap-server.c
index 8d35e1c..1f30fc9 100644
--- a/tests/test-dmap-server.c
+++ b/tests/test-dmap-server.c
@@ -95,6 +95,10 @@ NULL));
g_assert (NULL != share);
+ dmap_share_serve(share);
+
+ dmap_share_publish(share);
+
g_free (name);
}
diff --git a/tests/testpython.py b/tests/testpython.py
index 8b5c56f..99e7f29 100644
--- a/tests/testpython.py
+++ b/tests/testpython.py
@@ -1,14 +1,12 @@
import gi
-gi.require_version('DMAP', '4.0')
-gi.require_version('DAAP', '4.0')
+gi.require_version('Dmap', '4.0')
from gi.repository import GObject
from gi.repository import GLib
-from gi.repository import DMAP
-from gi.repository import DAAP
+from gi.repository import Dmap
-class PyDMAPDb(GObject.GObject, DMAP.Db):
+class PyDmapDb(GObject.GObject, Dmap.Db):
db = {}
nextId = 0
@@ -29,9 +27,9 @@ class PyDMAPDb(GObject.GObject, DMAP.Db):
return self.db[id]
def __init__(self):
- super(PyDMAPDb, self).__init__()
+ super(PyDmapDb, self).__init__()
-class PyDAAPRecord(GObject.GObject, DAAP.Record, DMAP.Record):
+class PyDaapRecord(GObject.GObject, Dmap.AvRecord, Dmap.Record):
location = GObject.property(type=GObject.TYPE_STRING, default=None)
title = GObject.property(type=GObject.TYPE_STRING, default=None)
songalbum = GObject.property(type=GObject.TYPE_STRING, default=None)
@@ -50,23 +48,23 @@ class PyDAAPRecord(GObject.GObject, DAAP.Record, DMAP.Record):
disc = GObject.property(type=GObject.TYPE_INT, default=0)
bitrate = GObject.property(type=GObject.TYPE_INT, default=0)
has_video = GObject.property(type=GObject.TYPE_BOOLEAN, default=0)
- mediakind = GObject.property(type=DMAP.MediaKind, default=DMAP.MediaKind.MUSIC)
+ mediakind = GObject.property(type=Dmap.MediaKind, default=Dmap.MediaKind.MUSIC)
songalbumid = GObject.property(type=GObject.TYPE_INT64, default=0)
hash = GObject.property(type=GLib.Array, default=None)
def __init__(self):
- super(PyDAAPRecord, self).__init__()
+ super(PyDaapRecord, self).__init__()
-class PyDAAPRecordFactory(GObject.GObject, DMAP.RecordFactory):
+class PyDaapRecordFactory(GObject.GObject, Dmap.RecordFactory):
def do_create (self, user_data=None):
- return PyDAAPRecord()
+ return PyDaapRecord()
def __init__(self):
- super(PyDAAPRecordFactory, self).__init__()
+ super(PyDaapRecordFactory, self).__init__()
-class PyDMAPContainerRecord(GObject.GObject, DMAP.ContainerRecord):
+class PyDmapContainerRecord(GObject.GObject, Dmap.ContainerRecord):
name = GObject.property(type=GObject.TYPE_STRING, default='Test')
- entries = PyDMAPDb()
+ entries = PyDmapDb()
def do_get_id(self):
return 2
@@ -81,10 +79,10 @@ class PyDMAPContainerRecord(GObject.GObject, DMAP.ContainerRecord):
return self.entries
def __init__(self):
- super(PyDMAPContainerRecord, self).__init__()
+ super(PyDmapContainerRecord, self).__init__()
-class PyDMAPContainerDb(GObject.GObject, DMAP.ContainerDb):
- record = PyDMAPContainerRecord()
+class PyDmapContainerDb(GObject.GObject, Dmap.ContainerDb):
+ record = PyDmapContainerRecord()
def do_add(self, record):
pass
@@ -99,4 +97,4 @@ class PyDMAPContainerDb(GObject.GObject, DMAP.ContainerDb):
return self.record
def __init__(self):
- super(PyDMAPContainerDb, self).__init__()
+ super(PyDmapContainerDb, self).__init__()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]