summaryrefslogtreecommitdiff
path: root/tests
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 /tests
parent34cc1e61a9f32d371470934f0177b4810b67a873 (diff)
downloadlibresourceqt-f15c9a9aaacfde28fe1275ec337f0ad96abe8851.tar.gz
libplayback tests: testConnectToServer()
Diffstat (limited to 'tests')
-rw-r--r--tests/test-libplayback.cpp22
-rw-r--r--tests/test-libplayback.h8
2 files changed, 27 insertions, 3 deletions
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();
};