aboutsummaryrefslogtreecommitdiff
path: root/tests/dbus-types
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-10-15 12:08:07 +0200
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-10-15 12:08:07 +0200
commite5a1645266514e38c49281a7f8da296a0e81687d (patch)
tree633da2d705450f8a1eae26c4a0ae372a2e20131f /tests/dbus-types
parentd3802b66c55e50ff1b9e2103cd446cb586d8acb3 (diff)
parent828fae630464f2eae96145cffcf97e5791497264 (diff)
downloadayatana-indicator-sound-e5a1645266514e38c49281a7f8da296a0e81687d.tar.gz
ayatana-indicator-sound-e5a1645266514e38c49281a7f8da296a0e81687d.tar.bz2
ayatana-indicator-sound-e5a1645266514e38c49281a7f8da296a0e81687d.zip
Added integragrion tests to the devices labels and icons
Diffstat (limited to 'tests/dbus-types')
-rw-r--r--tests/dbus-types/CMakeLists.txt53
-rw-r--r--tests/dbus-types/com.ubuntu.AccountsService.Sound.xml9
-rw-r--r--tests/dbus-types/dbus-types.h48
-rw-r--r--tests/dbus-types/org.PulseAudio.Ext.StreamRestore1.xml7
-rw-r--r--tests/dbus-types/org.freedesktop.Accounts.xml8
-rw-r--r--tests/dbus-types/org.freedesktop.DBus.Properties.xml22
-rw-r--r--tests/dbus-types/org.freedesktop.Notifications.xml47
-rw-r--r--tests/dbus-types/org.gtk.Actions.xml13
-rw-r--r--tests/dbus-types/pulseaudio-volume.cpp156
-rw-r--r--tests/dbus-types/pulseaudio-volume.h69
10 files changed, 432 insertions, 0 deletions
diff --git a/tests/dbus-types/CMakeLists.txt b/tests/dbus-types/CMakeLists.txt
new file mode 100644
index 0000000..cb7f512
--- /dev/null
+++ b/tests/dbus-types/CMakeLists.txt
@@ -0,0 +1,53 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+find_package(Qt5DBus REQUIRED)
+include_directories(${Qt5DBus_INCLUDE_DIRS})
+
+add_definitions(-DQT_NO_KEYWORDS=1)
+
+set(dbusinterface_streamrestore_xml "org.PulseAudio.Ext.StreamRestore1.xml")
+set_source_files_properties(${dbusinterface_streamrestore_xml} PROPERTIES
+ CLASSNAME StreamRestoreInterface)
+
+set(dbusinterface_accounts_xml "org.freedesktop.Accounts.xml")
+set_source_files_properties(${dbusinterface_accounts_xml} PROPERTIES
+ CLASSNAME AccountsInterface)
+
+set(dbusinterface_accountssound_xml "com.ubuntu.AccountsService.Sound.xml")
+set_source_files_properties(${dbusinterface_accountssound_xml} PROPERTIES
+ CLASSNAME AccountsSoundInterface)
+
+set(dbusinterface_properties_xml "org.freedesktop.DBus.Properties.xml")
+set_source_files_properties(${dbusinterface_properties_xml} PROPERTIES
+ CLASSNAME DBusPropertiesInterface
+ NO_NAMESPACE YES
+ INCLUDE "dbus-types.h")
+
+set(dbusinterface_actions_xml "org.gtk.Actions.xml")
+set_source_files_properties(${dbusinterface_actions_xml} PROPERTIES
+ CLASSNAME MenusInterface)
+
+set(dbusinterface_notifications_xml "org.freedesktop.Notifications.xml")
+set_source_files_properties(${dbusinterface_notifications_xml} PROPERTIES
+ CLASSNAME NotificationsInterface)
+
+qt5_add_dbus_interface(interface_files ${dbusinterface_streamrestore_xml} stream_restore_interface)
+qt5_add_dbus_interface(interface_files ${dbusinterface_properties_xml} dbus_properties_interface)
+qt5_add_dbus_interface(interface_files ${dbusinterface_accounts_xml} dbus_accounts_interface)
+qt5_add_dbus_interface(interface_files ${dbusinterface_accountssound_xml} dbus_accountssound_interface)
+qt5_add_dbus_interface(interface_files ${dbusinterface_actions_xml} dbus_menus_interface)
+qt5_add_dbus_interface(interface_files ${dbusinterface_notifications_xml} dbus_notifications_interface)
+
+add_library(
+ sound-indicator-dbus-interfaces
+ STATIC
+ ${interface_files}
+ pulseaudio-volume.cpp
+)
+
+qt5_use_modules(
+ sound-indicator-dbus-interfaces
+ Core
+ DBus
+)
diff --git a/tests/dbus-types/com.ubuntu.AccountsService.Sound.xml b/tests/dbus-types/com.ubuntu.AccountsService.Sound.xml
new file mode 100644
index 0000000..27c915a
--- /dev/null
+++ b/tests/dbus-types/com.ubuntu.AccountsService.Sound.xml
@@ -0,0 +1,9 @@
+<node>
+ <interface name="com.ubuntu.AccountsService.Sound">
+ <method name="Set">
+ <arg direction="in" type="s" name="interface" />
+ <arg direction="in" type="s" name="property" />
+ <arg direction="out" type="o" name="path" />
+ </method>
+ </interface>
+</node>
diff --git a/tests/dbus-types/dbus-types.h b/tests/dbus-types/dbus-types.h
new file mode 100644
index 0000000..b75acf0
--- /dev/null
+++ b/tests/dbus-types/dbus-types.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 Canonical, Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
+ */
+#pragma once
+
+#include <QDBusMetaType>
+#include "pulseaudio-volume.h"
+
+namespace DBusTypes
+{
+ inline void registerMetaTypes()
+ {
+ PulseaudioVolume::registerMetaType();
+ PulseaudioVolumeArray::registerMetaType();
+ }
+
+ static constexpr char const* DBUS_NAME = "com.canonical.indicator.sound";
+
+ static constexpr char const* DBUS_PULSE = "org.PulseAudio1";
+
+ static constexpr char const* ACCOUNTS_SERVICE = "org.freedesktop.Accounts";
+
+ static constexpr char const* STREAM_RESTORE_NAME = "org.PulseAudio.Ext.StreamRestore1";
+
+ static constexpr char const* STREAM_RESTORE_PATH = "/org/pulseaudio/stream_restore1";
+
+ static constexpr char const* STREAM_RESTORE_ENTRY_NAME = "org.PulseAudio.Ext.StreamRestore1.RestoreEntry";
+
+ static constexpr char const* MAIN_SERVICE_PATH = "/com/canonical/indicator/sound";
+
+ static constexpr char const* ACTIONS_INTERFACE = "org.gtk.Actions";
+
+} // namespace DBusTypes
+
diff --git a/tests/dbus-types/org.PulseAudio.Ext.StreamRestore1.xml b/tests/dbus-types/org.PulseAudio.Ext.StreamRestore1.xml
new file mode 100644
index 0000000..bf9af76
--- /dev/null
+++ b/tests/dbus-types/org.PulseAudio.Ext.StreamRestore1.xml
@@ -0,0 +1,7 @@
+<node>
+ <interface name="org.PulseAudio.Ext.StreamRestore1">
+ <method name="GetEntryByName">
+ <arg direction="in" type="s" name="entry" />
+ <arg direction="out" type="o" name="value" />
+ </interface>
+</node>
diff --git a/tests/dbus-types/org.freedesktop.Accounts.xml b/tests/dbus-types/org.freedesktop.Accounts.xml
new file mode 100644
index 0000000..d9c6b2a
--- /dev/null
+++ b/tests/dbus-types/org.freedesktop.Accounts.xml
@@ -0,0 +1,8 @@
+<node>
+ <interface name="org.freedesktop.Accounts">
+ <method name="FindUserByName">
+ <arg direction="in" type="s" name="user" />
+ <arg direction="out" type="o" name="path" />
+ </method>
+ </interface>
+</node>
diff --git a/tests/dbus-types/org.freedesktop.DBus.Properties.xml b/tests/dbus-types/org.freedesktop.DBus.Properties.xml
new file mode 100644
index 0000000..bdf6cad
--- /dev/null
+++ b/tests/dbus-types/org.freedesktop.DBus.Properties.xml
@@ -0,0 +1,22 @@
+<node>
+ <interface name="org.freedesktop.DBus.Properties">
+ <method name="Set">
+ <arg direction="in" type="s" name="entry" />
+ <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" />
+ <arg direction="out" type="v" name="value" />
+ </method>
+
+ <signal name="PropertiesChanged">
+ <arg type="s" name="interface_name"/>
+ <arg type="a{sv}" name="changed_properties"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
+ <arg type="as" name="invalidated_properties"/>
+ </signal>
+ </interface>
+</node>
diff --git a/tests/dbus-types/org.freedesktop.Notifications.xml b/tests/dbus-types/org.freedesktop.Notifications.xml
new file mode 100644
index 0000000..f7d923e
--- /dev/null
+++ b/tests/dbus-types/org.freedesktop.Notifications.xml
@@ -0,0 +1,47 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.Notifications">
+ <signal name="NotificationClosed">
+ <arg name="id" type="u" direction="out"/>
+ <arg name="reason" type="u" direction="out"/>
+ </signal>
+ <signal name="ActionInvoked">
+ <arg name="id" type="u" direction="out"/>
+ <arg name="action_key" type="s" direction="out"/>
+ </signal>
+ <signal name="dataChanged">
+ <arg name="id" type="u" direction="out"/>
+ </signal>
+ <method name="CloseNotification">
+ <arg name="id" type="u" direction="in"/>
+ </method>
+ <method name="GetServerInformation">
+ <arg name="name" type="s" direction="out"/>
+ <arg name="vendor" type="s" direction="out"/>
+ <arg name="version" type="s" direction="out"/>
+ <arg name="specVersion" type="s" direction="out"/>
+ </method>
+ <method name="GetCapabilities">
+ <arg type="as" direction="out"/>
+ </method>
+ <method name="Notify">
+ <arg type="u" direction="out"/>
+ <arg name="app_name" type="s" direction="in"/>
+ <arg name="replaces_id" type="u" direction="in"/>
+ <arg name="app_icon" type="s" direction="in"/>
+ <arg name="summary" type="s" direction="in"/>
+ <arg name="body" type="s" direction="in"/>
+ <arg name="actions" type="as" direction="in"/>
+ <arg name="hints" type="a{sv}" direction="in"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In6" value="QVariantMap"/>
+ <arg name="expire_timeout" type="i" direction="in"/>
+ </method>
+ <method name="onDataChanged">
+ <arg name="id" type="u" direction="in"/>
+ </method>
+ <method name="onCompleted">
+ <arg name="id" type="u" direction="in"/>
+ </method>
+ </interface>
+</node>
diff --git a/tests/dbus-types/org.gtk.Actions.xml b/tests/dbus-types/org.gtk.Actions.xml
new file mode 100644
index 0000000..b691f1f
--- /dev/null
+++ b/tests/dbus-types/org.gtk.Actions.xml
@@ -0,0 +1,13 @@
+<node>
+ <interface name="org.gtk.Actions">
+ <signal name="Changed">
+ <arg name="removedActions" type="as" direction="in" />
+ <arg name="actionsFlags" type="a{sb}" direction="in" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
+ <arg name="actionsChanged" type="a{sv}" direction="in" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QVariantMap"/>
+ <arg name="actionsAdded" type="a{s(bgav)}" direction="in" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QVariantMap"/>
+ </signal>
+ </interface>
+</node>
diff --git a/tests/dbus-types/pulseaudio-volume.cpp b/tests/dbus-types/pulseaudio-volume.cpp
new file mode 100644
index 0000000..8ee305f
--- /dev/null
+++ b/tests/dbus-types/pulseaudio-volume.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2015 Canonical, Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
+ */
+#include "dbus-types.h"
+
+PulseaudioVolume::PulseaudioVolume() :
+ type_(0),
+ volume_(10)
+{
+}
+
+PulseaudioVolume::PulseaudioVolume(unsigned int type, unsigned int volume) :
+ type_(type)
+ , volume_(volume)
+{
+}
+
+PulseaudioVolume::PulseaudioVolume(const PulseaudioVolume &other) :
+ type_(other.type_),
+ volume_(other.volume_)
+{
+}
+
+PulseaudioVolume& PulseaudioVolume::operator=(const PulseaudioVolume &other)
+{
+ type_ = other.type_;
+ volume_ = other.volume_;
+
+ return *this;
+}
+
+PulseaudioVolume::~PulseaudioVolume()
+{
+}
+
+unsigned int PulseaudioVolume::getType() const
+{
+ return type_;
+}
+
+unsigned int PulseaudioVolume::getVolume() const
+{
+ return volume_;
+}
+
+void PulseaudioVolume::registerMetaType()
+{
+ qRegisterMetaType<PulseaudioVolume>("PulseaudioVolume");
+
+ qDBusRegisterMetaType<PulseaudioVolume>();
+}
+
+QDBusArgument &operator<<(QDBusArgument &argument, const PulseaudioVolume& volume)
+{
+ argument.beginStructure();
+ argument << volume.type_;
+ argument << volume.volume_;
+ argument.endStructure();
+
+ return argument;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, PulseaudioVolume &volume)
+{
+ argument.beginStructure();
+ argument >> volume.type_;
+ argument >> volume.volume_;
+ argument.endStructure();
+
+ return argument;
+}
+
+PulseaudioVolumeArray::PulseaudioVolumeArray()
+{
+}
+
+PulseaudioVolumeArray::PulseaudioVolumeArray(const PulseaudioVolumeArray &other) :
+ volume_array_(other.volume_array_)
+{
+}
+
+PulseaudioVolumeArray& PulseaudioVolumeArray::operator=(const PulseaudioVolumeArray &other)
+{
+ volume_array_ = other.volume_array_;
+
+ return *this;
+}
+
+PulseaudioVolumeArray::~PulseaudioVolumeArray()
+{
+}
+
+int PulseaudioVolumeArray::getNumItems() const
+{
+ return volume_array_.size();
+}
+
+PulseaudioVolume PulseaudioVolumeArray::getItem(int i) const
+{
+ if (i < volume_array_.size())
+ {
+ return volume_array_[i];
+ }
+ return PulseaudioVolume();
+}
+
+void PulseaudioVolumeArray::addItem(PulseaudioVolume const &item)
+{
+ volume_array_.push_back(item);
+}
+
+void PulseaudioVolumeArray::registerMetaType()
+{
+ qRegisterMetaType<PulseaudioVolumeArray>("PulseaudioVolumeArray");
+
+ qDBusRegisterMetaType<PulseaudioVolumeArray>();
+}
+
+QDBusArgument &operator<<(QDBusArgument &argument, const PulseaudioVolumeArray& volume)
+{
+ argument.beginArray( qMetaTypeId<PulseaudioVolume>() );
+ for (int i = 0; i < volume.volume_array_.size(); ++ i)
+ {
+ PulseaudioVolume item = volume.getItem(i);
+ argument << item;
+ }
+ argument.endArray();
+ return argument;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, PulseaudioVolumeArray &volume)
+{
+ argument.beginArray();
+ while ( !argument.atEnd() ) {
+ PulseaudioVolume item;
+ argument >> item;
+ volume.volume_array_.push_back(item);
+ }
+ argument.endArray();
+
+ return argument;
+}
diff --git a/tests/dbus-types/pulseaudio-volume.h b/tests/dbus-types/pulseaudio-volume.h
new file mode 100644
index 0000000..6d5a222
--- /dev/null
+++ b/tests/dbus-types/pulseaudio-volume.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2015 Canonical, Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
+ */
+#pragma once
+
+#include <QtDBus>
+
+class PulseaudioVolume
+{
+public:
+ PulseaudioVolume();
+ PulseaudioVolume(unsigned int type, unsigned int volume);
+ PulseaudioVolume(const PulseaudioVolume &other);
+ PulseaudioVolume& operator=(const PulseaudioVolume &other);
+ ~PulseaudioVolume();
+
+ friend QDBusArgument &operator<<(QDBusArgument &argument, PulseaudioVolume const & volume);
+ friend const QDBusArgument &operator>>(QDBusArgument const & argument, PulseaudioVolume &volume);
+
+ unsigned int getType() const;
+ unsigned int getVolume() const;
+
+ //register Message with the Qt type system
+ static void registerMetaType();
+
+private:
+ unsigned int type_;
+ unsigned int volume_;
+};
+
+class PulseaudioVolumeArray
+{
+public:
+ PulseaudioVolumeArray();
+ PulseaudioVolumeArray(QString const &interface, QString const &property, QDBusVariant const& value);
+ PulseaudioVolumeArray(const PulseaudioVolumeArray &other);
+ PulseaudioVolumeArray& operator=(const PulseaudioVolumeArray &other);
+ ~PulseaudioVolumeArray();
+
+ friend QDBusArgument &operator<<(QDBusArgument &argument, PulseaudioVolumeArray const & volume);
+ friend const QDBusArgument &operator>>(QDBusArgument const & argument, PulseaudioVolumeArray &volume);
+
+ int getNumItems() const;
+ PulseaudioVolume getItem(int i) const;
+ void addItem(PulseaudioVolume const &item);
+
+ //register Message with the Qt type system
+ static void registerMetaType();
+
+private:
+ QVector<PulseaudioVolume> volume_array_;
+};
+
+Q_DECLARE_METATYPE(PulseaudioVolume)
+Q_DECLARE_METATYPE(PulseaudioVolumeArray)