aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarja Hassinen <ext-marja.2.hassinen@nokia.com>2009-09-09 17:10:34 +0300
committerMarja Hassinen <ext-marja.2.hassinen@nokia.com>2009-09-09 17:10:34 +0300
commit2f23cb54a9cba3285af11ee106e308a77f13d1b1 (patch)
treef890ead78767b9c7c3dda9141d7fe9d6f4a34a56
parent6b222da65f2250d19d07dae3f1ca909ae6c33554 (diff)
parente2eba1fd55240ffd91e81496098d348055a11725 (diff)
Merge branch 'subscriber-plugins' into bluez-plugin
Conflicts: libcontextsubscriber/src/Makefile.am
-rw-r--r--libcontextsubscriber/customer-tests/bluez-plugin/testbluezplugin.cpp2
-rwxr-xr-xlibcontextsubscriber/customer-tests/commander/commander_nonexistent.py2
-rw-r--r--libcontextsubscriber/plugins/bluez/bluezplugin.h2
-rw-r--r--libcontextsubscriber/src/Makefile.am5
-rw-r--r--libcontextsubscriber/src/contextkitplugin.h1
-rw-r--r--libcontextsubscriber/src/iproviderplugin.h46
-rw-r--r--libcontextsubscriber/src/propertyhandle.cpp1
-rw-r--r--libcontextsubscriber/src/provider.cpp2
-rw-r--r--libcontextsubscriber/src/provider.h20
-rw-r--r--libcontextsubscriber/unit-tests/handlesignalrouter/propertyhandle.h2
-rw-r--r--libcontextsubscriber/unit-tests/handlesignalrouter/testhandlesignalrouter.cpp20
-rw-r--r--libcontextsubscriber/unit-tests/propertyhandle/Makefile.am2
-rw-r--r--libcontextsubscriber/unit-tests/propertyhandle/contextpropertyinfo.h4
-rw-r--r--libcontextsubscriber/unit-tests/propertyhandle/provider.h (renamed from libcontextsubscriber/unit-tests/propertyhandle/propertyprovider.h)19
-rw-r--r--libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp252
-rw-r--r--libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.h1
16 files changed, 215 insertions, 166 deletions
diff --git a/libcontextsubscriber/customer-tests/bluez-plugin/testbluezplugin.cpp b/libcontextsubscriber/customer-tests/bluez-plugin/testbluezplugin.cpp
index e51efaad..2bbe0cd5 100644
--- a/libcontextsubscriber/customer-tests/bluez-plugin/testbluezplugin.cpp
+++ b/libcontextsubscriber/customer-tests/bluez-plugin/testbluezplugin.cpp
@@ -23,7 +23,7 @@
#include "testbluezplugin.h"
// Plugin interface definition
-#include "provider.h" // FIXME: change header file name
+#include "iproviderplugin.h"
#include <QtTest/QtTest>
#include <QLibrary>
diff --git a/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py b/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py
index 08242d3d..461e5e6e 100755
--- a/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py
+++ b/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py
@@ -86,7 +86,7 @@ class CommanderNonExistent(unittest.TestCase):
def testCommanderFunctionality(self):
line = self.context_client.stderr.readline().rstrip()
- while not 'Provider error, bad type for test.int wanted: INT got: QString' in line:
+ while not 'Provider error, bad type for "test.int" wanted: "INT" got: QString' in line:
line = self.context_client.stderr.readline().rstrip()
# if we are here, then the type check worked
diff --git a/libcontextsubscriber/plugins/bluez/bluezplugin.h b/libcontextsubscriber/plugins/bluez/bluezplugin.h
index 2c7699fd..b1311492 100644
--- a/libcontextsubscriber/plugins/bluez/bluezplugin.h
+++ b/libcontextsubscriber/plugins/bluez/bluezplugin.h
@@ -23,7 +23,7 @@
#define BLUEZPLUGIN_H
#include "bluezinterface.h"
-#include "provider.h" // For IProviderPlugin definition
+#include "iproviderplugin.h" // For IProviderPlugin definition
using ContextSubscriber::IProviderPlugin;
diff --git a/libcontextsubscriber/src/Makefile.am b/libcontextsubscriber/src/Makefile.am
index 0632b13e..4f8a5a20 100644
--- a/libcontextsubscriber/src/Makefile.am
+++ b/libcontextsubscriber/src/Makefile.am
@@ -12,7 +12,8 @@ libcontextsubscriber_la_SOURCES = contextproperty.cpp \
infocdbbackend.cpp infocdbbackend.h dbusnamelistener.h \
dbusnamelistener.cpp handlesignalrouter.cpp \
handlesignalrouter.h queuedinvoker.cpp queuedinvoker.h \
- loggingfeatures.h contextkitplugin.h contextkitplugin.cpp
+ loggingfeatures.h contextkitplugin.h contextkitplugin.cpp \
+ iproviderplugin.h
includecontextsubscriberdir=$(includedir)/contextsubscriber
includecontextsubscriber_HEADERS = contextproperty.h contextpropertyinfo.h contextregistryinfo.h
@@ -26,7 +27,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/common \
$(top_builddir)/common/libcommon.la:
$(MAKE) -C $(top_builddir)/common libcommon.la
-LIBS += $(CDB_LIBS) $(QtCore_LIBS) $(QtXml_LIBS) $(QtDBus_LIBS)
+LIBS += $(CDB_LIBS) $(QtCore_LIBS) $(QtXml_LIBS) $(QtDBus_LIBS)
libcontextsubscriber_la_LIBADD=$(top_builddir)/common/libcommon.la
.PHONY: $(top_builddir)/common/libcommon.la
diff --git a/libcontextsubscriber/src/contextkitplugin.h b/libcontextsubscriber/src/contextkitplugin.h
index a0d74888..25d09d58 100644
--- a/libcontextsubscriber/src/contextkitplugin.h
+++ b/libcontextsubscriber/src/contextkitplugin.h
@@ -29,6 +29,7 @@
#include <QMap>
#include "dbusnamelistener.h"
#include "provider.h"
+#include "iproviderplugin.h"
extern "C" {
ContextSubscriber::IProviderPlugin* contextKitPluginFactory(QString constructionString);
diff --git a/libcontextsubscriber/src/iproviderplugin.h b/libcontextsubscriber/src/iproviderplugin.h
new file mode 100644
index 00000000..1f025aa6
--- /dev/null
+++ b/libcontextsubscriber/src/iproviderplugin.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008, 2009 Nokia Corporation.
+ *
+ * Contact: Marius Vollmer <marius.vollmer@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef IPROVIDERPLUGIN_H
+#define IPROVIDERPLUGIN_H
+
+#include <QObject>
+
+namespace ContextSubscriber {
+
+class IProviderPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ virtual void subscribe(QSet<QString> keys) = 0;
+ virtual void unsubscribe(QSet<QString> keys) = 0;
+
+signals:
+ void ready();
+ void failed(QString error);
+ void subscribeFinished(QString key);
+ void subscribeFailed(QString failedKey, QString error);
+ void valueChanged(QString key, QVariant value);
+};
+
+}
+
+#endif
diff --git a/libcontextsubscriber/src/propertyhandle.cpp b/libcontextsubscriber/src/propertyhandle.cpp
index 777ac8ed..f1592659 100644
--- a/libcontextsubscriber/src/propertyhandle.cpp
+++ b/libcontextsubscriber/src/propertyhandle.cpp
@@ -135,7 +135,6 @@ void PropertyHandle::updateProvider()
} else {
// The myInfo object doesn't have to be re-created, because it
// just routes the function calls to a registry backend.
- QString dbusName = myInfo->providerDBusName();
if (myInfo->exists()) {
// If myInfo knows the current provider which should be
diff --git a/libcontextsubscriber/src/provider.cpp b/libcontextsubscriber/src/provider.cpp
index 0c8a61db..a968f08a 100644
--- a/libcontextsubscriber/src/provider.cpp
+++ b/libcontextsubscriber/src/provider.cpp
@@ -20,6 +20,7 @@
*/
#include "provider.h"
+#include "iproviderplugin.h"
#include "handlesignalrouter.h"
#include "sconnect.h"
#include "contextkitplugin.h"
@@ -142,7 +143,6 @@ void Provider::constructPlugin()
/// the keys that should be subscribed.
void Provider::onPluginReady()
{
- // FIXME: try this out :)
contextDebug();
QMutexLocker lock(&subscribeLock);
diff --git a/libcontextsubscriber/src/provider.h b/libcontextsubscriber/src/provider.h
index a8767b3b..28b18675 100644
--- a/libcontextsubscriber/src/provider.h
+++ b/libcontextsubscriber/src/provider.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef PROPERTYPROVIDER_H
-#define PROPERTYPROVIDER_H
+#ifndef PROVIDER_H
+#define PROVIDER_H
#include "queuedinvoker.h"
@@ -37,21 +37,7 @@ class PropertyHandle;
class SubscriberInterface;
class DBusNameListener;
class ManagerInterface;
-
-class IProviderPlugin : public QObject
-{
- Q_OBJECT
-public:
- virtual void subscribe(QSet<QString> keys) = 0;
- virtual void unsubscribe(QSet<QString> keys) = 0;
-
-signals:
- void ready();
- void failed(QString error);
- void subscribeFinished(QString key);
- void subscribeFailed(QString failedKey, QString error);
- void valueChanged(QString key, QVariant value);
-};
+class IProviderPlugin;
class Provider : public QueuedInvoker
{
diff --git a/libcontextsubscriber/unit-tests/handlesignalrouter/propertyhandle.h b/libcontextsubscriber/unit-tests/handlesignalrouter/propertyhandle.h
index 3de789dc..8b7be5b3 100644
--- a/libcontextsubscriber/unit-tests/handlesignalrouter/propertyhandle.h
+++ b/libcontextsubscriber/unit-tests/handlesignalrouter/propertyhandle.h
@@ -38,10 +38,12 @@ class PropertyHandle : public QObject
public:
static PropertyHandle* instance(const QString& key);
void setValue(QVariant newValue);
+ void setSubscribeFinished();
// For tests
signals:
void setValueCalled(QString, QVariant);
+ void setSubscribeFinishedCalled(QString);
public:
PropertyHandle(const QString& key);
diff --git a/libcontextsubscriber/unit-tests/handlesignalrouter/testhandlesignalrouter.cpp b/libcontextsubscriber/unit-tests/handlesignalrouter/testhandlesignalrouter.cpp
index 4328d5e1..371f810b 100644
--- a/libcontextsubscriber/unit-tests/handlesignalrouter/testhandlesignalrouter.cpp
+++ b/libcontextsubscriber/unit-tests/handlesignalrouter/testhandlesignalrouter.cpp
@@ -78,6 +78,11 @@ void PropertyHandle::setValue(QVariant value)
emit setValueCalled(myKey, value);
}
+void PropertyHandle::setSubscribeFinished()
+{
+ emit setSubscribeFinishedCalled(myKey);
+}
+
PropertyHandle* PropertyHandle::instance(const QString& key)
{
if (key == "Property.One") {
@@ -140,10 +145,14 @@ void HandleSignalRouterUnitTests::routingSignals()
QSignalSpy spy1(mockHandleOne, SIGNAL(setValueCalled(QString, QVariant)));
QSignalSpy spy2(mockHandleTwo, SIGNAL(setValueCalled(QString, QVariant)));
QSignalSpy spy3(mockHandleThree, SIGNAL(setValueCalled(QString, QVariant)));
+ QSignalSpy sspy1(mockHandleOne, SIGNAL(setSubscribeFinishedCalled(QString)));
+ QSignalSpy sspy2(mockHandleTwo, SIGNAL(setSubscribeFinishedCalled(QString)));
+ QSignalSpy sspy3(mockHandleThree, SIGNAL(setSubscribeFinishedCalled(QString)));
// Test:
// Send a signal to the HandleSignalRouter
handleSignalRouter->onValueChanged("Property.One", QVariant(4.3));
+ handleSignalRouter->onSubscribeFinished("Property.One");
// Expected results:
// The mockHandleOne.setValue was called
@@ -151,23 +160,34 @@ void HandleSignalRouterUnitTests::routingSignals()
QList<QVariant> parameters = spy1.takeFirst();
QCOMPARE(parameters.at(0), QVariant("Property.One"));
QCOMPARE(parameters.at(1).value<QVariant >(), QVariant(4.3));
+ QCOMPARE(sspy1.count(), 1);
+ parameters = sspy1.takeFirst();
+ QCOMPARE(parameters.at(0), QVariant("Property.One"));
// The setValue of other mock handles were not called
QCOMPARE(spy2.count(), 0);
QCOMPARE(spy3.count(), 0);
+ QCOMPARE(sspy2.count(), 0);
+ QCOMPARE(sspy3.count(), 0);
// Test:
// Send a signal to the HandleSignalRouter
handleSignalRouter->onValueChanged("Property.Two", QVariant("value"));
+ handleSignalRouter->onSubscribeFinished("Property.Two");
// Expected results:
// The mockHandleTwo.setValue was called
QCOMPARE(spy2.count(), 1);
+ QCOMPARE(sspy2.count(), 1);
parameters = spy2.takeFirst();
QCOMPARE(parameters.at(0), QVariant("Property.Two"));
QCOMPARE(parameters.at(1).value<QVariant >(), QVariant("value"));
+ parameters = sspy2.takeFirst();
+ QCOMPARE(parameters.at(0), QVariant("Property.Two"));
// The setValue of other mock handles were not called
QCOMPARE(spy1.count(), 0);
QCOMPARE(spy3.count(), 0);
+ QCOMPARE(sspy1.count(), 0);
+ QCOMPARE(sspy3.count(), 0);
}
diff --git a/libcontextsubscriber/unit-tests/propertyhandle/Makefile.am b/libcontextsubscriber/unit-tests/propertyhandle/Makefile.am
index c6efe95a..3fa452e2 100644
--- a/libcontextsubscriber/unit-tests/propertyhandle/Makefile.am
+++ b/libcontextsubscriber/unit-tests/propertyhandle/Makefile.am
@@ -2,7 +2,7 @@ check_PROGRAMS = propertyhandle-unit-tests
# your test's sources
propertyhandle_unit_tests_SOURCES = testpropertyhandle.cpp \
- testpropertyhandle.h propertyprovider.h dbusnamelistener.h \
+ testpropertyhandle.h provider.h dbusnamelistener.h \
contextpropertyinfo.h contextregistryinfo.h
# only include these files in the coverage
diff --git a/libcontextsubscriber/unit-tests/propertyhandle/contextpropertyinfo.h b/libcontextsubscriber/unit-tests/propertyhandle/contextpropertyinfo.h
index ec0caf58..a53f6d46 100644
--- a/libcontextsubscriber/unit-tests/propertyhandle/contextpropertyinfo.h
+++ b/libcontextsubscriber/unit-tests/propertyhandle/contextpropertyinfo.h
@@ -38,6 +38,10 @@ public:
QString type() const;
+ bool exists() const;
+ QString plugin() const;
+ QString constructionString() const;
+
QString providerDBusName() const;
QDBusConnection::BusType providerDBusType() const;
diff --git a/libcontextsubscriber/unit-tests/propertyhandle/propertyprovider.h b/libcontextsubscriber/unit-tests/propertyhandle/provider.h
index eff2954b..ab6ec6c7 100644
--- a/libcontextsubscriber/unit-tests/propertyhandle/propertyprovider.h
+++ b/libcontextsubscriber/unit-tests/propertyhandle/provider.h
@@ -21,8 +21,8 @@
// This is a mock implementation
-#ifndef PROPERTYPROVIDER_H
-#define PROPERTYPROVIDER_H
+#ifndef PROVIDER_H
+#define PROVIDER_H
#include <QObject>
#include <QDBusConnection>
@@ -31,23 +31,24 @@
namespace ContextSubscriber {
-class PropertyProvider : public QObject
+class Provider : public QObject
{
Q_OBJECT
public:
+ static Provider* instance(const QString &plugin, const QString& constructionString);
bool subscribe(const QString &key);
void unsubscribe(const QString &key);
- static PropertyProvider* instance(const QDBusConnection::BusType busType, const QString& busName);
signals:
- void subscribeFinished(QSet<QString> keys);
- void valueChanged(QString key, QVariant value, bool processingSubscription);
+ void subscribeFinished(QString key);
+ void valueChanged(QString key, QVariant value);
+
public:
// Logging
static int instanceCount;
- static QList<QDBusConnection::BusType> instanceDBusTypes;
- static QStringList instanceDBusNames;
+ static QStringList instancePluginNames;
+ static QStringList instancePluginConstructionStrings;
// Log the subscribe calls
static int subscribeCount; // count
static QStringList subscribeKeys; // parameters
@@ -60,7 +61,7 @@ public:
// on which it was called
// For tests
- PropertyProvider(QString name); // public only in tests
+ Provider(QString name); // public only in tests
static void resetLogs();
QString myName;
diff --git a/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp b/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp
index ce21c946..8c8f4c57 100644
--- a/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp
+++ b/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp
@@ -23,7 +23,7 @@
#include "testpropertyhandle.h"
// Mock header files
-#include "propertyprovider.h"
+#include "provider.h"
#include "dbusnamelistener.h"
#include "contextpropertyinfo.h"
#include "contextregistryinfo.h"
@@ -41,7 +41,7 @@ ContextPropertyInfo* mockContextPropertyInfo;
// Mock implementation of ContextPropertyInfo
ContextPropertyInfo::ContextPropertyInfo(const QString &key, QObject *parent)
- : myType("")
+ : myType("faketype")
{
// Store the object created by the class to be tested
mockContextPropertyInfo = this;
@@ -52,14 +52,19 @@ QString ContextPropertyInfo::type() const
return myType;
}
-QString ContextPropertyInfo::providerDBusName() const
+bool ContextPropertyInfo::exists() const
{
- return "Fake.Provider";
+ return myType != "";
}
-QDBusConnection::BusType ContextPropertyInfo::providerDBusType() const
+QString ContextPropertyInfo::plugin() const
{
- return QDBusConnection::SessionBus;
+ return "fakeplugin";
+}
+
+QString ContextPropertyInfo::constructionString() const
+{
+ return "fakeconstructionstring";
}
// Mock implementation of the ContextRegistryInfo
@@ -96,39 +101,39 @@ void myMessageOutput(QtMsgType type, const char *msg)
// Mock instances
// These will be created by the test program
-PropertyProvider* mockPropertyProvider;
-PropertyProvider* mockCommanderProvider;
+Provider* mockProvider;
+Provider* mockCommanderProvider;
DBusNameListener* mockDBusNameListener;
-// Mock implementation of the PropertyProvider
-int PropertyProvider::instanceCount = 0;
-QList<QDBusConnection::BusType> PropertyProvider::instanceDBusTypes;
-QStringList PropertyProvider::instanceDBusNames;
-int PropertyProvider::subscribeCount = 0;
-QStringList PropertyProvider::subscribeKeys;
-QStringList PropertyProvider::subscribeProviderNames;
+// Mock implementation of the Provider
+int Provider::instanceCount = 0;
+QStringList Provider::instancePluginNames;
+QStringList Provider::instancePluginConstructionStrings;
+int Provider::subscribeCount = 0;
+QStringList Provider::subscribeKeys;
+QStringList Provider::subscribeProviderNames;
-int PropertyProvider::unsubscribeCount = 0;
-QStringList PropertyProvider::unsubscribeKeys;
-QStringList PropertyProvider::unsubscribeProviderNames;
+int Provider::unsubscribeCount = 0;
+QStringList Provider::unsubscribeKeys;
+QStringList Provider::unsubscribeProviderNames;
-PropertyProvider* PropertyProvider::instance(const QDBusConnection::BusType busType, const QString &busName)
+Provider* Provider::instance(const QString &plugin, const QString& constructionString)
{
++ instanceCount;
- instanceDBusTypes << busType;
- instanceDBusNames << busName;
- if (busName.contains("Commander")) {
+ instancePluginNames << plugin;
+ instancePluginConstructionStrings << constructionString;
+ if (constructionString.contains("Commander")) {
return mockCommanderProvider;
}
- return mockPropertyProvider;
+ return mockProvider;
}
-PropertyProvider::PropertyProvider(QString name)
+Provider::Provider(QString name)
: myName(name)
{
}
-bool PropertyProvider::subscribe(const QString& key)
+bool Provider::subscribe(const QString& key)
{
qDebug() << "subscribe" << key << myName;
++subscribeCount;
@@ -137,7 +142,7 @@ bool PropertyProvider::subscribe(const QString& key)
return true;
}
-void PropertyProvider::unsubscribe(const QString& key)
+void Provider::unsubscribe(const QString& key)
{
qDebug() << "unsubscribe" << key << myName;
++unsubscribeCount;
@@ -145,11 +150,11 @@ void PropertyProvider::unsubscribe(const QString& key)
unsubscribeProviderNames << myName;
}
-void PropertyProvider::resetLogs()
+void Provider::resetLogs()
{
instanceCount = 0;
- instanceDBusTypes.clear();
- instanceDBusNames.clear();
+ instancePluginConstructionStrings.clear();
+ instancePluginNames.clear();
subscribeCount = 0;
subscribeKeys.clear();
subscribeProviderNames.clear();
@@ -201,11 +206,11 @@ void PropertyHandleUnitTests::cleanupTestCase()
void PropertyHandleUnitTests::init()
{
// Create the mock instances
- mockPropertyProvider = new PropertyProvider("NormalProvider");
- mockCommanderProvider = new PropertyProvider("Commander");
+ mockProvider = new Provider("NormalProvider");
+ mockCommanderProvider = new Provider("Commander");
mockContextRegistryInfo = new ContextRegistryInfo();
// Reset the logs
- PropertyProvider::resetLogs();
+ Provider::resetLogs();
// Reset the DBusNameListener (it is created only once, by the class to be tested)
mockDBusNameListener->servicePresent = DBusNameListener::NotPresent;
}
@@ -213,8 +218,8 @@ void PropertyHandleUnitTests::init()
// After each test
void PropertyHandleUnitTests::cleanup()
{
- delete mockPropertyProvider;
- mockPropertyProvider = 0;
+ delete mockProvider;
+ mockProvider = 0;
delete mockCommanderProvider;
mockCommanderProvider = 0;
delete mockContextRegistryInfo;
@@ -237,10 +242,10 @@ void PropertyHandleUnitTests::initializing()
propertyHandle = PropertyHandle::instance(key);
// Expected results:
- // The PropertyProvider with the correct DBusName and DBusType was created.
- QCOMPARE(PropertyProvider::instanceCount, 1);
- QCOMPARE(PropertyProvider::instanceDBusTypes.at(0), QDBusConnection::SessionBus);
- QCOMPARE(PropertyProvider::instanceDBusNames.at(0), QString("Fake.Provider"));
+ // The Provider with the correct DBusName and DBusType was created.
+ QCOMPARE(Provider::instanceCount, 1);
+ QCOMPARE(Provider::instancePluginNames.at(0), QString("fakeplugin"));
+ QCOMPARE(Provider::instancePluginConstructionStrings.at(0), QString("fakeconstructionstring"));
}
void PropertyHandleUnitTests::key()
@@ -285,10 +290,10 @@ void PropertyHandleUnitTests::subscribe()
propertyHandle->subscribe();
// Expected results:
- // The PropertyHandle calls the PropertyProvider::subscribe
- QCOMPARE(PropertyProvider::subscribeCount, 1);
- QCOMPARE(PropertyProvider::subscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::unsubscribeCount, 0);
+ // The PropertyHandle calls the Provider::subscribe
+ QCOMPARE(Provider::subscribeCount, 1);
+ QCOMPARE(Provider::subscribeKeys.at(0), key);
+ QCOMPARE(Provider::unsubscribeCount, 0);
}
void PropertyHandleUnitTests::subscribeAndUnsubscribe()
@@ -307,11 +312,11 @@ void PropertyHandleUnitTests::subscribeAndUnsubscribe()
propertyHandle->unsubscribe();
// Expected results:
- // The PropertyHandle calls the PropertyProvider::unsubscribe
- QCOMPARE(PropertyProvider::subscribeCount, 1);
- QCOMPARE(PropertyProvider::subscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::unsubscribeCount, 1);
- QCOMPARE(PropertyProvider::unsubscribeKeys.at(0), key);
+ // The PropertyHandle calls the Provider::unsubscribe
+ QCOMPARE(Provider::subscribeCount, 1);
+ QCOMPARE(Provider::subscribeKeys.at(0), key);
+ QCOMPARE(Provider::unsubscribeCount, 1);
+ QCOMPARE(Provider::unsubscribeKeys.at(0), key);
}
void PropertyHandleUnitTests::subscribeTwice()
@@ -330,11 +335,11 @@ void PropertyHandleUnitTests::subscribeTwice()
propertyHandle->subscribe();
// Expected results:
- // The PropertyHandle calls the PropertyProvider::subscribe
+ // The PropertyHandle calls the Provider::subscribe
// but only once.
- QCOMPARE(PropertyProvider::subscribeCount, 1);
- QCOMPARE(PropertyProvider::subscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::unsubscribeCount, 0);
+ QCOMPARE(Provider::subscribeCount, 1);
+ QCOMPARE(Provider::subscribeKeys.at(0), key);
+ QCOMPARE(Provider::unsubscribeCount, 0);
}
void PropertyHandleUnitTests::subscriptionPendingAndFinished()
@@ -354,23 +359,8 @@ void PropertyHandleUnitTests::subscriptionPendingAndFinished()
// The subscription is marked as pending
QVERIFY(propertyHandle->isSubscribePending());
- // Test:
- // Command the PropertyProvider to emit the subscriptionFinished signal
- // without the relevant key
- QSet<QString> toEmit1;
- toEmit1.insert("Non.Relevant.Key");
- emit mockPropertyProvider->subscribeFinished(toEmit1);
-
- // Expected results:
- // The subscription is still marked as pending
- QVERIFY(propertyHandle->isSubscribePending());
-
- // Test:
- // Command the PropertyProvider to emit the subscriptionFinished signal
- // with the relevant key
- QSet<QString> toEmit2;
- toEmit2.insert(key);
- emit mockPropertyProvider->subscribeFinished(toEmit2);
+ // finished
+ propertyHandle->setSubscribeFinished();
// Expected results:
// The subscription is no longer marked as pending
@@ -395,12 +385,12 @@ void PropertyHandleUnitTests::subscribeTwiceAndUnsubscribe()
propertyHandle->unsubscribe();
// Expected results:
- // The PropertyHandle calls the PropertyProvider::subscribe
+ // The PropertyHandle calls the Provider::subscribe
// but only once. The unsubscribe is not called, since one of the
// subscriptions is still valid.
- QCOMPARE(PropertyProvider::subscribeCount, 1);
- QCOMPARE(PropertyProvider::subscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::unsubscribeCount, 0);
+ QCOMPARE(Provider::subscribeCount, 1);
+ QCOMPARE(Provider::subscribeKeys.at(0), key);
+ QCOMPARE(Provider::unsubscribeCount, 0);
}
void PropertyHandleUnitTests::subscribeTwiceAndUnsubscribeTwice()
@@ -423,12 +413,12 @@ void PropertyHandleUnitTests::subscribeTwiceAndUnsubscribeTwice()
propertyHandle->unsubscribe();
// Expected results:
- // The PropertyHandle calls the PropertyProvider::subscribe
+ // The PropertyHandle calls the Provider::subscribe
// but only once. Also the unsubscription is called once.
- QCOMPARE(PropertyProvider::subscribeCount, 1);
- QCOMPARE(PropertyProvider::subscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::unsubscribeCount, 1);
- QCOMPARE(PropertyProvider::unsubscribeKeys.at(0), key);
+ QCOMPARE(Provider::subscribeCount, 1);
+ QCOMPARE(Provider::subscribeKeys.at(0), key);
+ QCOMPARE(Provider::unsubscribeCount, 1);
+ QCOMPARE(Provider::unsubscribeKeys.at(0), key);
}
void PropertyHandleUnitTests::setValueWithoutTypeCheck()
@@ -447,7 +437,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a double
- propertyHandle->setValue(QVariant(1.4), true);
+ propertyHandle->setValue(QVariant(1.4));
// Expected results:
// The valueChanged signal was emitted
@@ -458,7 +448,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
// Test:
spy.clear();
// Command the PropertyHandle to set its value to the same value it already has
- propertyHandle->setValue(QVariant(1.4), true);
+ propertyHandle->setValue(QVariant(1.4));
// Expected results:
// The valueChanged signal is not emitted
@@ -468,7 +458,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is an integer
- propertyHandle->setValue(QVariant(-8), true);
+ propertyHandle->setValue(QVariant(-8));
// Expected results:
// The valueChanged signal was emitted
@@ -480,7 +470,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
// Test:
spy.clear();
// Command the PropertyHandle to set its value to the same value it already has
- propertyHandle->setValue(QVariant(-8), true);
+ propertyHandle->setValue(QVariant(-8));
// Expected results:
// The valueChanged signal is not emitted
@@ -490,7 +480,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a string
- propertyHandle->setValue(QVariant("myValue"), true);
+ propertyHandle->setValue(QVariant("myValue"));
// Expected results:
// The valueChanged signal was emitted
@@ -502,7 +492,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
// Test:
spy.clear();
// Command the PropertyHandle to set its value to the same value it already has
- propertyHandle->setValue(QVariant("myValue"), true);
+ propertyHandle->setValue(QVariant("myValue"));
// Expected results:
// The valueChanged signal is not emitted
@@ -512,7 +502,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a boolean
- propertyHandle->setValue(QVariant(true), true);
+ propertyHandle->setValue(QVariant(true));
// Expected results:
// The valueChanged signal was emitted
@@ -524,7 +514,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
// Test:
spy.clear();
// Command the PropertyHandle to set its value to the same value it already has
- propertyHandle->setValue(QVariant(true), true);
+ propertyHandle->setValue(QVariant(true));
// Expected results:
// The valueChanged signal is not emitted
@@ -534,7 +524,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a null
- propertyHandle->setValue(QVariant(), true);
+ propertyHandle->setValue(QVariant());
// Expected results:
// The valueChanged signal was emitted
@@ -546,7 +536,7 @@ void PropertyHandleUnitTests::setValueWithoutTypeCheck()
// Test:
spy.clear();
// Command the PropertyHandle to set its value to the same value it already has
- propertyHandle->setValue(QVariant(), true);
+ propertyHandle->setValue(QVariant());
// Expected results:
// The valueChanged signal is not emitted
@@ -577,7 +567,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
// Test:
// Command the PropertyHandle to change its value
// The new value is a double
- propertyHandle->setValue(QVariant(1.4), true);
+ propertyHandle->setValue(QVariant(1.4));
// Expected results:
// The valueChanged signal was emitted
@@ -589,7 +579,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a null
- propertyHandle->setValue(QVariant(), true);
+ propertyHandle->setValue(QVariant());
// Expected results:
// The NULL value is always accepcted (not depending on the type)
@@ -607,7 +597,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
// Test:
// Command the PropertyHandle to change its value
// The new value is an integer
- propertyHandle->setValue(QVariant(-8), true);
+ propertyHandle->setValue(QVariant(-8));
// Expected results:
// The valueChanged signal was emitted
@@ -620,7 +610,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a null
- propertyHandle->setValue(QVariant(), true);
+ propertyHandle->setValue(QVariant());
// Expected results:
// The NULL value is always accepcted (not depending on the type)
@@ -638,7 +628,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
// Test:
// Command the PropertyHandle to change its value
// The new value is a string
- propertyHandle->setValue(QVariant("myValue"), true);
+ propertyHandle->setValue(QVariant("myValue"));
// Expected results:
// The valueChanged signal was emitted
@@ -651,7 +641,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a null
- propertyHandle->setValue(QVariant(), true);
+ propertyHandle->setValue(QVariant());
// Expected results:
// The NULL value is always accepcted (not depending on the type)
@@ -669,7 +659,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
// Test:
// Command the PropertyHandle to change its value
// The new value is a boolean
- propertyHandle->setValue(QVariant(true), true);
+ propertyHandle->setValue(QVariant(true));
// Expected results:
// The valueChanged signal was emitted
@@ -682,7 +672,7 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndCorrectTypes()
spy.clear();
// Command the PropertyHandle to change its value
// The new value is a null
- propertyHandle->setValue(QVariant(), true);
+ propertyHandle->setValue(QVariant());
// Expected results:
// The NULL value is always accepcted (not depending on the type)
@@ -713,15 +703,15 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndIncorrectTypes()
// Set the type to DOUBLE
mockContextPropertyInfo->myType = "DOUBLE";
// Set an initial value
- propertyHandle->setValue(QVariant(4.2), true);
+ propertyHandle->setValue(QVariant(4.2));
spy.clear();
// Test:
// Command the PropertyHandle to change its value multiple times but with
// incorrect types.
- propertyHandle->setValue(QVariant(5), true);
- propertyHandle->setValue(QVariant("string"), true);
- propertyHandle->setValue(QVariant(false), true);
+ propertyHandle->setValue(QVariant(5));
+ propertyHandle->setValue(QVariant("string"));
+ propertyHandle->setValue(QVariant(false));
// Expected results:
// The valueChanged signal was not emitted
@@ -733,15 +723,15 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndIncorrectTypes()
// Set the type to INT
mockContextPropertyInfo->myType = "INT";
// Set an initial value
- propertyHandle->setValue(QVariant(22), true);
+ propertyHandle->setValue(QVariant(22));
spy.clear();
// Test:
// Command the PropertyHandle to change its value multiple times but with
// incorrect types.
- propertyHandle->setValue(QVariant(5.6), true);
- propertyHandle->setValue(QVariant("string"), true);
- propertyHandle->setValue(QVariant(false), true);
+ propertyHandle->setValue(QVariant(5.6));
+ propertyHandle->setValue(QVariant("string"));
+ propertyHandle->setValue(QVariant(false));
// Expected results:
// The valueChanged signal was not emitted
@@ -753,15 +743,15 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndIncorrectTypes()
// Set the type to STRING
mockContextPropertyInfo->myType = "STRING";
// Set an initial value
- propertyHandle->setValue(QVariant("myString"), true);
+ propertyHandle->setValue(QVariant("myString"));
spy.clear();
// Test:
// Command the PropertyHandle to change its value multiple times but with
// incorrect types.
- propertyHandle->setValue(QVariant(5.4), true);
- propertyHandle->setValue(QVariant(-8), true);
- propertyHandle->setValue(QVariant(false), true);
+ propertyHandle->setValue(QVariant(5.4));
+ propertyHandle->setValue(QVariant(-8));
+ propertyHandle->setValue(QVariant(false));
// Expected results:
// The valueChanged signal was not emitted
@@ -773,15 +763,15 @@ void PropertyHandleUnitTests::setValueWithTypeCheckAndIncorrectTypes()
// Set the type to TRUTH
mockContextPropertyInfo->myType = "TRUTH";
// Set an initial value
- propertyHandle->setValue(QVariant(false), true);
+ propertyHandle->setValue(QVariant(false));
spy.clear();
// Test:
// Command the PropertyHandle to change its value multiple times but with
// incorrect types.
- propertyHandle->setValue(QVariant(5.4), true);
- propertyHandle->setValue(QVariant(-8), true);
- propertyHandle->setValue(QVariant("string"), true);
+ propertyHandle->setValue(QVariant(5.4));
+ propertyHandle->setValue(QVariant(-8));
+ propertyHandle->setValue(QVariant("string"));
// Expected results:
// The valueChanged signal was not emitted
@@ -803,7 +793,7 @@ void PropertyHandleUnitTests::commanderAppearsAndDisappears()
propertyHandle->subscribe();
// Clear the logs from the subscription
- PropertyProvider::resetLogs();
+ Provider::resetLogs();
// Test:
// Command the DBusNameListener to tell that the Commander has appeared
@@ -812,17 +802,17 @@ void PropertyHandleUnitTests::commanderAppearsAndDisappears()
// Expected results:
// The handle unsubscribes from the real provider
- QCOMPARE(PropertyProvider::unsubscribeCount, 1);
- QCOMPARE(PropertyProvider::unsubscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::unsubscribeProviderNames.at(0), QString("NormalProvider"));
+ QCOMPARE(Provider::unsubscribeCount, 1);
+ QCOMPARE(Provider::unsubscribeKeys.at(0), key);
+ QCOMPARE(Provider::unsubscribeProviderNames.at(0), QString("NormalProvider"));
// And subscribes to Commander
- QCOMPARE(PropertyProvider::subscribeCount, 1);
- QCOMPARE(PropertyProvider::subscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::subscribeProviderNames.at(0), QString("Commander"));
+ QCOMPARE(Provider::subscribeCount, 1);
+ QCOMPARE(Provider::subscribeKeys.at(0), key);
+ QCOMPARE(Provider::subscribeProviderNames.at(0), QString("Commander"));
// Setup:
// Clear the logs from the subscription
- PropertyProvider::resetLogs();
+ Provider::resetLogs();
// Test:
// Command the DBusNameListener to tell that the Commander has disappeared
@@ -831,13 +821,13 @@ void PropertyHandleUnitTests::commanderAppearsAndDisappears()
// Expected results:
// The PropertyHandle unsubscribes from the commander
- QCOMPARE(PropertyProvider::unsubscribeCount, 1);
- QCOMPARE(PropertyProvider::unsubscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::unsubscribeProviderNames.at(0), QString("Commander"));
+ QCOMPARE(Provider::unsubscribeCount, 1);
+ QCOMPARE(Provider::unsubscribeKeys.at(0), key);
+ QCOMPARE(Provider::unsubscribeProviderNames.at(0), QString("Commander"));
// And subscribes to the real provider
- QCOMPARE(PropertyProvider::subscribeCount, 1);
- QCOMPARE(PropertyProvider::subscribeKeys.at(0), key);
- QCOMPARE(PropertyProvider::subscribeProviderNames.at(0), QString("NormalProvider"));
+ QCOMPARE(Provider::subscribeCount, 1);
+ QCOMPARE(Provider::subscribeKeys.at(0), key);
+ QCOMPARE(Provider::subscribeProviderNames.at(0), QString("NormalProvider"));
}
void PropertyHandleUnitTests::commandingDisabled()
@@ -853,7 +843,7 @@ void PropertyHandleUnitTests::commandingDisabled()
propertyHandle->subscribe();
// Clear the logs from the subscription
- PropertyProvider::resetLogs();
+ Provider::resetLogs();
// Test:
// Disable commanding
@@ -865,12 +855,12 @@ void PropertyHandleUnitTests::commandingDisabled()
// Expected results:
// The PropertyHandle ignores the Commander
- QCOMPARE(PropertyProvider::unsubscribeCount, 0);
- QCOMPARE(PropertyProvider::subscribeCount, 0);
+ QCOMPARE(Provider::unsubscribeCount, 0);
+ QCOMPARE(Provider::subscribeCount, 0);
// Setup:
// Clear the logs from the subscription
- PropertyProvider::resetLogs();
+ Provider::resetLogs();
// Test:
// Command the DBusNameListener to tell that the Commander has disappeared
@@ -879,8 +869,8 @@ void PropertyHandleUnitTests::commandingDisabled()
// Expected results:
// The PropertyHandle ignores the Commander
- QCOMPARE(PropertyProvider::unsubscribeCount, 0);
- QCOMPARE(PropertyProvider::subscribeCount, 0);
+ QCOMPARE(Provider::unsubscribeCount, 0);
+ QCOMPARE(Provider::subscribeCount, 0);
}
} // end namespace
diff --git a/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.h b/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.h
index e09e276e..496c7653 100644
--- a/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.h
+++ b/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.h
@@ -61,7 +61,6 @@ private slots:
void commanderAppearsAndDisappears();
void commandingDisabled();
-
};
} // end namespace