libqtdbusmock-0.5+15.10.20151009/0000755000015300001610000000000012605720601016547 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/cmake/0000755000015300001610000000000012605720601017627 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/cmake/COPYING-CMAKE-SCRIPTS0000644000015300001610000000245712605720403022635 0ustar pbuserpbgroup00000000000000Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. libqtdbusmock-0.5+15.10.20151009/cmake/FindValgrind.cmake0000644000015300001610000000140212605720403023175 0ustar pbuserpbgroup00000000000000 option( ENABLE_MEMCHECK_OPTION "If set to ON, enables automatic creation of memcheck targets" OFF ) find_program( VALGRIND_PROGRAM NAMES valgrind ) if(VALGRIND_PROGRAM) set(VALGRIND_PROGRAM_OPTIONS "--suppressions=${CMAKE_SOURCE_DIR}/tests/data/valgrind.suppression" "--error-exitcode=1" "--leak-check=full" "--gen-suppressions=all" "--show-leak-kinds=definite" "--quiet" ) endif() find_package_handle_standard_args( VALGRIND DEFAULT_MSG VALGRIND_PROGRAM ) function(add_valgrind_test NAME EXECUTABLE) if(ENABLE_MEMCHECK_OPTION AND VALGRIND_PROGRAM) add_test(${NAME} ${VALGRIND_PROGRAM} ${VALGRIND_PROGRAM_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}") else() add_test(${NAME} ${EXECUTABLE}) endif() endfunction() libqtdbusmock-0.5+15.10.20151009/cmake/FindGMock.cmake0000644000015300001610000000076612605720403022443 0ustar pbuserpbgroup00000000000000# Build with system gmock and embedded gtest set (GMOCK_INCLUDE_DIRS "/usr/include/gmock/include" CACHE PATH "gmock source include directory") set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") set (GTEST_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") set(GTEST_LIBRARIES gtest) set(GTEST_MAIN_LIBRARIES gtest_main) set(GMOCK_LIBRARIES gmock gmock_main) libqtdbusmock-0.5+15.10.20151009/cmake/Coverage.cmake0000644000015300001610000000422612605720403022370 0ustar pbuserpbgroup00000000000000if (CMAKE_BUILD_TYPE MATCHES coverage) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin") if (NOT GCOVR_EXECUTABLE) message(STATUS "Gcovr binary was not found, can not generate XML coverage info.") else () message(STATUS "Gcovr found, can generate XML coverage info.") add_custom_target (coverage-xml WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" --exclude="obj.*" -x -r "${CMAKE_SOURCE_DIR}" --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml) endif() find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin") find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT}) if (NOT LCOV_EXECUTABLE) message(STATUS "Lcov binary was not found, can not generate HTML coverage info.") else () if(NOT GENHTML_EXECUTABLE) message(STATUS "Genthml binary not found, can not generate HTML coverage info.") else() message(STATUS "Lcov and genhtml found, can generate HTML coverage info.") add_custom_target (coverage-html WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND "${LCOV_EXECUTABLE}" --capture --output-file "${CMAKE_BINARY_DIR}/coverage.info" --no-checksum --directory "${CMAKE_BINARY_DIR}/src" COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '/usr/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info" COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '${CMAKE_BINARY_DIR}/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info" COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '${CMAKE_SOURCE_DIR}/tests/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info" COMMAND "${GENHTML_EXECUTABLE}" --prefix "${CMAKE_BINARY_DIR}" --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info ) endif() endif() endif() libqtdbusmock-0.5+15.10.20151009/COPYING0000644000015300001610000001672712605720403017617 0ustar pbuserpbgroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. libqtdbusmock-0.5+15.10.20151009/tests/0000755000015300001610000000000012605720601017711 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/tests/libqtdbusmock/0000755000015300001610000000000012605720601022554 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/tests/libqtdbusmock/TestDBusMock.cpp0000644000015300001610000002052412605720407025576 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #include #include #include #include #include #include #include #include using namespace std; using namespace testing; using namespace QtDBusTest; using namespace QtDBusMock; namespace { class TestDBusMock: public Test { protected: TestDBusMock() : dbusMock(dbusTestRunner) { } virtual ~TestDBusMock() { } bool processListContains(const char *str) { QProcess pgrep; pgrep.start("ps", QStringList() << "--no-headers" << "--ppid" << QString::number(QCoreApplication::applicationPid()) << "-o" << "args"); pgrep.waitForFinished(); pgrep.waitForReadyRead(); return pgrep.readAll().contains(str); } DBusTestRunner dbusTestRunner; DBusMock dbusMock; }; TEST_F(TestDBusMock, StartsDBusMockSession) { dbusMock.registerCustomMock("test.name", "/test/object", "test.Interface", QDBusConnection::SessionBus); dbusTestRunner.startServices(); EXPECT_TRUE( processListContains( "python3 -m dbusmock test.name /test/object test.Interface")); } TEST_F(TestDBusMock, StartsDBusMockSystem) { dbusMock.registerCustomMock("test.name2", "/test/object2", "test.Interface2", QDBusConnection::SystemBus); dbusTestRunner.startServices(); EXPECT_TRUE( processListContains( "python3 -m dbusmock -s test.name2 /test/object2 test.Interface2")); } TEST_F(TestDBusMock, StartsDBusMockWithNM) { dbusMock.registerNetworkManager(); dbusTestRunner.startServices(); EXPECT_TRUE( processListContains( "python3 -m dbusmock --template networkmanager")); NetworkManagerMockInterface &networkManager( dbusMock.networkManagerInterface()); networkManager.AddWiFiDevice("device", "eth1", NM_STATE_DISCONNECTED).waitForFinished(); QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbusTestRunner.systemConnection()); QDBusReply > devices = iface.call("GetDevices"); ASSERT_EQ(true, devices.isValid()); ASSERT_EQ(1, devices.value().size()); } TEST_F(TestDBusMock, StartsDBusMockTemplateParameters) { dbusMock.registerUpower({{"DaemonVersion", "0.99.0"}, {"OnBattery", true}}); dbusTestRunner.startServices(); EXPECT_TRUE( processListContains( "python3 -m dbusmock --template upower --parameters {\"DaemonVersion\":\"0.99.0\",\"OnBattery\":true}")); QDBusInterface iface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", dbusTestRunner.systemConnection()); EXPECT_EQ("0.99.0", iface.property("DaemonVersion").toString()); EXPECT_TRUE(iface.property("OnBattery").toBool()); } TEST_F(TestDBusMock, StartsDBusMockWithTemplate) { dbusMock.registerTemplate(NM_DBUS_SERVICE, "networkmanager", QDBusConnection::SystemBus); dbusTestRunner.startServices(); EXPECT_TRUE( processListContains( "python3 -m dbusmock --template networkmanager")); NetworkManagerMockInterface &networkManager( dbusMock.networkManagerInterface()); networkManager.AddWiFiDevice("device", "eth1", NM_STATE_DISCONNECTED).waitForFinished(); QDBusInterface iface (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbusTestRunner.systemConnection()); QDBusReply > devices = iface.call("GetDevices"); ASSERT_EQ(true, devices.isValid()); ASSERT_EQ(1, devices.value().size()); } TEST_F(TestDBusMock, GetMethodCalls) { dbusMock.registerCustomMock("test.name", "/test/path", "test.interface", QDBusConnection::SessionBus); dbusTestRunner.startServices(); OrgFreedesktopDBusMockInterface &mockInterface( dbusMock.mockInterface("test.name", "/test/path", "test.interface", QDBusConnection::SessionBus)); mockInterface.AddMethod("test.interface", "MethodName", "s", "s", "ret = 'output'").waitForFinished(); QDBusMessage message( QDBusMessage::createMethodCall("test.name", "/test/path", "test.interface", "MethodName")); message.setArguments(QVariantList() << QVariant("input")); QDBusMessage reply(dbusTestRunner.sessionConnection().call(message)); ASSERT_EQ(1, reply.arguments().size()); EXPECT_EQ("output", reply.arguments().first().toString().toStdString()); QList methodCalls(mockInterface.GetMethodCalls("MethodName")); ASSERT_EQ(1, methodCalls.size()); MethodCall call; call = methodCalls.first(); ASSERT_EQ(1, call.args().size()); EXPECT_EQ("input", call.args().first().toString().toStdString()); } TEST_F(TestDBusMock, GetAllMethodCalls) { dbusMock.registerCustomMock("test.name", "/test/path", "test.interface", QDBusConnection::SessionBus); dbusTestRunner.startServices(); OrgFreedesktopDBusMockInterface &mockInterface( dbusMock.mockInterface("test.name", "/test/path", "test.interface", QDBusConnection::SessionBus)); mockInterface.AddMethod("test.interface", "MethodName", "s", "s", "ret = 'output'").waitForFinished(); QDBusMessage message( QDBusMessage::createMethodCall("test.name", "/test/path", "test.interface", "MethodName")); message.setArguments(QVariantList() << QVariant("input")); QDBusMessage reply(dbusTestRunner.sessionConnection().call(message)); ASSERT_EQ(1, reply.arguments().size()); EXPECT_EQ("output", reply.arguments().first().toString().toStdString()); QList methodCalls(mockInterface.GetCalls()); ASSERT_EQ(1, methodCalls.size()); NamedMethodCall call; call = methodCalls.first(); EXPECT_EQ("MethodName", call.methodName().toStdString()); ASSERT_EQ(1, call.args().size()); EXPECT_EQ("input", call.args().first().toString().toStdString()); } TEST_F(TestDBusMock, AddMethods) { dbusMock.registerCustomMock("test.name", "/test/path", "test.interface", QDBusConnection::SessionBus); dbusTestRunner.startServices(); OrgFreedesktopDBusMockInterface &mockInterface( dbusMock.mockInterface("test.name", "/test/path", "test.interface", QDBusConnection::SessionBus)); Method method1; method1.setName("MethodName1"); method1.setInSig("s"); method1.setOutSig("s"); method1.setCode("ret = 'output1'"); Method methodTemp; methodTemp.setName("MethodName2"); methodTemp.setInSig("u"); methodTemp.setOutSig("s"); methodTemp.setCode("ret = 'output2'"); Method method2; method2 = methodTemp; mockInterface.AddMethods("test.interface", QList() << method1 << method2).waitForFinished(); { QDBusMessage message( QDBusMessage::createMethodCall("test.name", "/test/path", "test.interface", "MethodName1")); message.setArguments(QVariantList() << QVariant("input")); QDBusMessage reply(dbusTestRunner.sessionConnection().call(message)); ASSERT_EQ(1, reply.arguments().size()); EXPECT_EQ("output1", reply.arguments().first().toString().toStdString()); } { QDBusMessage message( QDBusMessage::createMethodCall("test.name", "/test/path", "test.interface", "MethodName2")); message.setArguments(QVariantList() << QVariant(123)); QDBusMessage reply(dbusTestRunner.sessionConnection().call(message)); ASSERT_EQ(1, reply.arguments().size()); EXPECT_EQ("output2", reply.arguments().first().toString().toStdString()); } QList methodCalls(mockInterface.GetCalls()); ASSERT_EQ(2, methodCalls.size()); { NamedMethodCall call; call = methodCalls.first(); EXPECT_EQ("MethodName1", call.methodName().toStdString()); ASSERT_EQ(1, call.args().size()); EXPECT_EQ("input", call.args().first().toString().toStdString()); } { NamedMethodCall call; call = methodCalls[1]; EXPECT_EQ("MethodName2", call.methodName().toStdString()); ASSERT_EQ(1, call.args().size()); EXPECT_EQ(123, call.args().first().toUInt()); } } } // namespace libqtdbusmock-0.5+15.10.20151009/tests/main.cpp0000644000015300001610000000234612605720403021346 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #include #include #include #include using namespace QtDBusMock; int main(int argc, char **argv) { // qputenv("LANG", "C.UTF-8"); // unsetenv("LC_ALL"); // setlocale(LC_ALL, ""); // bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); // textdomain(GETTEXT_PACKAGE); QCoreApplication application(argc, argv); DBusMock::registerMetaTypes(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } libqtdbusmock-0.5+15.10.20151009/tests/CMakeLists.txt0000644000015300001610000000106312605720403022451 0ustar pbuserpbgroup00000000000000 set(CMAKE_AUTOMOC OFF) include(FindGMock) set(CMAKE_AUTOMOC ON) find_package("Valgrind" REQUIRED) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${GMOCK_INCLUDE_DIRS}) include_directories(${GTEST_INCLUDE_DIRS}) set( UNIT_TESTS_SRC main.cpp libqtdbusmock/TestDBusMock.cpp ) add_executable( unit-tests ${UNIT_TESTS_SRC} ) qt5_use_modules( unit-tests Core DBus Test ) target_link_libraries( unit-tests qtdbusmock ${QTDBUSTEST_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ) add_valgrind_test( unit-tests unit-tests ) libqtdbusmock-0.5+15.10.20151009/tests/data/0000755000015300001610000000000012605720601020622 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/tests/data/valgrind.suppression0000644000015300001610000000154412605720403024750 0ustar pbuserpbgroup00000000000000{ Ignore pthreads Memcheck:Leak ... fun:pthread_create@@* } { Glib memalign Memcheck:Leak ... fun:posix_memalign } { Ignore glib mainloop Memcheck:Leak ... fun:g_main_context_push_thread_default } { Ignore glib main context Memcheck:Leak ... fun:g_main_context_new } { False positive leak on strings in i386 Memcheck:Leak fun:_Znwj fun:_ZNSs4_Rep9_S_createEjjRKSaIcE ... fun:_ZN7testing14InitGoogleTestEPiPPc fun:(below main) } { False positive leak on strings on i386 Memcheck:Leak fun:_Znwj fun:_ZNSs4_Rep9_S_createEjjRKSaIcE ... fun:__libc_csu_init fun:(below main) } { Qt apparently has some statically allocated data here Memcheck:Leak fun:calloc fun:allocate_dtv fun:_ZN7QThread5startENS_8PriorityE obj:/usr/lib/*/libQt5Core.so.* ... obj:* } libqtdbusmock-0.5+15.10.20151009/src/0000755000015300001610000000000012605720601017336 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/0000755000015300001610000000000012605720601022201 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/libqtdbusmock.pc.in0000644000015300001610000000047212605720403026000 0ustar pbuserpbgroup00000000000000libdir=@CMAKE_INSTALL_FULL_LIBDIR@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Cflags: -I${includedir}/libqtdbusmock-@API_VERSION@ Requires: Qt5Core Libs: -L${libdir} -lqtdbusmock -lqtdbustest Name: libqtdbusmock Description: A library to facilitate mocking DBus services written in Qt/C++ Version: @ABI_VERSION@ libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/MethodCall.cpp0000644000015300001610000000651612605720403024731 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #include using namespace QtDBusMock; MethodCall::MethodCall() : m_timestamp(0) { } MethodCall::MethodCall(const MethodCall &other) : m_timestamp(other.m_timestamp), m_args(other.m_args) { } MethodCall& MethodCall::operator=(const MethodCall &other) { m_timestamp = other.m_timestamp; m_args = other.m_args; return *this; } MethodCall::~MethodCall() { } void MethodCall::registerMetaType() { qRegisterMetaType("QtDBusMock::MethodCall"); qDBusRegisterMetaType(); qDBusRegisterMetaType>(); } const quint64 & MethodCall::timestamp() const { return m_timestamp; } const QVariantList & MethodCall::args() const { return m_args; } void MethodCall::setTimestamp(quint64 timestamp) { m_timestamp = timestamp; } void MethodCall::setArgs(const QVariantList &args) { m_args = args; } QDBusArgument &operator<<(QDBusArgument &argument, const MethodCall& methodCall) { argument.beginStructure(); argument << methodCall.timestamp() << methodCall.args(); argument.endStructure(); return argument; } static void transform(QVariantList &list); static void transform(QVariantMap &map); static QVariant transform(const QDBusArgument & value) { switch (value.currentType()) { case QDBusArgument::ArrayType: { value.beginArray(); QVariantList list = transform(value).toList(); value.endArray(); return list; } case QDBusArgument::MapType: { QVariantMap map; value >> map; transform(map); return map; } case QDBusArgument::StructureType: { value.beginStructure(); QVariantList list; while (!value.atEnd()) { list << value.asVariant(); } value.endStructure(); return list; break; } default: qDebug() << "Unhandled type" << value.currentType() << value.currentSignature(); } return QVariant(); } static void transform(QVariant &variant) { if (variant.canConvert()) { QVariantList list = variant.toList(); transform(list); variant = list; } else if (variant.canConvert()) { QDBusArgument value(variant.value()); variant = transform(value); } } static void transform(QVariantMap &map) { for (auto it(map.begin()); it != map.end(); ++it) { transform(*it); } } static void transform(QVariantList &list) { for (auto it(list.begin()); it != list.end(); ++it) { transform(*it); } } const QDBusArgument &operator>>(const QDBusArgument &argument, MethodCall &methodCall) { quint64 timestamp; QVariantList args; argument.beginStructure(); argument >> timestamp >> args; argument.endStructure(); transform(args); methodCall.setTimestamp(timestamp); methodCall.setArgs(args); return argument; } libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/config.h.in0000644000015300001610000000156312605720403024231 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #ifndef LIBQTDBUSMOCK_CONFIG_H_ #define LIBQTDBUSMOCK_CONFIG_H_ #define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@" #define LOCALE_DIR "@LOCALE_DIR@" #endif // LIBQTDBUSMOCK_CONFIG_H_ libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/ExportInterfaces.h0000644000015300001610000000222112605720403025634 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #ifndef LIBQTDBUSMOCK_EXPORTINTERFACES_H_ #define LIBQTDBUSMOCK_EXPORTINTERFACES_H_ #include class Q_DECL_EXPORT OrgFreedesktopDBusMockInterface; class Q_DECL_EXPORT NetworkManagerMockInterface; class Q_DECL_EXPORT OrgFreedesktopDBusPropertiesInterface; #include #include #include #endif /* LIBQTDBUSMOCK_EXPORTINTERFACES_H_ */ libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/DBusMock.cpp0000644000015300001610000002327512605720407024371 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #include #include #include #include using namespace QtDBusTest; namespace QtDBusMock { class DBusMockPrivate { public: DBusMockPrivate(DBusTestRunner &testRunner) : m_testRunner(testRunner) { } QtDBusTest::DBusTestRunner &m_testRunner; QScopedPointer m_networkManagerMock; QScopedPointer m_notificationDaemonMock; QScopedPointer m_ofonoInterface; QMap> m_ofonoModemInterface; QMap> m_ofonoSimManagerInterface; QMap> m_ofonoConnectionManagerInterface; QMap> m_ofonoNetworkRegistrationInterface; QScopedPointer m_urfkillInterface; QMap > m_urfkillKillSwitchInterfaces; QMap > m_mockInterfaces; }; DBusMock::DBusMock(DBusTestRunner &testRunner) : d(new DBusMockPrivate(testRunner)) { } DBusMock::~DBusMock() { } void DBusMock::registerMetaTypes() { Method::registerMetaType(); MethodCall::registerMetaType(); NamedMethodCall::registerMetaType(); } void DBusMock::registerTemplate(const QString &service, const QString &templateName, QDBusConnection::BusType busType) { registerTemplate(service, templateName, QVariantMap(), busType); } void DBusMock::registerTemplate(const QString &service, const QString &templateName, const QVariantMap& parameters, QDBusConnection::BusType busType) { QStringList arguments; arguments << "-m" << "dbusmock"; arguments << "--template" << templateName; if (!parameters.isEmpty()) { auto doc = QJsonDocument::fromVariant(parameters); arguments << "--parameters" << QString::fromUtf8(doc.toJson(QJsonDocument::Compact)); } d->m_testRunner.registerService( DBusServicePtr( new QProcessDBusService(service, busType, "python3", arguments))); } void DBusMock::registerBluez5(const QVariantMap& parameters) { registerTemplate("org.bluez", "bluez5", parameters, QDBusConnection::SystemBus); } void DBusMock::registerBluez4(const QVariantMap& parameters) { registerTemplate("org.bluez", "bluez4", parameters, QDBusConnection::SystemBus); } void DBusMock::registerGnomeScreensaver(const QVariantMap& parameters) { registerTemplate("org.gnome.ScreenSaver", "gnome_screensaver", parameters, QDBusConnection::SessionBus); } void DBusMock::registerLogind(const QVariantMap& parameters) { registerTemplate("org.freedesktop.login1", "logind", parameters, QDBusConnection::SystemBus); } void DBusMock::registerNetworkManager() { registerNetworkManager(QVariantMap()); } void DBusMock::registerNetworkManager(const QVariantMap& parameters) { registerTemplate(NM_DBUS_SERVICE, "networkmanager", parameters, QDBusConnection::SystemBus); } void DBusMock::registerNotificationDaemon() { registerNotificationDaemon(QVariantMap()); } void DBusMock::registerNotificationDaemon(const QVariantMap& parameters) { registerTemplate("org.freedesktop.Notifications", "notification_daemon", parameters, QDBusConnection::SessionBus); } void DBusMock::registerOfono() { registerOfono(QVariantMap()); } void DBusMock::registerOfono(const QVariantMap& parameters) { registerTemplate("org.ofono", "ofono", parameters, QDBusConnection::SystemBus); } void DBusMock::registerPolicyKit(const QVariantMap& parameters) { registerTemplate("org.freedesktop.PolicyKit1", "polkitd", parameters, QDBusConnection::SystemBus); } void DBusMock::registerTimeDate(const QVariantMap& parameters) { registerTemplate("org.freedesktop.timedate1", "timedated", parameters, QDBusConnection::SystemBus); } void DBusMock::registerURfkill() { registerURfkill(QVariantMap()); } void DBusMock::registerUpower(const QVariantMap& parameters) { registerTemplate("org.freedesktop.UPower", "upower", parameters, QDBusConnection::SystemBus); } void DBusMock::registerURfkill(const QVariantMap& parameters) { registerTemplate("org.freedesktop.URfkill", "urfkill", parameters, QDBusConnection::SystemBus); } void DBusMock::registerCustomMock(const QString &name, const QString &path, const QString &interface, QDBusConnection::BusType busType) { QStringList args; args << "-m" << "dbusmock"; if (busType == QDBusConnection::SystemBus) { args << "-s"; } args << name << path << interface; d->m_testRunner.registerService( DBusServicePtr( new QProcessDBusService(name, busType, "python3", args))); } NetworkManagerMockInterface & DBusMock::networkManagerInterface() { if (d->m_networkManagerMock.isNull()) { d->m_networkManagerMock.reset( new NetworkManagerMockInterface(NM_DBUS_INTERFACE, NM_DBUS_PATH, d->m_testRunner.systemConnection())); } return *d->m_networkManagerMock; } NotificationDaemonMockInterface & DBusMock::notificationDaemonInterface() { if (d->m_notificationDaemonMock.isNull()) { d->m_notificationDaemonMock.reset( new NotificationDaemonMockInterface("org.freedesktop.Notifications", "/org/freedesktop/Notifications", d->m_testRunner.sessionConnection())); } return *d->m_notificationDaemonMock; } OfonoMockInterface & DBusMock::ofonoInterface() { if (d->m_ofonoInterface.isNull()) { d->m_ofonoInterface.reset( new OfonoMockInterface("org.ofono", "/", d->m_testRunner.systemConnection())); } return *d->m_ofonoInterface; } OfonoModemInterface & DBusMock::ofonoModemInterface(const QString& path) { QSharedPointer interface = d->m_ofonoModemInterface[path]; if (!interface) { interface.reset( new OfonoModemInterface("org.ofono", path, d->m_testRunner.systemConnection())); d->m_ofonoModemInterface[path] = interface; } return *interface; } OfonoSimManagerInterface & DBusMock::ofonoSimManagerInterface(const QString& path) { QSharedPointer interface = d->m_ofonoSimManagerInterface[path]; if (!interface) { interface.reset( new OfonoSimManagerInterface("org.ofono", path, d->m_testRunner.systemConnection())); d->m_ofonoSimManagerInterface[path] = interface; } return *interface; } OfonoConnectionManagerInterface & DBusMock::ofonoConnectionManagerInterface(const QString& path) { QSharedPointer interface = d->m_ofonoConnectionManagerInterface[path]; if (!interface) { interface.reset( new OfonoConnectionManagerInterface("org.ofono", path, d->m_testRunner.systemConnection())); d->m_ofonoConnectionManagerInterface[path] = interface; } return *interface; } OfonoNetworkRegistrationInterface & DBusMock::ofonoNetworkRegistrationInterface(const QString& path) { QSharedPointer interface = d->m_ofonoNetworkRegistrationInterface[path]; if (!interface) { interface.reset( new OfonoNetworkRegistrationInterface("org.ofono", path, d->m_testRunner.systemConnection())); d->m_ofonoNetworkRegistrationInterface[path] = interface; } return *interface; } OrgFreedesktopURfkillInterface & DBusMock::urfkillInterface() { if (d->m_urfkillInterface.isNull()) { d->m_urfkillInterface.reset( new OrgFreedesktopURfkillInterface( "org.freedesktop.URfkill", "/org/freedesktop/URfkill", d->m_testRunner.systemConnection())); } return *d->m_urfkillInterface; } OrgFreedesktopURfkillKillswitchInterface & DBusMock::urfkillKillswitchInterface(const QString& device) { QSharedPointer interface = d->m_urfkillKillSwitchInterfaces[device]; if (!interface) { interface.reset( new OrgFreedesktopURfkillKillswitchInterface( "org.freedesktop.URfkill", QString("/org/freedesktop/URfkill/%1").arg(device), d->m_testRunner.systemConnection())); d->m_urfkillKillSwitchInterfaces[device] = interface; } return *interface; } OrgFreedesktopDBusMockInterface & DBusMock::mockInterface(const QString &name, const QString &path, const QString &interface, QDBusConnection::BusType busType) { Q_UNUSED(interface); QString id(name); id.append(':'); id.append(path); auto it(d->m_mockInterfaces.find(id)); if (it == d->m_mockInterfaces.end()) { switch (busType) { case QDBusConnection::SystemBus: it = d->m_mockInterfaces.insert(id, QSharedPointer( new OrgFreedesktopDBusMockInterface(name, path, d->m_testRunner.systemConnection()))); break; case QDBusConnection::SessionBus: it = d->m_mockInterfaces.insert(id, QSharedPointer( new OrgFreedesktopDBusMockInterface(name, path, d->m_testRunner.sessionConnection()))); break; case QDBusConnection::ActivationBus: qWarning() << "Unknown bus type"; break; } } return **it; } } libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/NamedMethodCall.cpp0000644000015300001610000000500412605720403025665 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #include using namespace QtDBusMock; NamedMethodCall::NamedMethodCall() : m_timestamp(0) { } NamedMethodCall::NamedMethodCall(const NamedMethodCall &other) : m_timestamp(other.m_timestamp), m_methodName(other.m_methodName), m_args( other.m_args) { } NamedMethodCall& NamedMethodCall::operator=(const NamedMethodCall &other) { m_timestamp = other.m_timestamp; m_methodName = other.m_methodName; m_args = other.m_args; return *this; } NamedMethodCall::~NamedMethodCall() { } void NamedMethodCall::registerMetaType() { qRegisterMetaType("QtDBusMock::NamedMethodCall"); qDBusRegisterMetaType(); qDBusRegisterMetaType>(); } const QString & NamedMethodCall::methodName() const { return m_methodName; } const quint64 & NamedMethodCall::timestamp() const { return m_timestamp; } const QVariantList & NamedMethodCall::args() const { return m_args; } void NamedMethodCall::setMethodName(const QString &methodName) { m_methodName = methodName; } void NamedMethodCall::setTimestamp(quint64 timestamp) { m_timestamp = timestamp; } void NamedMethodCall::setArgs(const QVariantList &args) { m_args = args; } QDBusArgument &operator<<(QDBusArgument &argument, const NamedMethodCall& methodCall) { argument.beginStructure(); argument << methodCall.timestamp() << methodCall.methodName() << methodCall.args(); argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, NamedMethodCall &methodCall) { quint64 timestamp; QString methodName; QVariantList args; argument.beginStructure(); argument >> timestamp >> methodName >> args; argument.endStructure(); methodCall.setTimestamp(timestamp); methodCall.setMethodName(methodName); methodCall.setArgs(args); return argument; } libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/MockInterfaceClasses.h0000644000015300001610000000154112605720403026403 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #include #include #include #include libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/MethodCall.h0000644000015300001610000000303112605720403024363 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #ifndef LIBQTDBUSMOCK_METHODCALLS_H_ #define LIBQTDBUSMOCK_METHODCALLS_H_ #include namespace QtDBusMock { class Q_DECL_EXPORT MethodCall { public: explicit MethodCall(); MethodCall(const MethodCall &other); MethodCall& operator=(const MethodCall &other); ~MethodCall(); static void registerMetaType(); const quint64 & timestamp() const; const QVariantList & args() const; void setTimestamp(quint64 timestamp); void setArgs(const QVariantList &args); protected: quint64 m_timestamp; QVariantList m_args; }; } Q_DECL_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const QtDBusMock::MethodCall &methodCalls); Q_DECL_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, QtDBusMock::MethodCall &methodCalls); Q_DECLARE_METATYPE(QtDBusMock::MethodCall) #endif // LIBQTDBUSMOCK_METHODCALLS_H_ libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/DBusMock.h0000644000015300001610000001000312605720407024017 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #ifndef QTDBUSMOCK_DBUSMOCK_H_ #define QTDBUSMOCK_DBUSMOCK_H_ #include #include #include #include #include #include #include #include #include #include #include #include namespace QtDBusMock { class DBusMockPrivate; class Q_DECL_EXPORT DBusMock { public: DBusMock(QtDBusTest::DBusTestRunner &testRunner); virtual ~DBusMock(); Q_DECL_EXPORT static void registerMetaTypes(); virtual void registerTemplate(const QString &service, const QString &templateName, QDBusConnection::BusType busType); virtual void registerTemplate(const QString &service, const QString &templateName, const QVariantMap& parameters, QDBusConnection::BusType busType); virtual void registerBluez4(const QVariantMap& parameters = QVariantMap()); virtual void registerBluez5(const QVariantMap& parameters = QVariantMap()); virtual void registerGnomeScreensaver(const QVariantMap& parameters = QVariantMap()); virtual void registerLogind(const QVariantMap& parameters = QVariantMap()); virtual void registerNetworkManager(); virtual void registerNetworkManager(const QVariantMap& parameters); virtual void registerNotificationDaemon(); virtual void registerNotificationDaemon(const QVariantMap& parameters); virtual void registerOfono(); virtual void registerOfono(const QVariantMap& parameters); virtual void registerPolicyKit(const QVariantMap& parameters = QVariantMap()); virtual void registerTimeDate(const QVariantMap& parameters = QVariantMap()); virtual void registerURfkill(); virtual void registerURfkill(const QVariantMap& parameters); virtual void registerUpower(const QVariantMap& parameters = QVariantMap()); virtual void registerCustomMock(const QString &name, const QString &path, const QString &interface, QDBusConnection::BusType); virtual NetworkManagerMockInterface & networkManagerInterface(); virtual NotificationDaemonMockInterface & notificationDaemonInterface(); virtual OrgFreedesktopDBusMockInterface & mockInterface(const QString &name, const QString &path, const QString &interface, QDBusConnection::BusType busType); virtual OfonoMockInterface & ofonoInterface(); virtual OfonoModemInterface & ofonoModemInterface(const QString &path); virtual OfonoSimManagerInterface & ofonoSimManagerInterface(const QString &path); virtual OfonoConnectionManagerInterface & ofonoConnectionManagerInterface(const QString &path); virtual OfonoNetworkRegistrationInterface & ofonoNetworkRegistrationInterface(const QString &path); virtual OrgFreedesktopURfkillInterface & urfkillInterface(); virtual OrgFreedesktopURfkillKillswitchInterface & urfkillKillswitchInterface(const QString& device); private: QSharedPointer d; }; } #endif /* QTDBUSMOCK_DBUSMOCK_H_ */ libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/Method.h0000644000015300001610000000316612605720403023600 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #ifndef LIBQTDBUSMOCK_METHOD_H_ #define LIBQTDBUSMOCK_METHOD_H_ #include namespace QtDBusMock { class Q_DECL_EXPORT Method { public: explicit Method(); Method(const Method &other); Method& operator=(const Method &other); ~Method(); static void registerMetaType(); const QString & name() const; const QString & inSig() const; const QString & outSig() const; const QString & code() const; void setName(const QString &name); void setInSig(const QString &inSig); void setOutSig(const QString &outSig); void setCode(const QString &code); protected: QString m_name; QString m_inSig; QString m_outSig; QString m_code; }; } Q_DECL_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const QtDBusMock::Method &method); Q_DECL_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, QtDBusMock::Method &method); Q_DECLARE_METATYPE(QtDBusMock::Method) #endif // LIBQTDBUSMOCK_METHOD_H_ libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/Method.cpp0000644000015300001610000000452712605720403024135 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #include using namespace QtDBusMock; Method::Method() { } Method::Method(const Method &other) : m_name(other.m_name), m_inSig(other.m_inSig), m_outSig(other.m_outSig), m_code( other.m_code) { } Method& Method::operator=(const Method &other) { m_name = other.m_name; m_inSig = other.m_inSig; m_outSig = other.m_outSig; m_code = other.m_code; return *this; } Method::~Method() { } void Method::registerMetaType() { qRegisterMetaType("QtDBusMock::Method"); qDBusRegisterMetaType(); qDBusRegisterMetaType>(); } const QString & Method::name() const { return m_name; } void Method::setName(const QString &name) { m_name = name; } const QString & Method::inSig() const { return m_inSig; } void Method::setInSig(const QString &inSig) { m_inSig = inSig; } const QString & Method::outSig() const { return m_outSig; } void Method::setOutSig(const QString &outSig) { m_outSig = outSig; } const QString & Method::code() const { return m_code; } void Method::setCode(const QString &code) { m_code = code; } QDBusArgument &operator<<(QDBusArgument &argument, const Method& method) { argument.beginStructure(); argument << method.name() << method.inSig() << method.outSig() << method.code(); argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, Method &method) { QString name; QString inSig; QString outSig; QString code; argument.beginStructure(); argument >> name >> inSig >> outSig >> code; argument.endStructure(); method.setName(name); method.setInSig(inSig); method.setOutSig(outSig); method.setCode(code); return argument; } libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/CMakeLists.txt0000644000015300001610000001157312605720403024750 0ustar pbuserpbgroup00000000000000 set( QTDBUSMOCK_SRC DBusMock.cpp Method.cpp MethodCall.cpp NamedMethodCall.cpp ) set( QTDBUSMOCK_PUBLIC_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/config.h" DBusMock.h ExportInterfaces.h Method.h MethodCall.h MockInterfaceClasses.h NamedMethodCall.h "${CMAKE_CURRENT_BINARY_DIR}/MockInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/PropertiesInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/NetworkManagerMockInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/NotificationDaemonMockInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/OfonoMockInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/OfonoModemInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/OfonoConnectionManagerInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/OfonoSimManagerInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/OfonoNetworkRegistrationInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/URfkillInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/URfkillDeviceInterface.h" "${CMAKE_CURRENT_BINARY_DIR}/URfkillKillswitchInterface.h" ) set_source_files_properties( "${DATA_DIR}/org.freedesktop.DBus.Mock.xml" PROPERTIES NO_NAMESPACE YES INCLUDE "libqtdbusmock/MockInterfaceClasses.h" ) set_source_files_properties( "${DATA_DIR}/org.freedesktop.DBus.Properties.xml" PROPERTIES NO_NAMESPACE YES INCLUDE "libqtdbusmock/ExportInterfaces.h" ) set_source_files_properties( "${DATA_DIR}/nm-manager-mock.xml" PROPERTIES NO_NAMESPACE YES CLASSNAME NetworkManagerMockInterface INCLUDE "libqtdbusmock/ExportInterfaces.h" ) set_source_files_properties( "${DATA_DIR}/notification-daemon-mock.xml" PROPERTIES NO_NAMESPACE YES CLASSNAME NotificationDaemonMockInterface ) set_source_files_properties( "${DATA_DIR}/ofono-mock.xml" PROPERTIES NO_NAMESPACE YES CLASSNAME OfonoMockInterface ) set_source_files_properties( "${DATA_DIR}/ofono-modem-mock.xml" PROPERTIES NO_NAMESPACE YES CLASSNAME OfonoModemInterface ) set_source_files_properties( "${DATA_DIR}/ofono-simmanager.xml" PROPERTIES NO_NAMESPACE YES CLASSNAME OfonoSimManagerInterface ) set_source_files_properties( "${DATA_DIR}/ofono-connectionmanager.xml" PROPERTIES NO_NAMESPACE YES CLASSNAME OfonoConnectionManagerInterface ) set_source_files_properties( "${DATA_DIR}/ofono-networkregistration.xml" PROPERTIES NO_NAMESPACE YES CLASSNAME OfonoNetworkRegistrationInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/org.freedesktop.DBus.Mock.xml" MockInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/org.freedesktop.DBus.Properties.xml" PropertiesInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/nm-manager-mock.xml" NetworkManagerMockInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/notification-daemon-mock.xml" NotificationDaemonMockInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/ofono-mock.xml" OfonoMockInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/ofono-modem-mock.xml" OfonoModemInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/ofono-connectionmanager.xml" OfonoConnectionManagerInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/ofono-simmanager.xml" OfonoSimManagerInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/ofono-networkregistration.xml" OfonoNetworkRegistrationInterface ) set_source_files_properties( "${DATA_DIR}/org.freedesktop.URfkill.xml" PROPERTIES NO_NAMESPACE YES ) set_source_files_properties( "${DATA_DIR}/org.freedesktop.URfkill.Device.xml" PROPERTIES NO_NAMESPACE YES ) set_source_files_properties( "${DATA_DIR}/org.freedesktop.URfkill.Killswitch.xml" PROPERTIES NO_NAMESPACE YES ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/org.freedesktop.URfkill.xml" URfkillInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/org.freedesktop.URfkill.Device.xml" URfkillDeviceInterface ) qt5_add_dbus_interface( QTDBUSMOCK_SRC "${DATA_DIR}/org.freedesktop.URfkill.Killswitch.xml" URfkillKillswitchInterface ) add_library( qtdbusmock SHARED ${QTDBUSMOCK_SRC} ) qt5_use_modules( qtdbusmock Core DBus Test ) target_link_libraries( qtdbusmock ${QTDBUSTEST_LIBRARIES} ) set_target_properties( qtdbusmock PROPERTIES VERSION ${API_VERSION}.0.0 SOVERSION ${ABI_VERSION} PUBLIC_HEADER "${QTDBUSMOCK_PUBLIC_HEADERS}" ) install( TARGETS qtdbusmock LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libqtdbusmock-${API_VERSION}/libqtdbusmock" ) # Package config set(LIBQTDBUSMOCK_PC "${CMAKE_CURRENT_BINARY_DIR}/libqtdbusmock-${API_VERSION}.pc") configure_file("libqtdbusmock.pc.in" "${LIBQTDBUSMOCK_PC}" @ONLY) install( FILES "${LIBQTDBUSMOCK_PC}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" ) libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/NamedMethodCall.h0000644000015300001610000000330612605720403025335 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This library is free software; you can redistribute it and/or modify it under * the terms of version 3 of the GNU Lesser General Public License 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 program. If not, see . * * Author: Pete Woods */ #ifndef LIBQTDBUSMOCK_NAMEDMETHODCALL_H_ #define LIBQTDBUSMOCK_NAMEDMETHODCALL_H_ #include namespace QtDBusMock { class Q_DECL_EXPORT NamedMethodCall { public: explicit NamedMethodCall(); NamedMethodCall(const NamedMethodCall &other); NamedMethodCall& operator=(const NamedMethodCall &other); ~NamedMethodCall(); static void registerMetaType(); const QString & methodName() const; void setMethodName(const QString &methodName); const quint64 & timestamp() const; const QVariantList & args() const; void setTimestamp(quint64 timestamp); void setArgs(const QVariantList &args); protected: quint64 m_timestamp; QString m_methodName; QVariantList m_args; }; } Q_DECL_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const QtDBusMock::NamedMethodCall &methodCalls); Q_DECL_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, QtDBusMock::NamedMethodCall &methodCalls); Q_DECLARE_METATYPE(QtDBusMock::NamedMethodCall) #endif // LIBQTDBUSMOCK_NAMEDMETHODCALL_H_ libqtdbusmock-0.5+15.10.20151009/src/CMakeLists.txt0000644000015300001610000000013212605720403022072 0ustar pbuserpbgroup00000000000000include(GenerateExportHeader) add_compiler_export_flags() add_subdirectory(libqtdbusmock)libqtdbusmock-0.5+15.10.20151009/CMakeLists.txt0000644000015300001610000000367712605720403021324 0ustar pbuserpbgroup00000000000000project(libqtdbusmock CXX) cmake_minimum_required(VERSION 2.8.9) set(API_VERSION 1) set(ABI_VERSION 1) set(GETTEXT_PACKAGE libqtdbusmock) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") find_package(PkgConfig REQUIRED) find_package(Qt5Core REQUIRED) include_directories(${Qt5Core_INCLUDE_DIRS}) find_package(Qt5DBus COMPONENTS Qt5DBusMacros REQUIRED) include_directories(${Qt5DBus_INCLUDE_DIRS}) find_package(Qt5Test REQUIRED) include_directories(${Qt5Test_INCLUDE_DIRS}) pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1 REQUIRED) include_directories(${QTDBUSTEST_INCLUDE_DIRS}) pkg_check_modules(NM REQUIRED NetworkManager REQUIRED) include_directories(${NM_INCLUDE_DIRS}) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(DATA_DIR "${CMAKE_SOURCE_DIR}/data") set(SOURCE_DIR "${CMAKE_SOURCE_DIR}/src") set(SOURCE_BINARY_DIR "${CMAKE_BINARY_DIR}/src") include_directories(${SOURCE_DIR}) include_directories(${SOURCE_BINARY_DIR}) include(GNUInstallDirs) include(Coverage) # Workaround for libexecdir on debian if (EXISTS "/etc/debian_version") set(CMAKE_INSTALL_LIBEXECDIR ${CMAKE_INSTALL_LIBDIR}) set(CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}") endif() set(LOCALE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/locale") add_definitions( -std=c++11 -fno-permissive -pedantic -Wall -Wextra ) #set(DOXYFILE_SOURCE_DIR "include") #set(DOXYFILE_EXTRA_SOURCES "doc") #include(UseDoxygen) #if(DOXYGEN_FOUND AND BUILD_DOXYGEN) # install( # DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html # DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/libusermetrics-doc/ # ) #endif() configure_file( "${SOURCE_DIR}/libqtdbusmock/config.h.in" "${SOURCE_BINARY_DIR}/libqtdbusmock/config.h" ) #add_subdirectory("po") add_subdirectory("src") add_subdirectory("data") enable_testing() add_subdirectory(tests) ADD_CUSTOM_TARGET( check ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure ) libqtdbusmock-0.5+15.10.20151009/build.sh0000755000015300001610000000267412605720403020216 0ustar pbuserpbgroup00000000000000#! /bin/bash set -e ECLIPSE=false CLEAN=false SOURCEDIR="$PWD" BRANCHNAME=`basename $SOURCEDIR` BUILDDIR="$SOURCEDIR/../$BRANCHNAME-build" usage() { echo "usage: $0 [OPTIONS] [BUILD_TYPE]\n" >&2 echo "Script to build libqtdbusmock. If BUILD_TYPE is not specified, it defaults to \"Debug\".\n" >&2 echo "OPTIONS:" >&2 echo " -e, --eclipse Generate Eclipse projects" >&2 echo " -c, --clean Clean the build tree before building" >&2 echo >&2 exit 1 } ARGS=`getopt -n$0 -u -a --longoptions="eclipse,clean,help" -o "sch" -- "$@"` [ $? -ne 0 ] && usage eval set -- "$ARGS" while [ $# -gt 0 ] do case "$1" in -e|--eclipse) ECLIPSE=true;; -c|--clean) CLEAN=true;; -h|--help) usage;; --) shift;break;; esac shift done [ $# -gt 1 ] && usage BUILD_TYPE="Debug" [ $# -eq 1 ] && BUILD_TYPE="$1" if [ -f "/usr/bin/ninja" ] ; then if $ECLIPSE; then GENERATOR="Eclipse CDT4 - Ninja" else GENERATOR="Ninja" fi BUILD_COMMAND="ninja" else if $ECLIPSE; then GENERATOR="Eclipse CDT4 - Unix Makefiles" else GENERATOR="Unix Makefiles" fi BUILD_COMMAND="make" fi echo "Using $BUILD_COMMAND to build" if $CLEAN; then rm -rf $BUILDDIR fi mkdir -p $BUILDDIR ( cd $BUILDDIR cmake "$SOURCEDIR" -G "$GENERATOR" \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DENABLE_MEMCHECK_OPTION=YES \ -DCMAKE_INSTALL_PREFIX="$SOURCEDIR/../$BRANCHNAME-install" $BUILD_COMMAND ) libqtdbusmock-0.5+15.10.20151009/data/0000755000015300001610000000000012605720601017460 5ustar pbuserpbgroup00000000000000libqtdbusmock-0.5+15.10.20151009/data/ofono-modem-mock.xml0000644000015300001610000000110412605720403023344 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/org.freedesktop.DBus.Mock.xml0000644000015300001610000000545212605720403025035 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/ofono-simmanager.xml0000644000015300001610000000301712605720403023444 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/ofono-mock.xml0000644000015300001610000000061612605720403022254 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/ofono-networkregistration.xml0000644000015300001610000000215412605720403025446 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/nm-manager-mock.xml0000644000015300001610000000606212605720403023157 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/org.freedesktop.URfkill.Killswitch.xml0000644000015300001610000000544312605720403026774 0ustar pbuserpbgroup00000000000000 Objects implementing this interface represent different types of killswitches and are discovered through the org.freedesktop.URfkill.Killswitch interface on the /org/freedesktop/URfkill/TYPENAME object on the D-Bus system bus service with the well-known name org.freedesktop.URfkill. The TYPENAME could be "WLAN", "BLUETOOTH", "UWB", "WIMAX", "WWAN", "GPS", "FM", or "NFC". $ gdbus call -y \ -d org.freedesktop.URfkill \ -o /org/freedesktop/URfkill/WLAN \ -m org.freedesktop.DBus.Properties.GetAll \ "org.freedesktop.URfkill.Killswitch" ({'state': <2>},) Emitted when the state of the killswitch changed. Note: This signal is deprecated since 0.4.0. Use the standard signal, PropertiesChanged from org.freedesktop.DBus.Properties instead. The state of the killswitch -1killswitch is not available. 0killswitch is unblocked. 1killswitch is soft-blocked. 2killswitch is hard-blocked. libqtdbusmock-0.5+15.10.20151009/data/ofono-connectionmanager.xml0000644000015300001610000000112012605720403025004 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/org.freedesktop.URfkill.xml0000644000015300001610000002757412605720403024671 0ustar pbuserpbgroup00000000000000 The urfkill service is available via the system message bus. To access the service, use the org.freedesktop.URfkill interface on the /org/freedesktop/URfkill object on the D-Bus system bus service with the well-known name org.freedesktop.URfkill. $ gdbus call -y \ -d org.freedesktop.URfkill \ -o /org/freedesktop/URfkill \ -m org.freedesktop.URfkill.EnumerateDevices ([objectpath '/org/freedesktop/URfkill/devices/0', '/org/freedesktop/URfkill/devices/1'],) The type of devices to be blocked/unblocked TRUE to block the devices, FALSE to unblock TRUE for success, otherwise FALSE Block or unblock the devices belonging to the type. The types are defined as the followings: 0All 1WLAN 2Bluetooth 3UWB 4WIMAX 5WWAN 6GPS 7FM Note: This method only changes soft block. Hard block is controlled by BIOS or the hardware and there is no way to change the state of hard block through kernel functions. This method is restricted to the active session user. The index of the device to be blocked/unblocked TRUE to block the device, FALSE to unblock TRUE for success, otherwise FALSE Block or unblock the device by the index. Note: This method only changes soft block. Hard block is controlled by BIOS or the hardware and there is no way to change the state of hard block through kernel functions. This method is restricted to the currently active session user. An array of the object pathes for the devices Enumerate all rfkill objects on the system. TRUE of flight mode should be enabled, otherwise FALSE TRUE if successful, otherwise FALSE Enable or disable flight mode. TRUE if flight mode is enabled, otherwise FALSE Get whether flight mode is enabled or not. TRUE if the key control is inhibited, otherwise FALSE Get whether the rfkill key handling function is inhibited or not. The reason to inhibit the key control The cookie Inhibit the rfkill key handling function for the session. The cookie Cancel a previous call to Inhibit() identified by the cookie. The object path for the device that was added Emitted when a device is added. The object path for the device that was removed Emitted when a device is removed. The object path for the device that was changed Emitted when a device is changed. TRUE if flight mode has been enabled, otherwise FALSE Emitted when flight mode is enabled or disabled. The keycode emitted from the input device Emitted when a rfkill key is pressed. The keycode is defined in <linux/input.h>. 237KEY_BLUETOOTH 238KEY_WLAN 239KEY_UWB 246KEY_WIMAX 247KEY_RFKILL The version the running daemon. e.g. 0.2.0 Whether the key control is enabled or not libqtdbusmock-0.5+15.10.20151009/data/org.freedesktop.URfkill.Device.xml0000644000015300001610000001076612605720403026062 0ustar pbuserpbgroup00000000000000 Objects implementing this interface are usually discovered through the org.freedesktop.URfkill interface on the /org/freedesktop/URfkill object on the D-Bus system bus service with the well-known name org.freedesktop.URfkill using the EnumerateDevices method. $ gdbus call -y \ -d org.freedesktop.URfkill \ -o /org/freedesktop/URfkill/devices/0 \ -m org.freedesktop.DBus.Properties.GetAll \ "org.freedesktop.URfkill.Device" ({'index': <uint32 0>, 'type': <uint32 2>, 'name': <'tpacpi_bluetooth_sw'>, 'soft': <true>, 'hard': <true>, 'platform': <true>},) Emitted when a property of the device is changed. Note: This signal is deprecated since 0.4.0. Use the standard signal, PropertiesChanged from org.freedesktop.DBus.Properties instead. The index of the rfkill device The type of the rfkill device 0All 1WLAN 2Bluetooth 3UWB 4WIMAX 5WWAN 6GPS 7FM 8NFC The name of the rfkill device Whether the soft block of the device is on or not Whether the hard block of the device is on or not Whether the device is generated by a platform driver or not libqtdbusmock-0.5+15.10.20151009/data/notification-daemon-mock.xml0000644000015300001610000000246312605720403025065 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/org.freedesktop.DBus.Properties.xml0000644000015300001610000000202312605720403026267 0ustar pbuserpbgroup00000000000000 libqtdbusmock-0.5+15.10.20151009/data/CMakeLists.txt0000644000015300001610000000000012605720403022206 0ustar pbuserpbgroup00000000000000