summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Wolf <ext-martin.2.wolf@nokia.com>2010-03-19 12:29:36 +0200
committerMartin Wolf <ext-martin.2.wolf@nokia.com>2010-03-19 12:29:36 +0200
commitcedefad1cbd0857fd1247dfb65a38f1bd0323304 (patch)
tree0cc87b46efdc11d631ddecd5bab1bddb2f3f7305
parent6eff9f8263541053b66d10960e909707ed592f62 (diff)
parent50dbb5b9aad308fe9c23db4e6db3f4b1a07dab17 (diff)
downloadlibresourceqt-cedefad1cbd0857fd1247dfb65a38f1bd0323304.tar.gz
Merge branch 'master' of ssh://mawolf@karma.research.nokia.com/u/repositories/libresourceqt
-rw-r--r--debian/changelog6
-rw-r--r--libresourceqt.pro3
-rw-r--r--libresourceqt/Doxyfile15
-rw-r--r--libresourceqt/include/qt4/policy/audio-resource.h12
-rw-r--r--libresourceqt/include/qt4/policy/resource-set.h42
-rw-r--r--libresourceqt/include/qt4/policy/resource.h33
-rw-r--r--libresourceqt/src/resource-engine.h4
-rw-r--r--resourceqt-client/client.cpp6
-rw-r--r--resourceqt-client/client.h14
-rw-r--r--tests/test-resource-engine/test-resource-engine.cpp116
-rw-r--r--tests/test-resource-engine/test-resource-engine.h22
-rw-r--r--tests/test-resource-set/test-resource-set.cpp59
-rw-r--r--tests/test-resource-set/test-resource-set.h43
13 files changed, 288 insertions, 87 deletions
diff --git a/debian/changelog b/debian/changelog
index 6d623f5..74b7496 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libresourceqt (1.1) unstable; urgency=low
+
+ * Bugfix release
+
+ -- Wolf Bergenheim <ext-wolf.2.bergenheim@nokia.com> Fri, 26 Feb 2010 09:21:57 +0200
+
libresourceqt (1.0) unstable; urgency=low
* First release
diff --git a/libresourceqt.pro b/libresourceqt.pro
index c5814e4..d032d2e 100644
--- a/libresourceqt.pro
+++ b/libresourceqt.pro
@@ -2,11 +2,10 @@
# Main projectfile
#####################################################################
-CONFIG += ordered
+CONFIG += ordered
TEMPLATE = subdirs
SUBDIRS = libdbus-qeventloop \
libresourceqt \
resourceqt-client \
tests
-
diff --git a/libresourceqt/Doxyfile b/libresourceqt/Doxyfile
index d41c553..f2c2e14 100644
--- a/libresourceqt/Doxyfile
+++ b/libresourceqt/Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME = ResourcePolicy
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 0.1
+PROJECT_NUMBER = 1.1
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
@@ -573,8 +573,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = include/resource.h \
- include/resource-set.h
+INPUT = include/qt4
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -627,7 +626,7 @@ FILE_PATTERNS = *.c \
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
-RECURSIVE = NO
+RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
@@ -923,13 +922,13 @@ GENERATE_QHP = YES
# be used to specify the file name of the resulting .qch file.
# The path specified is relative to the HTML output folder.
-QCH_FILE = ../libresourceqt.qch
+QCH_FILE = ../com.nokia.policy.libresourceqt.qch
# The QHP_NAMESPACE tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#namespace
-QHP_NAMESPACE = libresourceqt
+QHP_NAMESPACE = ResourcePolicy
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
@@ -1349,7 +1348,7 @@ PERL_PATH = /usr/bin/perl
# fallback. It is recommended to install and use dot, since it yields more
# powerful graphs.
-CLASS_DIAGRAMS = YES
+CLASS_DIAGRAMS = NO
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see
@@ -1371,7 +1370,7 @@ HIDE_UNDOC_RELATIONS = YES
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
-HAVE_DOT = NO
+HAVE_DOT = YES
# By default doxygen will write a font called FreeSans.ttf to the output
# directory and reference it in all dot files that doxygen generates. This
diff --git a/libresourceqt/include/qt4/policy/audio-resource.h b/libresourceqt/include/qt4/policy/audio-resource.h
index 99c2c7f..bb0783f 100644
--- a/libresourceqt/include/qt4/policy/audio-resource.h
+++ b/libresourceqt/include/qt4/policy/audio-resource.h
@@ -18,14 +18,26 @@ public:
QString audioGroup() const;
bool audioGroupIsSet() const;
+ /**
+ * Set the audio group (classification)
+ * \param newGroup The new audio group to set.
+ */
void setAudioGroup(const QString & newGroup);
quint32 processID() const;
+ /**
+ * Set the PID of the process which will render the audio. Use this if the
+ * audio renderer is in a separate process.
+ */
void setProcessID(quint32 newPID);
QString streamTagName() const;
QString streamTagValue() const;
bool streamTagIsSet() const;
+ /**
+ * Set the tream tag to help policy to correctly identify the audio stream
+ * beloning to you
+ */
void setStreamTag(const QString &name, const QString &value);
virtual ResourceType type() const;
diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h
index bc81b89..0d72cb7 100644
--- a/libresourceqt/include/qt4/policy/resource-set.h
+++ b/libresourceqt/include/qt4/policy/resource-set.h
@@ -24,23 +24,23 @@
* \code
* ResourcePolicy::ResourceSet *resources = new ResourcePolicy::ResourceSet("player");
* \endcode
- * Then to add resources to the set use the \ref addResource() method to add
- * resources to the \ref ResourceSet. Like this:
+ * Then to add resources to the set use the ResourceSet::addResource() method to add
+ * resources to the ResourcePolicy::ResourceSet. Like this:
* \code
* resources->addResource(AudioPlaybackType);
* resources->addResource(VideoPlaybackType);
* \endcode
* If you want to pre-populate the AudioResource with the audio group (it is a good idea)
- * and other oudio parameters you can create an audio object your self and then
- * give that to the \ref ResourceSet. Note that you should NOT free this object.
- * The \ref ResourceSet takes ownership of this pointer.
+ * and other oudio parameters you can create an audio object yourself and then
+ * give that to the ResourcePolicy::ResourceSet. Note that you should NOT free this object.
+ * The ResourcePolicy::ResourceSet takes ownership of this pointer.
* \code
- * ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("fmradio");
+ * ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("player");
* resources->addResourceObject(audioResource);
* \endcode
* Calling the ResourcePolicy::ResourceSet::deleteResource() method will remove
- * and delete the object. Then when you want to acquire the \ref ResourcePolicy::ResourceSet
- * you simply use the \ref acquire() method, like this:
+ * and delete the object. Then when you want to acquire the ResourcePolicy::ResourceSet
+ * you simply use the ResourcePolicy::ResourceSet::acquire() method, like this:
* \code
* QObject::connect(resources, SIGNAL(resourcesAcquired()),
* this, SLOT(acquireOkHandler(QList<ResourcePolicy::Resource>)));
@@ -55,7 +55,7 @@
* This signal tells you when you should stop using the resources you have asked for.
* So it is important that you connect to it.
*
- * To modify the properties of the resources you can use the \ref resource() method.
+ * To modify the properties of the resources you can use the ResourcePolicy::ResourceSet::resource() method.
*/
/**
@@ -101,8 +101,8 @@ public:
* This method adds a resource to the set. A set contains only a single
* instance of a given resource. If the ResourceSet already contains a
* resource of the given type it will be overridden.
- * \param resource The resource to add to the set. The \ref ResourseSet takes
- * ownership of the pointer. Do NOT free!
+ * \param resource The resource to add to the set.
+ * The ResourcePolicy::ResourseSet takes ownership of the pointer. Do NOT free!
*/
void addResourceObject(Resource *resource);
@@ -119,7 +119,7 @@ public:
QList<Resource *> resources() const;
/**
* This method returns a const pointer to a resource of a specific type.
- * \type The type of resource we are interested in.
+ * \param type The type of resource we are interested in.
* \return a pointer to the Resource if it is defined NULL otherwise.
*/
Resource * resource(ResourceType type) const;
@@ -159,17 +159,17 @@ public:
*/
bool release();
/**
- * Commit changes to the \ref ResourceSet. Remember to call update()
+ * Commit changes to the \ref ResourcePolicy::ResourceSet. Remember to call update()
* after adding and/or removing resources.
*/
bool update();
/**
- * Stes the auto-release. When loosing the resources doue to another
+ * Sets the auto-release. When loosing the resources due to another
* application with a higher priority the default is that we automatically
* re-gain our resources without having to re-request them. However if
* the AutoRelease is set we release the resources and need to re-acquire
- * them, when the pre-emting application releases it s resources.
+ * them, when the pre-emting application releases its resources.
*
* This feature is by default disabled.
*
@@ -177,6 +177,10 @@ public:
* and cannot be unset.
*/
bool setAutoRelease();
+ /**
+ * Check whether we have setAutoRelease().
+ * \return true if auto-release is ennabled.
+ */
bool willAutoRelease();
/**
* Sets that the resourcesGranted() signal is emited even if we already
@@ -186,6 +190,10 @@ public:
* and cannot be unset.
*/
bool setAlwaysReply();
+ /**
+ * Check whether the always-get-reply flag has been set.
+ * \return true if we will always get a reply (even if there is no change).
+ */
bool alwaysGetReply();
signals:
@@ -195,13 +203,13 @@ signals:
* \param availableResources A list of available resources. The list of
* available resources contains only available resource which we have in the set.
*/
- void resourcesBecameAvailable(const QList<ResourceType> &availableResources);
+ void resourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &availableResources);
/**
* This signal is emited as a response to the acquire() request.
* \param grantedOptionalResources The list of granted optional resources.
* All the mandatory resources have also been aquired.
*/
- void resourcesGranted(const QList<ResourceType> &grantedOptionalResources);
+ void resourcesGranted(const QList<ResourcePolicy::ResourceType> &grantedOptionalResources);
/**
* This signal is emited as a response to the acquire() request, in the
* case where one or more of the mandatroy resources were not availalble.
diff --git a/libresourceqt/include/qt4/policy/resource.h b/libresourceqt/include/qt4/policy/resource.h
index 434f3dd..4f9b02e 100644
--- a/libresourceqt/include/qt4/policy/resource.h
+++ b/libresourceqt/include/qt4/policy/resource.h
@@ -5,18 +5,23 @@
namespace ResourcePolicy
{
+/**
+ * This enumeration represents the resources which can be reserved.
+ * \see ResourcePolicy::ResourceSet::AddResource() for info on how to reserve
+ * resources.
+ */
enum ResourceType {
- AudioPlaybackType = 0,
- VideoPlaybackType,
- AudioRecorderType,
- VideoRecorderType,
- VibraType,
- LedsType,
- BacklightType,
- SystemButtonType,
- LockButtonType,
- ScaleButtonType,
- SnapButtonType,
+ AudioPlaybackType = 0, ///< For audio playback
+ VideoPlaybackType, ///< For video playback
+ AudioRecorderType, ///< For audio recording (using of the microphone)
+ VideoRecorderType, ///< For video recording (using the camera)
+ VibraType, ///< For Vibra
+ LedsType, ///< For LEDs
+ BacklightType, ///< For the backlight (of the display)
+ SystemButtonType, ///< For the system (power) button
+ LockButtonType, ///< For the lock button
+ ScaleButtonType, ///< The scale (zoom) button
+ SnapButtonType, ///< Use this if you are a camera application
LensCoverType,
NumberOfTypes
};
@@ -29,8 +34,8 @@ class ResourceSet;
*/
class Resource
{
-public:
friend class ResourceSet;
+public:
/**
* Whether or not this resource is optional, in that it doesn't need to
* be available for the set to be acquired.
@@ -51,6 +56,10 @@ public:
*/
bool isGranted() const;
+ /**
+ * Use this method to check for the type of Resource
+ * \return The ResourceType associated to this resource
+ */
virtual ResourceType type() const = 0;
virtual ~Resource();
protected:
diff --git a/libresourceqt/src/resource-engine.h b/libresourceqt/src/resource-engine.h
index 6caaef7..897c27e 100644
--- a/libresourceqt/src/resource-engine.h
+++ b/libresourceqt/src/resource-engine.h
@@ -17,8 +17,8 @@ class ResourceEngine: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( ResourceEngine )
-#ifndef QT_NO_DEBUG
- friend class TestResourceEngine;
+#ifdef TEST_RESOURCE_ENGINE_H
+ friend class ::TestResourceEngine;
#endif
public:
diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp
index 1c4ce34..968810e 100644
--- a/resourceqt-client/client.cpp
+++ b/resourceqt-client/client.cpp
@@ -7,6 +7,8 @@
#include "client.h"
+using namespace ResourcePolicy;
+
Client::Client(QString appClass) : QObject()
{
applicationClass = appClass;
@@ -157,7 +159,9 @@ bool Client::initialize(uint32_t all, uint32_t optional, bool alwaysReply, bool
updateSet(all, optional, false);
- if (!connect(resourceSet, SIGNAL(resourcesGranted(QList<ResourceType>)), this, SLOT(resourceAcquiredHandler(QList<ResourceType>)))) {
+ if (!connect(resourceSet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)),
+ this, SLOT(resourceAcquiredHandler(QList<ResourcePolicy::ResourceType>))))
+ {
return false;
}
diff --git a/resourceqt-client/client.h b/resourceqt-client/client.h
index 81461c5..ed32538 100644
--- a/resourceqt-client/client.h
+++ b/resourceqt-client/client.h
@@ -6,8 +6,6 @@
#include <policy/resource-set.h>
-using namespace ResourcePolicy;
-
#define RES_AUDIO_PLAYBACK (1<<0)
#define RES_VIDEO_PLAYBACK (1<<1)
#define RES_AUDIO_RECORDING (1<<2)
@@ -33,7 +31,7 @@ public:
static uint32_t parseResourceList(QString resourceListStr);
private slots:
- void resourceAcquiredHandler(const QList<ResourceType>& grantedResList);
+ void resourceAcquiredHandler(const QList<ResourcePolicy::ResourceType>& grantedResList);
void resourceDeniedHandler();
void resourceLostHandler();
void resourceReleasedHandler();
@@ -49,14 +47,14 @@ private:
uint32_t resourcesOptional;
QString applicationClass;
- ResourceSet* resourceSet;
+ ResourcePolicy::ResourceSet* resourceSet;
- Resource* allocateResource(ResourceType resource, bool optional);
- ResourceType getResourceType(uint32_t resource);
+ ResourcePolicy::Resource* allocateResource(ResourcePolicy::ResourceType resource, bool optional);
+ ResourcePolicy::ResourceType getResourceType(uint32_t resource);
void showPrompt();
- void showResources(const QList<ResourceType> resList);
- void showResources(const QList<Resource*> resList);
+ void showResources(const QList<ResourcePolicy::ResourceType> resList);
+ void showResources(const QList<ResourcePolicy::Resource*> resList);
void updateSet(uint32_t list, uint32_t optional, bool remove);
};
diff --git a/tests/test-resource-engine/test-resource-engine.cpp b/tests/test-resource-engine/test-resource-engine.cpp
index 804ef16..42f1a0e 100644
--- a/tests/test-resource-engine/test-resource-engine.cpp
+++ b/tests/test-resource-engine/test-resource-engine.cpp
@@ -1,10 +1,12 @@
#include "test-resource-engine.h"
#include <dbus/dbus.h>
+#include <string.h>
using namespace ResourcePolicy;
quint32 theID = 0;
void statusCallbackHandler(resset_t *libresourceSet, resmsg_t *message);
+static bool strverify(const char *a, const char *b);
static void verify_resproto_init(resproto_role_t role,
resproto_transport_t transport,
@@ -129,28 +131,28 @@ void TestResourceEngine::testAcquire()
void TestResourceEngine::handleAcquire(quint32 bitmaskOfGrantedResources)
{
- qDebug("Acquired resources: 0x%04x", bitmaskOfGrantedResources);
+ //qDebug("Acquired resources: 0x%04x", bitmaskOfGrantedResources);
QVERIFY(messageOperationShoulSucceed);
bool hasOptionalResource = false;
QList<Resource *> resourceList = resourceSet->resources();
for (int i=0; i < resourceList.size(); i++) {
quint32 bitmask = resourceTypeToLibresourceType(resourceList.at(i)->type());
- qDebug("Checking if resource %x(%x) is in the list", resourceList.at(i)->type(), bitmask);
+ //qDebug("Checking if resource %x(%x) is in the list", resourceList.at(i)->type(), bitmask);
if ((bitmask & bitmaskOfGrantedResources) == bitmask)
{
- qDebug("Yes :)");
+ //qDebug("Yes :)");
if (resourceList.at(i)->type() == optionalType) {
- qDebug("Resource is the one we are looking for. :D");
+ //qDebug("Resource is the one we are looking for. :D");
hasOptionalResource = true;
break;
}
}
else {
- qDebug("No :(");
+ //qDebug("No :(");
}
}
if ((optionalType == NumberOfTypes) && (bitmaskOfGrantedResources > 0)) {
- qDebug("Expected to get no optional resources");
+ //qDebug("Expected to get no optional resources");
hasOptionalResource = true;
}
QVERIFY(hasOptionalResource);
@@ -197,6 +199,65 @@ void TestResourceEngine::testRelease()
QVERIFY(releaseRequestSucceeded == !requestShouldFail);
}
+void TestResourceEngine::testRegisterAudioProperties_data()
+{
+ QTest::addColumn<QString>("audioGroup");
+ QTest::addColumn<quint32>("pid");
+ QTest::addColumn<QString>("streamName");
+ QTest::addColumn<QString>("streamValue");
+
+ QTest::newRow("'player':12345:'media.role':'music'") << "player" << 12345u << "media.role" << "music";
+ QTest::newRow("'':12345:'media.role':'music'") << "" << 12345u << "media.role" << "music";
+ QTest::newRow(":12345:'media.role':'music'") << QString() << 12345u << "media.role" << "music";
+ QTest::newRow("'player':0:'media.role':'music'") << "player" << 0u << "media.role" << "music";
+ QTest::newRow("'player':12345:'':'music'") << "player" << 12345u << "" << "music";
+ QTest::newRow("'player':12345::'music'") << "player" << 12345u << QString() << "music";
+ QTest::newRow("'player':12345:'':''") << "player" << 12345u << "" << "";
+ QTest::newRow("'player':12345::") << "player" << 12345u << QString() << QString();
+ QTest::newRow("'player':12345:'media.role':''") << "player" << 12345u << "media.role" << "";
+ QTest::newRow("'player':12345:'media.role':") << "player" << 12345u << "media.role" << QString();
+ QTest::newRow("'':0:'':''") << "" << 0u << "" << "";
+ QTest::newRow(":0::") << QString() << 0u << QString() << QString();
+}
+
+char *expectedGroup, *expectedStreamName, *expectedStreamValue;
+
+void TestResourceEngine::testRegisterAudioProperties()
+{
+ QFETCH(QString, audioGroup);
+ QFETCH(quint32, pid);
+ QFETCH(QString, streamName);
+ QFETCH(QString, streamValue);
+
+ requestShouldFail = false;
+
+ if(audioGroup.isEmpty() || audioGroup.isNull()) {
+ expectedGroup = NULL;
+ }
+ else {
+ QByteArray ba = audioGroup.toLatin1();
+ expectedGroup = strdup(ba.data());
+ }
+
+ if(streamName.isEmpty() || streamName.isNull() || streamValue.isEmpty() || streamValue.isNull()) {
+ expectedStreamName = NULL;
+ expectedStreamValue = NULL;
+ }
+ else {
+ QByteArray ba = streamName.toLatin1();
+ expectedStreamName = strdup(ba.data());
+ ba = streamValue.toLatin1();
+ expectedStreamValue = strdup(ba.data());
+ }
+ //qDebug() << "streamValue = " << streamValue;
+ //qDebug("expectedStreamValue = %s", expectedStreamValue);
+
+ resourceEngine->connectToManager();
+
+ bool audioPropertiesSetSucceeded = resourceEngine->registerAudioProperties(audioGroup, pid, streamName, streamValue);
+ QVERIFY(audioPropertiesSetSucceeded);
+}
+
QTEST_MAIN(TestResourceEngine)
////////////////////////////////////////////////////////////////
@@ -297,7 +358,7 @@ int resconn_disconnect(resset_t *resSet, resmsg_t *message,
static void verify_resconn_disconnect(resset_t *resourceSet, resmsg_t *message,
resproto_status_t callbackFunction)
{
- qDebug("resourceSet = %p resSet = %p", resourceSet, resSet);
+ //qDebug("resourceSet = %p resSet = %p", resourceSet, resSet);
QVERIFY(resourceSet == resSet);
QVERIFY(message->record.type == RESMSG_UNREGISTER);
QVERIFY(message->record.id == theID);
@@ -309,7 +370,7 @@ int resproto_send_message(resset_t *resourceSet, resmsg_t *message,
resproto_status_t callbackFunction)
{
resmsg_t grantMessage, statusMessage;
- qDebug("%s(): id:%u req#: %u", __FUNCTION__, message->record.id, message->record.reqno);
+ //qDebug("%s(): id:%u req#: %u", __FUNCTION__, message->record.id, message->record.reqno);
verify_resproto_send_message(resourceSet, message, callbackFunction);
@@ -348,8 +409,16 @@ int resproto_send_message(resset_t *resourceSet, resmsg_t *message,
grantMessage.record.reqno = message->record.reqno;
grantCallback(&grantMessage, resSet, resSet->userdata);
break;
+ case RESMSG_AUDIO:
+ statusMessage.type = RESMSG_STATUS;
+ statusMessage.status.errcod = 0;
+ statusMessage.status.errmsg = "";
+ statusMessage.record.id = 11;
+ statusMessage.record.reqno = 77;
+ callbackFunction(resSet, &statusMessage);
+ break;
default:
- qDebug("Unknown message requested...");
+ //qDebug("Unknown message requested...");
return 0;
}
@@ -369,16 +438,43 @@ static void verify_resproto_send_message(resset_t *resourceSet, resmsg_t *messag
QVERIFY(message->possess.id == theID);
QVERIFY(callbackFunction != NULL);
break;
+ case RESMSG_AUDIO:
+ QVERIFY(resourceSet == resSet);
+ QVERIFY(message->possess.id == theID);
+ QVERIFY(callbackFunction != NULL);
+ QVERIFY(strverify(expectedGroup, message->audio.group));
+ QVERIFY(strverify(expectedStreamName, message->audio.property.name));
+ QVERIFY(strverify(expectedStreamValue, message->audio.property.match.pattern));
+ break;
default:
bool expectedMessageType = false;
QVERIFY(expectedMessageType);
}
}
+static bool strverify(const char *a, const char *b)
+{
+ //qDebug("a='%s' b='%s'", a, b);
+ if (a == b) {
+ return true;
+ }
+ else if ((a == NULL) || (b == NULL)) {
+ return false;
+ }
+ else {
+ int i = strcmp(a, b);
+ if (i == 0)
+ return true;
+ else
+ return false;
+ }
+
+}
+
char *resmsg_dump_message(resmsg_t *resmsg,
int indent,
char *buf,
int len)
{
- return "message";
+ char * ret = strdup("message");
} \ No newline at end of file
diff --git a/tests/test-resource-engine/test-resource-engine.h b/tests/test-resource-engine/test-resource-engine.h
index dbdd755..5398a72 100644
--- a/tests/test-resource-engine/test-resource-engine.h
+++ b/tests/test-resource-engine/test-resource-engine.h
@@ -3,26 +3,27 @@
#include <QtTest/QTest>
#include <QMetaType>
+
+class TestResourceEngine;
+
#include "resource-engine.h"
Q_DECLARE_METATYPE(ResourcePolicy::ResourceType)
-namespace ResourcePolicy
-{
class TestResourceEngine: public QObject
{
Q_OBJECT
private:
- ResourceEngine *resourceEngine;
- AudioResource *audioPlayback;
- VideoResource *videoPlayback;
- AudioRecorderResource *audioRecorder;
- VideoRecorderResource *videoRecorder;
+ ResourcePolicy::ResourceEngine *resourceEngine;
+ ResourcePolicy::AudioResource *audioPlayback;
+ ResourcePolicy::VideoResource *videoPlayback;
+ ResourcePolicy::AudioRecorderResource *audioRecorder;
+ ResourcePolicy::VideoRecorderResource *videoRecorder;
bool libresourceInitialized;
bool acquireOrDenyWasCalled;
public:
- ResourceSet *resourceSet;
+ ResourcePolicy::ResourceSet *resourceSet;
TestResourceEngine();
~TestResourceEngine();
@@ -44,7 +45,10 @@ private slots:
void testRelease_data();
void testRelease();
+
+ void testRegisterAudioProperties_data();
+ void testRegisterAudioProperties();
};
-}
+
#endif
diff --git a/tests/test-resource-set/test-resource-set.cpp b/tests/test-resource-set/test-resource-set.cpp
index d9cbbce..61ea71c 100644
--- a/tests/test-resource-set/test-resource-set.cpp
+++ b/tests/test-resource-set/test-resource-set.cpp
@@ -1,5 +1,7 @@
#include "test-resource-set.h"
+using namespace ResourcePolicy;
+
Resource * TestResourceSet::resourceFromType(ResourceType type)
{
switch (type) {
@@ -125,5 +127,62 @@ void TestResourceSet::testContainsSet()
QVERIFY(containsAll);
QVERIFY(containsSubset);
}
+
+void TestResourceSet::testConnectToSignals()
+{
+ bool signalConnectionSucceeded=false;
+ signalConnectionSucceeded = QObject::connect(resourceSet,
+ SIGNAL(resourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &)),
+ this, SLOT(handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &)));
+
+ QVERIFY(signalConnectionSucceeded);
+
+ signalConnectionSucceeded = QObject::connect(resourceSet,
+ SIGNAL(resourcesGranted(const QList<ResourcePolicy::ResourceType> &)),
+ this, SLOT(handleResourcesGranted(const QList<ResourcePolicy::ResourceType> &)));
+
+ QVERIFY(signalConnectionSucceeded);
+
+ signalConnectionSucceeded = QObject::connect(resourceSet,
+ SIGNAL(resourcesDenied()),
+ this, SLOT(handleResourcesDenied()));
+
+ QVERIFY(signalConnectionSucceeded);
+
+ signalConnectionSucceeded = QObject::connect(resourceSet,
+ SIGNAL(resourcesReleased()),
+ this, SLOT(handleResourcesReleased()));
+
+ QVERIFY(signalConnectionSucceeded);
+
+ signalConnectionSucceeded = QObject::connect(resourceSet,
+ SIGNAL(lostResources()),
+ this, SLOT(handleLostResources()));
+
+ QVERIFY(signalConnectionSucceeded);
+
+}
+
+void TestResourceSet::handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &availableResources)
+{
+
+}
+void TestResourceSet::handleResourcesGranted(const QList<ResourcePolicy::ResourceType> &grantedOptionalResources)
+{
+}
+
+void TestResourceSet::handleResourcesDenied()
+{
+}
+
+void TestResourceSet::handleResourcesReleased()
+{
+}
+
+void TestResourceSet::handleLostResources()
+{
+}
+
+
QTEST_MAIN(TestResourceSet)
diff --git a/tests/test-resource-set/test-resource-set.h b/tests/test-resource-set/test-resource-set.h
index abab859..c112b6c 100644
--- a/tests/test-resource-set/test-resource-set.h
+++ b/tests/test-resource-set/test-resource-set.h
@@ -4,32 +4,37 @@
#include <QtTest/QTest>
#include <policy/resource-set.h>
-using namespace ResourcePolicy;
-
class TestResourceSet: public QObject
{
Q_OBJECT
private:
- ResourceSet *resourceSet;
-
- AudioResource *audioResource;
- AudioRecorderResource *audioRecorderResource;
- Resource *videoResource;
- Resource *videoRecorderResource;
- Resource *vibraResource;
- Resource *ledsResource;
- Resource *backlightResource;
- Resource *systemButtonResource;
- Resource *lockButtonResource;
- Resource *scaleButtonResource;
- Resource *snapButtonResource;
- Resource *lensCoverResource;
-
- Resource * resourceFromType(ResourceType type);
+ ResourcePolicy::ResourceSet *resourceSet;
+
+ ResourcePolicy::AudioResource *audioResource;
+ ResourcePolicy::AudioRecorderResource *audioRecorderResource;
+ ResourcePolicy::Resource *videoResource;
+ ResourcePolicy::Resource *videoRecorderResource;
+ ResourcePolicy::Resource *vibraResource;
+ ResourcePolicy::Resource *ledsResource;
+ ResourcePolicy::Resource *backlightResource;
+ ResourcePolicy::Resource *systemButtonResource;
+ ResourcePolicy::Resource *lockButtonResource;
+ ResourcePolicy::Resource *scaleButtonResource;
+ ResourcePolicy::Resource *snapButtonResource;
+ ResourcePolicy::Resource *lensCoverResource;
+
+ ResourcePolicy::Resource * resourceFromType(ResourcePolicy::ResourceType type);
public:
TestResourceSet();
~TestResourceSet();
+public slots:
+
+ void handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &availableResources);
+ void handleResourcesGranted(const QList<ResourcePolicy::ResourceType> &grantedOptionalResources);
+ void handleResourcesDenied();
+ void handleResourcesReleased();
+ void handleLostResources();
private slots:
@@ -43,6 +48,8 @@ private slots:
void testDelResource();
void testContainsSet();
+
+ void testConnectToSignals();
};
#endif