aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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
-rw-r--r--tests/dbus-types/dbus-types.h4
-rw-r--r--tests/dbus-types/org.freedesktop.DBus.Properties.xml1
-rw-r--r--tests/dbus-types/pulseaudio-volume.h4
-rw-r--r--tests/integration/utils/dbus-pulse-volume.cpp33
11 files changed, 71 insertions, 62 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);
diff --git a/tests/dbus-types/dbus-types.h b/tests/dbus-types/dbus-types.h
index 8c7f253..4abe9ff 100644
--- a/tests/dbus-types/dbus-types.h
+++ b/tests/dbus-types/dbus-types.h
@@ -39,4 +39,6 @@ namespace DBusTypes
static constexpr char const* STREAM_RESTORE_PATH = "/org/pulseaudio/stream_restore1";
static constexpr char const* STREAM_RESTORE_ENTRY_NAME = "org.PulseAudio.Ext.StreamRestore1.RestoreEntry";
-}
+
+} // namespace DBusTypes
+
diff --git a/tests/dbus-types/org.freedesktop.DBus.Properties.xml b/tests/dbus-types/org.freedesktop.DBus.Properties.xml
index 19a1b90..bdf6cad 100644
--- a/tests/dbus-types/org.freedesktop.DBus.Properties.xml
+++ b/tests/dbus-types/org.freedesktop.DBus.Properties.xml
@@ -5,6 +5,7 @@
<arg direction="in" type="s" name="property" />
<arg direction="in" type="v" name="value" />
</method>
+
<method name="Get">
<arg direction="in" type="s" name="entry" />
<arg direction="in" type="s" name="property" />
diff --git a/tests/dbus-types/pulseaudio-volume.h b/tests/dbus-types/pulseaudio-volume.h
index e9fe73d..6d5a222 100644
--- a/tests/dbus-types/pulseaudio-volume.h
+++ b/tests/dbus-types/pulseaudio-volume.h
@@ -42,9 +42,6 @@ private:
unsigned int volume_;
};
-Q_DECLARE_METATYPE(PulseaudioVolume)
-
-
class PulseaudioVolumeArray
{
public:
@@ -68,4 +65,5 @@ private:
QVector<PulseaudioVolume> volume_array_;
};
+Q_DECLARE_METATYPE(PulseaudioVolume)
Q_DECLARE_METATYPE(PulseaudioVolumeArray)
diff --git a/tests/integration/utils/dbus-pulse-volume.cpp b/tests/integration/utils/dbus-pulse-volume.cpp
index b42ea15..a282f77 100644
--- a/tests/integration/utils/dbus-pulse-volume.cpp
+++ b/tests/integration/utils/dbus-pulse-volume.cpp
@@ -16,13 +16,14 @@
* Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
*/
+#include "dbus-pulse-volume.h"
+
#include "dbus_properties_interface.h"
#include "dbus_accounts_interface.h"
#include "dbus_accountssound_interface.h"
#include "stream_restore_interface.h"
#include <pulse/volume.h>
-#include "dbus-pulse-volume.h"
#include <QSignalSpy>
@@ -54,20 +55,13 @@ DBusPulseVolume::DBusPulseVolume() :
qWarning() << "DBusPulseVolume::DBusPulseVolume(): D-Bus error: " << connection_string.error().message();
}
- qDebug() << "********************************Connetion: " << connection_string.value().toString();
-
connection_.reset(new QDBusConnection(QDBusConnection::connectToPeer(connection_string.value().toString(), "set-volume")));
-// connection_.reset(new QDBusConnection(QDBusConnection::connectToPeer("unix:path=/run/user/1000/pulse/dbus-socket", "set-volume")));
- qDebug() << "Is connected " << connection_->isConnected();
-
if (connection_->isConnected())
{
interface_paths_.reset(new StreamRestoreInterface("org.PulseAudio.Ext.StreamRestore1",
"/org/pulseaudio/stream_restore1",
*(connection_.get()), 0));
- qDebug() << "Interface " << (void *)interface_paths_.get();
-
if (interface_paths_)
{
// get the role paths
@@ -87,7 +81,6 @@ DBusPulseVolume::DBusPulseVolume() :
DBusPulseVolume::~DBusPulseVolume()
{
- connection_->disconnectFromPeer("unix:path=/run/user/1000/pulse/dbus-socket");
}
QString DBusPulseVolume::fillRolePath(QString const &role)
@@ -100,7 +93,7 @@ QString DBusPulseVolume::fillRolePath(QString const &role)
qWarning() << "SetVolume::fillRolePath(): D-Bus error: " << objectPath.error().message();
return "";
}
- qDebug() << "XGM: path for role " << role << "=" << objectPath.value().path();
+
auto role_info = std::make_shared<RoleInformation>();
role_info->interface_.reset(new DBusPropertiesInterface("org.PulseAudio.Ext.StreamRestore1.RestoreEntry",
objectPath.value().path(),
@@ -122,26 +115,10 @@ bool DBusPulseVolume::setVolume(QString const & role, double volume)
qWarning() << "SetVolume::setVolume(): error: Volume interfaces are not initialized";
return false;
}
+
RolesMap::const_iterator iter = roles_map_.find(role);
if (iter != roles_map_.end())
{
- QDBusReply<QVariant> prev_vol = (*iter).second->interface_->call(QLatin1String("Get"),
- QLatin1String("org.PulseAudio.Ext.StreamRestore1.RestoreEntry"),
- QLatin1String("Volume"));
-
- if (!prev_vol.isValid())
- {
- qWarning() << "SetVolume::setVolume(): D-Bus error: " << prev_vol.error().message();
- return false;
- }
- QDBusArgument arg = prev_vol.value().value<QDBusArgument>();
- PulseaudioVolumeArray element;
- arg >> element;
-
- PulseaudioVolume signal_vol(0, 4000);
- PulseaudioVolumeArray vol_array;
- vol_array.addItem(signal_vol);
-
QVariant var;
PulseaudioVolumeArray t;
PulseaudioVolume vv(0, volumeDoubleToUint(volume));
@@ -209,7 +186,6 @@ void DBusPulseVolume::initializeAccountsInterface()
std::unique_ptr<AccountsInterface> setInterface(new AccountsInterface("org.freedesktop.Accounts",
"/org/freedesktop/Accounts",
QDBusConnection::systemBus(), 0));
- qDebug() << "Interface: " << setInterface.get();
QDBusReply<QDBusObjectPath> userResp = setInterface->call(QLatin1String("FindUserByName"),
QLatin1String(username));
@@ -228,7 +204,6 @@ void DBusPulseVolume::initializeAccountsInterface()
accounts_interface_.reset(new DBusPropertiesInterface("org.freedesktop.Accounts",
userPath,
soundInterface->connection(), 0));
- qDebug() << "Interface for setting volume: " << accounts_interface_.get();
if (!accounts_interface_->isValid())
{
qWarning() << "SetVolume::initializeAccountsInterface(): D-Bus error: " << accounts_interface_->lastError().message();