aboutsummaryrefslogtreecommitdiff
path: root/tests/accounts-mock
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-21 11:53:31 +0200
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-21 11:53:31 +0200
commitae0602ca11090c6c70cdf289ce3871766d36519c (patch)
tree2a8591780c403f3dc0d416d800df4f6abfffb02e /tests/accounts-mock
parent913282e093a723b7e3a7bb899a77a068edafcd01 (diff)
downloadayatana-indicator-sound-ae0602ca11090c6c70cdf289ce3871766d36519c.tar.gz
ayatana-indicator-sound-ae0602ca11090c6c70cdf289ce3871766d36519c.tar.bz2
ayatana-indicator-sound-ae0602ca11090c6c70cdf289ce3871766d36519c.zip
code cleanup
Diffstat (limited to 'tests/accounts-mock')
-rw-r--r--tests/accounts-mock/AccountsDefs.h15
-rw-r--r--tests/accounts-mock/AccountsMock.cpp2
-rw-r--r--tests/accounts-mock/AccountsMock.h15
-rw-r--r--tests/accounts-mock/AccountsServiceSoundMock.cpp26
-rw-r--r--tests/accounts-mock/AccountsServiceSoundMock.h26
-rw-r--r--tests/accounts-mock/CMakeLists.txt5
-rw-r--r--tests/accounts-mock/main.cpp2
7 files changed, 62 insertions, 29 deletions
diff --git a/tests/accounts-mock/AccountsDefs.h b/tests/accounts-mock/AccountsDefs.h
index e2b24ab..0e4f270 100644
--- a/tests/accounts-mock/AccountsDefs.h
+++ b/tests/accounts-mock/AccountsDefs.h
@@ -17,10 +17,21 @@
*/
#pragma once
-namespace
+namespace ubuntu
+{
+
+namespace indicators
+{
+
+namespace testing
{
constexpr const char ACCOUNTS_SERVICE[] = "org.freedesktop.Accounts";
constexpr const char USER_PATH[] = "/org/freedesktop/Accounts/UserTest";
constexpr const char ACCOUNTS_PATH[] = "/org/freedesktop/Accounts";
constexpr const char ACCOUNTS_SOUND_INTERFACE[] = "com.ubuntu.AccountsService.Sound";
-}
+} // namespace testing
+
+} // namespace indicators
+
+} // namespace ubuntu
+
diff --git a/tests/accounts-mock/AccountsMock.cpp b/tests/accounts-mock/AccountsMock.cpp
index 72f86a6..5c92dc5 100644
--- a/tests/accounts-mock/AccountsMock.cpp
+++ b/tests/accounts-mock/AccountsMock.cpp
@@ -20,6 +20,8 @@
#include "AccountsMock.h"
#include "AccountsDefs.h"
+using namespace ubuntu::indicators::testing;
+
AccountsMock::AccountsMock(QObject* parent)
: QObject(parent)
{
diff --git a/tests/accounts-mock/AccountsMock.h b/tests/accounts-mock/AccountsMock.h
index 759443c..72372e0 100644
--- a/tests/accounts-mock/AccountsMock.h
+++ b/tests/accounts-mock/AccountsMock.h
@@ -21,6 +21,15 @@
#include <QDBusObjectPath>
#include <QObject>
+namespace ubuntu
+{
+
+namespace indicators
+{
+
+namespace testing
+{
+
class AccountsMock : public QObject, protected QDBusContext
{
Q_OBJECT
@@ -33,3 +42,9 @@ public:
AccountsMock(QObject* parent = 0);
virtual ~AccountsMock();
};
+
+} // namespace testing
+
+} // namespace indicators
+
+} // namespace ubuntu
diff --git a/tests/accounts-mock/AccountsServiceSoundMock.cpp b/tests/accounts-mock/AccountsServiceSoundMock.cpp
index 10f4f8d..37de377 100644
--- a/tests/accounts-mock/AccountsServiceSoundMock.cpp
+++ b/tests/accounts-mock/AccountsServiceSoundMock.cpp
@@ -22,6 +22,8 @@
#include "AccountsServiceSoundMock.h"
#include "AccountsDefs.h"
+using namespace ubuntu::indicators::testing;
+
AccountsServiceSoundMock::AccountsServiceSoundMock(QObject* parent)
: QObject(parent)
, volume_(0.0)
@@ -38,23 +40,9 @@ double AccountsServiceSoundMock::volume() const
void AccountsServiceSoundMock::setVolume(double volume)
{
volume_ = volume;
- notifyPropertyChanged(ACCOUNTS_SOUND_INTERFACE,
- USER_PATH,
- "Volume");
-}
-
-void AccountsServiceSoundMock::notifyPropertyChanged(QString const & interface,
- QString const & path,
- QString const & propertyName)
-{
- QDBusMessage signal = QDBusMessage::createSignal(
- path,
- "org.freedesktop.DBus.Properties",
- "PropertiesChanged");
- signal << interface;
- QVariantMap changedProps;
- changedProps.insert(propertyName, property(propertyName.toStdString().c_str()));
- signal << changedProps;
- signal << QStringList();
- QDBusConnection::systemBus().send(signal);
+ notifier_.notifyPropertyChanged(QDBusConnection::systemBus(),
+ ACCOUNTS_SOUND_INTERFACE,
+ USER_PATH,
+ "Volume",
+ property("Volume"));
}
diff --git a/tests/accounts-mock/AccountsServiceSoundMock.h b/tests/accounts-mock/AccountsServiceSoundMock.h
index 2be996f..bb3dbe8 100644
--- a/tests/accounts-mock/AccountsServiceSoundMock.h
+++ b/tests/accounts-mock/AccountsServiceSoundMock.h
@@ -20,10 +20,22 @@
#include <QDBusContext>
#include <QObject>
+#include "DBusPropertiesNotifier.h"
+
+namespace ubuntu
+{
+
+namespace indicators
+{
+
+namespace testing
+{
+
+class DBusPropertiesNotifier;
+
class AccountsServiceSoundMock : public QObject, protected QDBusContext
{
Q_OBJECT
-// Q_CLASSINFO("D-Bus Interface", "test.com.ubuntu.AccountsService.Sound")
Q_PROPERTY(double Volume READ volume WRITE setVolume)
public Q_SLOTS:
@@ -34,11 +46,13 @@ public:
AccountsServiceSoundMock(QObject* parent = 0);
virtual ~AccountsServiceSoundMock();
-protected:
- void notifyPropertyChanged(QString const & interface,
- QString const & path,
- QString const & propertyName);
-
private:
double volume_;
+ DBusPropertiesNotifier notifier_;
};
+
+} // namespace testing
+
+} // namespace indicators
+
+} // namespace ubuntu
diff --git a/tests/accounts-mock/CMakeLists.txt b/tests/accounts-mock/CMakeLists.txt
index fcfab2d..aab7940 100644
--- a/tests/accounts-mock/CMakeLists.txt
+++ b/tests/accounts-mock/CMakeLists.txt
@@ -15,13 +15,13 @@ qt5_add_dbus_interface(interface_files ${dbusinterface_sound_xml} accountsservic
qt5_add_dbus_adaptor(adaptor_files
com.ubuntu.AccountsService.Sound.Mock.xml
AccountsServiceSoundMock.h
- AccountsServiceSoundMock
+ ubuntu::indicators::testing::AccountsServiceSoundMock
AccountsServiceSoundMockAdaptor)
qt5_add_dbus_adaptor(adaptor_files
org.freedesktop.Accounts.Mock.xml
AccountsMock.h
- AccountsMock
+ ubuntu::indicators::testing::AccountsMock
AccountsMockAdaptor)
add_executable(
@@ -30,6 +30,7 @@ add_executable(
${adaptor_files}
AccountsServiceSoundMock.cpp
AccountsMock.cpp
+ DBusPropertiesNotifier.cpp
main.cpp
)
diff --git a/tests/accounts-mock/main.cpp b/tests/accounts-mock/main.cpp
index 04ec530..d6cd1d3 100644
--- a/tests/accounts-mock/main.cpp
+++ b/tests/accounts-mock/main.cpp
@@ -26,6 +26,8 @@
#include "AccountsMock.h"
#include "AccountsMockAdaptor.h"
+using namespace ubuntu::indicators::testing;
+
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);