summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-resource-engine/test-resource-engine.cpp92
-rw-r--r--tests/test-resource-engine/test-resource-engine.h12
-rw-r--r--tests/test-resource-engine/test-resource-engine.pro21
-rw-r--r--tests/test-resource-set/test-resource-set.h2
-rw-r--r--tests/test-resource-set/test-resource-set.pro13
-rw-r--r--tests/test-resource/test-resource.h2
-rw-r--r--tests/test-resource/test-resource.pro12
-rw-r--r--tests/tests.pro4
-rw-r--r--tests/tests.xml4
9 files changed, 121 insertions, 41 deletions
diff --git a/tests/test-resource-engine/test-resource-engine.cpp b/tests/test-resource-engine/test-resource-engine.cpp
index 5c95224..ee2656f 100644
--- a/tests/test-resource-engine/test-resource-engine.cpp
+++ b/tests/test-resource-engine/test-resource-engine.cpp
@@ -2,13 +2,30 @@
#include <dbus/dbus.h>
using namespace ResourcePolicy;
+quint32 theID = 0;
+
+static void verify_resproto_init(resproto_role_t role,
+ resproto_transport_t transport,
+ resconn_linkup_t callbackFunction,
+ DBusConnection *dbusConnection);
+
+static void verify_resconn_connect(resconn_t *connection, resmsg_t *message,
+ resproto_status_t callbackFunction);
TestResourceEngine::TestResourceEngine()
- : resourceEngine(NULL), resourceSet(NULL),
- audioPlayback(AudioPlaybackResource), videoPlayback(VideoPlaybackResource),
- audioRecorder(AudioRecorderResource), videoRecorder(VideoRecorderResource)
+ : resourceEngine(NULL), resourceSet(NULL)
{
+ audioPlayback = new AudioResource;
+ videoPlayback = new VideoResource;
+ audioRecorder = new AudioRecorderResource;
+ videoRecorder = new VideoRecorderResource;
+
+ videoPlayback->setOptional();
+ audioRecorder->setOptional();
+ videoRecorder->setOptional();
+
resourceSet = new ResourceSet("player", this);
+ theID = resourceSet->id();
resourceSet->addResource(audioPlayback);
resourceSet->addResource(videoPlayback);
resourceSet->addResource(audioRecorder);
@@ -17,6 +34,10 @@ TestResourceEngine::TestResourceEngine()
TestResourceEngine::~TestResourceEngine()
{
+ delete audioPlayback;
+ delete videoPlayback;
+ delete audioRecorder;
+ delete videoRecorder;
}
void TestResourceEngine::init()
@@ -36,27 +57,78 @@ void TestResourceEngine::testConnect()
QTEST_MAIN(TestResourceEngine)
////////////////////////////////////////////////////////////////
+resconn_t *resourceConnection;
+resset_t *resSet;
resconn_t* resproto_init(resproto_role_t role, resproto_transport_t transport, ...)
{
- resconn_t *resourceConnection;
resconn_linkup_t callbackFunction;
- DBusConnection *dbusConnection, systemBus;
+ DBusConnection *dbusConnection;
va_list args;
- va_start();
+ va_start(args, transport);
callbackFunction = va_arg(args, resconn_linkup_t);
dbusConnection = va_arg(args, DBusConnection *);
- va_end();
+ va_end(args);
+
+ verify_resproto_init(role, transport, callbackFunction, dbusConnection);
+
+ resourceConnection =(resconn_t *) calloc(1, sizeof(resconn_t));
- systemBus = dbus_bus_get(DBUS_BUS_SYSTEM);
+ return resourceConnection;
+}
+
+static void verify_resproto_init(resproto_role_t role,
+ resproto_transport_t transport,
+ resconn_linkup_t callbackFunction,
+ DBusConnection *dbusConnection)
+{
+ DBusConnection *systemBus;
+ systemBus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
QVERIFY(callbackFunction != NULL);
QVERIFY(dbusConnection == systemBus);
QVERIFY(role == RESPROTO_ROLE_CLIENT);
QVERIFY(transport == RESPROTO_TRANSPORT_DBUS);
+}
- resourceConnection =(resconn_t *) calloc(1, sizeof(resconn_t));
+resset_t *resconn_connect(resconn_t *connection, resmsg_t *message,
+ resproto_status_t callbackFunction)
+{
+ verify_resconn_connect(connection, message, callbackFunction);
- return resourceConnection;
+ resSet = (resset_t *) calloc(1, sizeof(resset_t));
+
+ return resSet;
+}
+
+static void verify_resconn_connect(resconn_t *connection, resmsg_t *message,
+ resproto_status_t callbackFunction)
+{
+ QVERIFY(connection == resourceConnection);
+ QVERIFY(message->record.type == RESMSG_REGISTER);
+ QVERIFY(message->record.id == theID);
+ QVERIFY(message->record.reqno == 1);
+ QVERIFY(message->record.rset.all == (RESMSG_AUDIO_PLAYBACK|RESMSG_AUDIO_RECORDING
+ |RESMSG_VIDEO_PLAYBACK|RESMSG_VIDEO_RECORDING));
+ QVERIFY(message->record.rset.opt == (RESMSG_AUDIO_RECORDING|RESMSG_VIDEO_PLAYBACK
+ |RESMSG_VIDEO_RECORDING));
+ QVERIFY(message->record.rset.share == 0);
+ QVERIFY(message->record.rset.mask == 0);
+ QCOMPARE(message->record.klass, "player");
+ QVERIFY(message->record.mode == 0);
+ QVERIFY(callbackFunction != NULL);
+}
+
+char *resmsg_res_str(uint32_t res, char *buf, int len)
+{
+ snprintf(buf, len, "0x%04x", res);
+
+ return buf;
}
+
+int resproto_set_handler(union resconn_u *, resmsg_type_t, resproto_handler_t)
+{
+ return 1;
+}
+
diff --git a/tests/test-resource-engine/test-resource-engine.h b/tests/test-resource-engine/test-resource-engine.h
index 5484a05..5e7a79b 100644
--- a/tests/test-resource-engine/test-resource-engine.h
+++ b/tests/test-resource-engine/test-resource-engine.h
@@ -9,16 +9,16 @@ using namespace ResourcePolicy;
class TestResourceEngine: public QObject
{
Q_OBJECT
- friend resconn_t* resproto_init(resproto_role_t, resproto_transport_t, ...);
private:
ResourceEngine *resourceEngine;
- ResourceSet *resourceSet;
- Resource audioPlayback;
- Resource videoPlayback;
- Resource audioRecorder;
- Resource videoRecorder;
+ AudioResource *audioPlayback;
+ VideoResource *videoPlayback;
+ AudioRecorderResource *audioRecorder;
+ VideoRecorderResource *videoRecorder;
bool libresourceInitialized;
public:
+ ResourceSet *resourceSet;
+
TestResourceEngine();
~TestResourceEngine();
public slots:
diff --git a/tests/test-resource-engine/test-resource-engine.pro b/tests/test-resource-engine/test-resource-engine.pro
index 25e2dd9..2c0d4a7 100644
--- a/tests/test-resource-engine/test-resource-engine.pro
+++ b/tests/test-resource-engine/test-resource-engine.pro
@@ -1,19 +1,21 @@
-BASE = ../../libresourceqt
+include(../../common.pri)
TEMPLATE = app
TARGET = test-resource-engine
DESTDIR = build
-DEPENDPATH += $${BASE}/include $${BASE}/src .
-INCLUDEPATH += $${BASE}/src $${BASE}/include $${BASE}/../libresource/src
+DEPENDPATH += $${POLICY} $${LIBRESOURCEQT}/src .
+INCLUDEPATH += $${LIBRESOURCEQT}/src $${LIBRESOURCEINC} /usr/include/resource
# Input
-HEADERS += $${BASE}/include/resource.h \
- $${BASE}/include/resource-set.h \
- $${BASE}/src/resource-engine.h \
+HEADERS += $${POLICY}/resource.h \
+ $${POLICY}/resources.h \
+ $${POLICY}/resource-set.h \
+ $${LIBRESOURCEQT}/src/resource-engine.h \
test-resource-engine.h
-SOURCES += $${BASE}/src/resource.cpp \
- $${BASE}/src/resource-set.cpp \
- $${BASE}/src/resource-engine.cpp \
+SOURCES += $${LIBRESOURCEQT}/src/resource.cpp \
+ $${LIBRESOURCEQT}/src/resources.cpp \
+ $${LIBRESOURCEQT}/src/resource-set.cpp \
+ $${LIBRESOURCEQT}/src/resource-engine.cpp \
test-resource-engine.cpp
OBJECTS_DIR = build
@@ -27,3 +29,4 @@ PKGCONFIG += dbus-1
INSTALLBASE = /usr
target.path = $${INSTALLBASE}/lib/libresourceqt-tests/
INSTALLS = target
+
diff --git a/tests/test-resource-set/test-resource-set.h b/tests/test-resource-set/test-resource-set.h
index 0a3eeef..5c6498b 100644
--- a/tests/test-resource-set/test-resource-set.h
+++ b/tests/test-resource-set/test-resource-set.h
@@ -2,7 +2,7 @@
#define TEST_RESOURCE_SET_H
#include <QtTest/QTest>
-#include "resource-set.h"
+#include <policy/resource-set.h>
using namespace ResourcePolicy;
diff --git a/tests/test-resource-set/test-resource-set.pro b/tests/test-resource-set/test-resource-set.pro
index 5a9f7f6..aa3ebca 100644
--- a/tests/test-resource-set/test-resource-set.pro
+++ b/tests/test-resource-set/test-resource-set.pro
@@ -1,13 +1,14 @@
-BASE = ../../libresourceqt
+include(../../common.pri)
TEMPLATE = app
TARGET = test-resource-set
DESTDIR = build
-DEPENDPATH += $${BASE}/include $${BASE}/src .
-INCLUDEPATH += $${BASE}/src $${BASE}/include
+DEPENDPATH += $${POLICY} $${BASE}/src .
+INCLUDEPATH += $${LIBRESOURCEQT}/src $${LIBRESOURCEINC}
# Input
-HEADERS += $${BASE}/include/resources.h $${BASE}/include/resource-set.h test-resource-set.h
-SOURCES += $${BASE}/src/resource.cpp $${BASE}/src/resources.cpp $${BASE}/src/resource-set.cpp test-resource-set.cpp
+HEADERS += $${POLICY}/resources.h $${POLICY}/resource-set.h test-resource-set.h
+SOURCES += $${LIBRESOURCEQT}/src/resource.cpp $${LIBRESOURCEQT}/src/resources.cpp \
+ $${LIBRESOURCEQT}/src/resource-set.cpp test-resource-set.cpp
OBJECTS_DIR = build
MOC_DIR = build
@@ -17,5 +18,5 @@ QT -= gui
# Install directives
INSTALLBASE = /usr
-target.path = $$INSTALLBASE/lib/libresourceqt-tests/
+target.path = $${INSTALLBASE}/lib/libresourceqt-tests/
INSTALLS = target
diff --git a/tests/test-resource/test-resource.h b/tests/test-resource/test-resource.h
index fc04c47..61a48ea 100644
--- a/tests/test-resource/test-resource.h
+++ b/tests/test-resource/test-resource.h
@@ -3,7 +3,7 @@
#include <QtTest/QTest>
#include <QMetaType>
-#include "resources.h"
+#include <policy/resources.h>
Q_DECLARE_METATYPE(ResourcePolicy::ResourceType)
diff --git a/tests/test-resource/test-resource.pro b/tests/test-resource/test-resource.pro
index 6ff2f35..c6ec6ab 100644
--- a/tests/test-resource/test-resource.pro
+++ b/tests/test-resource/test-resource.pro
@@ -1,13 +1,13 @@
-BASE = ../../libresourceqt
+include(../../common.pri)
TEMPLATE = app
TARGET = test-resource
DESTDIR = build
-DEPENDPATH += $${BASE}/include $${BASE}/src .
-INCLUDEPATH += $${BASE}/src $${BASE}/include
+DEPENDPATH += $${POLICY} $${LIBRESOURCEQT}/src .
+INCLUDEPATH += $${LIBRESOURCEQT}/src $${LIBRESOURCEINC}
# Input
-HEADERS += $${BASE}/include/resource.h $${BASE}/include/resources.h test-resource.h
-SOURCES += $${BASE}/src/resource.cpp $${BASE}/src/resources.cpp test-resource.cpp
+HEADERS += $${POLICY}/resource.h $${POLICY}/resources.h test-resource.h
+SOURCES += $${LIBRESOURCEQT}/src/resource.cpp $${LIBRESOURCEQT}/src/resources.cpp test-resource.cpp
OBJECTS_DIR = build
MOC_DIR = build
@@ -17,5 +17,5 @@ QT -= gui
# Install directives
INSTALLBASE = /usr
-target.path = $$INSTALLBASE/lib/libresourceqt-tests/
+target.path = $${INSTALLBASE}/lib/libresourceqt-tests/
INSTALLS = target
diff --git a/tests/tests.pro b/tests/tests.pro
index c24c97c..1d2853f 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -8,8 +8,8 @@ TEMPLATE = subdirs
SUBDIRS = test-dbus-qeventloop \
test-dbus-pong \
test-resource \
-# test-resource-engine \
- test-resource-set
+ test-resource-set \
+ test-resource-engine
# Install options
testsxml.path = /usr/share/libresourceqt-tests/
diff --git a/tests/tests.xml b/tests/tests.xml
index 8cd4f87..579c2e9 100644
--- a/tests/tests.xml
+++ b/tests/tests.xml
@@ -10,6 +10,10 @@
<case name="test-resource-set" type="Functional" level="Component" description="Unit tests for libresourceqt" timeout="15">
<step expected_result="0">/usr/lib/libresourceqt-tests/test-resource-set</step>
</case>
+
+ <case name="test-resource-engine" type="Functional" level="Component" description="Unit tests for libresourceqt" timeout="15">
+ <step expected_result="0">/usr/lib/libresourceqt-tests/test-resource-engine</step>
+ </case>
<environments>
<scratchbox>false</scratchbox>