summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-01-13 08:47:08 +0200
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-01-13 08:47:08 +0200
commitf15c9a9aaacfde28fe1275ec337f0ad96abe8851 (patch)
tree38e46dbd59465e25b758fc4bdb3ec241dd37fceb
parent34cc1e61a9f32d371470934f0177b4810b67a873 (diff)
downloadlibresourceqt-f15c9a9aaacfde28fe1275ec337f0ad96abe8851.tar.gz
libplayback tests: testConnectToServer()
-rw-r--r--include/resource.h2
-rw-r--r--src/libplayback-wrapper.cpp5
-rw-r--r--src/resource-factory.cpp1
-rw-r--r--src/resource.cpp3
-rw-r--r--tests/test-libplayback.cpp22
-rw-r--r--tests/test-libplayback.h8
6 files changed, 37 insertions, 4 deletions
diff --git a/include/resource.h b/include/resource.h
index 3399b7c..d1c386a 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -98,7 +98,7 @@ public:
//! \internal Stores the new state and emits a stateChanged() signal.
void handleStateChange(enum ResourceState newState);
- //! \internal Emits the exclusiveAccessIsAvailable() signal.
+ //! \internal Emits the reservable() signal.
void emitReservable();
//! Reserve exclusive access to our resources.
diff --git a/src/libplayback-wrapper.cpp b/src/libplayback-wrapper.cpp
index d260380..90b5f6a 100644
--- a/src/libplayback-wrapper.cpp
+++ b/src/libplayback-wrapper.cpp
@@ -24,6 +24,7 @@ bool LibPlaybackWrapper::initialize()
DBusError dbusError;
dbus_error_init(&dbusError);
dbusConnection = dbus_bus_get(DBUS_BUS_SESSION, &dbusError);
+ qDebug("dbusConnection=%p", dbusConnection);
if (dbus_error_is_set(&dbusError)) {
qDebug("D-Bus Connection Error (%s)\n", dbusError.message);
dbus_error_free(&dbusError);
@@ -40,6 +41,10 @@ bool LibPlaybackWrapper::connectToServer()
{
enum pb_class_e libPlaybackClass = resourceClassToLibPlaybackClass(resource->applicationClass());
quint16 libPlaybackFlags = resourceFlagsToLibPlaybackFlags(resource->resources());
+
+ qDebug("libPlaybackFlags=%02x resources=%02x",libPlaybackFlags, resource->resources());
+ qDebug("dbusConnection=%p", dbusConnection);
+
libPlaybackHandle = pb_playback_new_2(dbusConnection, libPlaybackClass, libPlaybackFlags,
PB_STATE_STOP, libPlaybackStateHandler, this);
if(libPlaybackHandle == NULL) {
diff --git a/src/resource-factory.cpp b/src/resource-factory.cpp
index c012bb9..f500792 100644
--- a/src/resource-factory.cpp
+++ b/src/resource-factory.cpp
@@ -15,6 +15,7 @@ ResourceFactory::~ResourceFactory()
Resource * ResourceFactory::createResource(enum ResourceClass applicationClass,
quint16 requestedResources)
{
+ qDebug("We %s connected to DBus",sessionBusConnection.isConnected()?"are":"are not");
Resource *resource = new Resource(applicationClass, requestedResources, this);
ResourceLibrary *libPlayback = new LibPlaybackWrapper(resource);
diff --git a/src/resource.cpp b/src/resource.cpp
index 76ef720..bc03847 100644
--- a/src/resource.cpp
+++ b/src/resource.cpp
@@ -13,12 +13,15 @@ Resource::~Resource()
bool Resource::initialize(ResourceLibrary *library)
{
+ qDebug("Resource::initialize");
resourceLibrary = library;
return resourceLibrary->initialize();
}
bool Resource::connectToServer()
{
+ if(resourceLibrary == NULL)
+ return false;
return resourceLibrary->connectToServer();
}
diff --git a/tests/test-libplayback.cpp b/tests/test-libplayback.cpp
index 5607104..ac4107c 100644
--- a/tests/test-libplayback.cpp
+++ b/tests/test-libplayback.cpp
@@ -6,23 +6,41 @@ TestLibplayback::TestLibplayback()
{
resourceFactory=NULL;
resource=NULL;
+ loop=NULL;
+ timer=NULL;
}
TestLibplayback::~TestLibplayback()
{
}
-void TestLibplayback::initTestCase()
+void TestLibplayback::init()
{
+ loop = new QEventLoop(this);
+ timer = new QTimer(this);
resourceFactory = new ResourceFactory(this);
QVERIFY(resourceFactory != NULL);
- Resource *resource = resourceFactory->createResource(MediaClass, AudioResource|VideoResource);
+ resource = resourceFactory->createResource(MediaClass, AudioResource|VideoResource);
QVERIFY(resource != NULL);
+
+ timer->setInterval(3000);
+ timer->setSingleShot(true);
}
void TestLibplayback::testConnectToServer()
{
+ connect(timer, SIGNAL(timeout()), loop, SLOT(quit()));
+
+ qDebug("connecting to server...");
resource->connectToServer();
+
+ loop->exec();
+}
+
+void TestLibplayback::timeout()
+{
+ qDebug("Timeout!");
+ loop->exit(0);
}
QTEST_MAIN(TestLibplayback)
diff --git a/tests/test-libplayback.h b/tests/test-libplayback.h
index 9c294e6..03ffc4a 100644
--- a/tests/test-libplayback.h
+++ b/tests/test-libplayback.h
@@ -2,6 +2,8 @@
#define TEST_RESOURCE_FACTORY_H
#include <QtTest/QTest>
+#include <QEventLoop>
+#include <QTimer>
#include "resource-factory.h"
#include "resource.h"
@@ -11,11 +13,15 @@ class TestLibplayback: public QObject
private:
ResourceFactory *resourceFactory;
Resource *resource;
+ QEventLoop *loop;
+ QTimer *timer;
public:
TestLibplayback();
~TestLibplayback();
+public slots:
+ void timeout();
private slots:
- void initTestCase();
+ void init();
void testConnectToServer();
};