summaryrefslogtreecommitdiff
path: root/tests/test-resource-engine/test-resource-engine.cpp
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-02-09 12:07:31 +0200
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-02-09 12:14:46 +0200
commit381719b9a0adb8553a041633aed943f5ef48a1ff (patch)
tree6c5db8b6a7342dee77b1e1a010a6618fd824714f /tests/test-resource-engine/test-resource-engine.cpp
parent6751c585385f017d08540bbe121606d642afb220 (diff)
downloadlibresourceqt-381719b9a0adb8553a041633aed943f5ef48a1ff.tar.gz
Restructured libresourceqt includes, updated debianpackages to soversion=1.
Fixed ResourceEngine to work with the new Resource object.
Diffstat (limited to 'tests/test-resource-engine/test-resource-engine.cpp')
-rw-r--r--tests/test-resource-engine/test-resource-engine.cpp92
1 files changed, 82 insertions, 10 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;
+}
+