aboutsummaryrefslogtreecommitdiff
path: root/tests/dbus-types
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-07 15:11:19 +0200
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-07 15:11:19 +0200
commit58f10c864fd301fbe509c232488cab7b5c99a6b8 (patch)
tree63372aa6fc5a8e337489a1df7cd5a1d70f1b1742 /tests/dbus-types
parentf76bbdf9eefaffd594078efe534ad1090f5aa41f (diff)
downloadayatana-indicator-sound-58f10c864fd301fbe509c232488cab7b5c99a6b8.tar.gz
ayatana-indicator-sound-58f10c864fd301fbe509c232488cab7b5c99a6b8.tar.bz2
ayatana-indicator-sound-58f10c864fd301fbe509c232488cab7b5c99a6b8.zip
test version for gmenuharness
Diffstat (limited to 'tests/dbus-types')
-rw-r--r--tests/dbus-types/CMakeLists.txt48
-rw-r--r--tests/dbus-types/com.ubuntu.AccountsService.Sound.xml9
-rw-r--r--tests/dbus-types/dbus-types.h40
-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.xml21
-rw-r--r--tests/dbus-types/org.gtk.Menus.xml6
-rw-r--r--tests/dbus-types/pulseaudio-volume.cpp156
-rw-r--r--tests/dbus-types/pulseaudio-volume.h71
9 files changed, 366 insertions, 0 deletions
diff --git a/tests/dbus-types/CMakeLists.txt b/tests/dbus-types/CMakeLists.txt
new file mode 100644
index 0000000..6346e25
--- /dev/null
+++ b/tests/dbus-types/CMakeLists.txt
@@ -0,0 +1,48 @@
+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_menus_xml "org.gtk.Menus.xml")
+set_source_files_properties(${dbusinterface_menus_xml} PROPERTIES
+ CLASSNAME MenusInterface)
+
+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_menus_xml} dbus_menus_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..f747458
--- /dev/null
+++ b/tests/dbus-types/dbus-types.h
@@ -0,0 +1,40 @@
+/*
+ * 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* 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";
+}
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..19a1b90
--- /dev/null
+++ b/tests/dbus-types/org.freedesktop.DBus.Properties.xml
@@ -0,0 +1,21 @@
+<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.gtk.Menus.xml b/tests/dbus-types/org.gtk.Menus.xml
new file mode 100644
index 0000000..a0d6a83
--- /dev/null
+++ b/tests/dbus-types/org.gtk.Menus.xml
@@ -0,0 +1,6 @@
+<node>
+ <interface name="org.gtk.Menus">
+ <signal name="Changed">
+ </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..e9fe73d
--- /dev/null
+++ b/tests/dbus-types/pulseaudio-volume.h
@@ -0,0 +1,71 @@
+/*
+ * 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_;
+};
+
+Q_DECLARE_METATYPE(PulseaudioVolume)
+
+
+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(PulseaudioVolumeArray)