summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-04-27 09:42:03 +0300
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-04-27 09:42:03 +0300
commitee5ed8f33d6060c9eb041cacb54f31c2cb1da067 (patch)
treebf06a93541eed2751d34c3616e2432b88933df43 /tests
parent3a5be2e8aff1c1bdd6406904307a7b3b7a062d38 (diff)
downloadlibresourceqt-ee5ed8f33d6060c9eb041cacb54f31c2cb1da067.tar.gz
Added mutexes to make all libresourceqt usage atomic
Diffstat (limited to 'tests')
-rw-r--r--tests/test-resource-engine/test-resource-engine.cpp41
-rw-r--r--tests/test-resource-engine/test-resource-engine.h3
2 files changed, 43 insertions, 1 deletions
diff --git a/tests/test-resource-engine/test-resource-engine.cpp b/tests/test-resource-engine/test-resource-engine.cpp
index 42f1a0e..f74de51 100644
--- a/tests/test-resource-engine/test-resource-engine.cpp
+++ b/tests/test-resource-engine/test-resource-engine.cpp
@@ -4,6 +4,7 @@
using namespace ResourcePolicy;
quint32 theID = 0;
+quint32 resproto_init_calls = 0;
void statusCallbackHandler(resset_t *libresourceSet, resmsg_t *message);
static bool strverify(const char *a, const char *b);
@@ -47,11 +48,22 @@ TestResourceEngine::~TestResourceEngine()
void TestResourceEngine::init()
{
+ resproto_init_calls=0;
resourceEngine = new ResourceEngine(resourceSet);
bool initializeSucceeded = resourceEngine->initialize();
acquireOrDenyWasCalled = false;
QVERIFY(!resourceEngine->isConnectedToManager());
QVERIFY(initializeSucceeded);
+ QVERIFY(resourceSet->id() == theID);
+}
+
+void TestResourceEngine::cleanup()
+{
+ delete(resourceEngine);
+
+ QVERIFY(ResourceEngine::libresourceConnection == NULL);
+ QVERIFY(ResourceEngine::libresourceUsers == 0);
+ resproto_init_calls=0;
}
void TestResourceEngine::testConnect()
@@ -258,6 +270,27 @@ void TestResourceEngine::testRegisterAudioProperties()
QVERIFY(audioPropertiesSetSucceeded);
}
+void TestResourceEngine::testMultipleInstences()
+{
+ ResourceSet *resSet;
+ ResourceEngine *resEngine;
+ resconn_t * resConn = ResourceEngine::libresourceConnection;
+ resSet = new ResourceSet("background", this);
+ resEngine = new ResourceEngine(resSet);
+ bool initializeSucceeded = resEngine->initialize();
+ acquireOrDenyWasCalled = false;
+
+ QVERIFY(!resEngine->isConnectedToManager());
+ QVERIFY(initializeSucceeded);
+ QVERIFY(resEngine->id() != theID);
+ QVERIFY(ResourceEngine::libresourceConnection == resConn);
+ QVERIFY(ResourceEngine::libresourceUsers == 2);
+
+ delete(resEngine);
+ QVERIFY(ResourceEngine::libresourceConnection == resConn);
+ delete(resSet);
+}
+
QTEST_MAIN(TestResourceEngine)
////////////////////////////////////////////////////////////////
@@ -272,6 +305,8 @@ resconn_t* resproto_init(resproto_role_t role, resproto_transport_t transport, .
DBusConnection *dbusConnection;
va_list args;
+ resproto_init_calls += 1;
+
va_start(args, transport);
callbackFunction = va_arg(args, resconn_linkup_t);
dbusConnection = va_arg(args, DBusConnection *);
@@ -296,6 +331,8 @@ static void verify_resproto_init(resproto_role_t role,
QVERIFY(dbusConnection == sessionBus);
QVERIFY(role == RESPROTO_ROLE_CLIENT);
QVERIFY(transport == RESPROTO_TRANSPORT_DBUS);
+ qDebug("resproto_init_calls==%u", resproto_init_calls);
+ QVERIFY(resproto_init_calls==1);
}
resset_t *resconn_connect(resconn_t *connection, resmsg_t *message,
@@ -477,4 +514,6 @@ char *resmsg_dump_message(resmsg_t *resmsg,
int len)
{
char * ret = strdup("message");
-} \ No newline at end of file
+ return ret;
+}
+
diff --git a/tests/test-resource-engine/test-resource-engine.h b/tests/test-resource-engine/test-resource-engine.h
index 5398a72..ddefbea 100644
--- a/tests/test-resource-engine/test-resource-engine.h
+++ b/tests/test-resource-engine/test-resource-engine.h
@@ -34,6 +34,7 @@ public slots:
private slots:
void init();
+ void cleanup();
void testConnect();
void testDisconnect();
@@ -48,6 +49,8 @@ private slots:
void testRegisterAudioProperties_data();
void testRegisterAudioProperties();
+
+ void testMultipleInstences();
};
#endif