libqtdbusmock-0.5+15.10.20151009/ 0000755 0000153 0000161 00000000000 12605720601 016547 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/cmake/ 0000755 0000153 0000161 00000000000 12605720601 017627 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/cmake/COPYING-CMAKE-SCRIPTS 0000644 0000153 0000161 00000002457 12605720403 022635 0 ustar pbuser pbgroup 0000000 0000000 Redistribution 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.cmake 0000644 0000153 0000161 00000001402 12605720403 023175 0 ustar pbuser pbgroup 0000000 0000000
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.cmake 0000644 0000153 0000161 00000000766 12605720403 022443 0 ustar pbuser pbgroup 0000000 0000000 # 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.cmake 0000644 0000153 0000161 00000004226 12605720403 022370 0 ustar pbuser pbgroup 0000000 0000000 if (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/COPYING 0000644 0000153 0000161 00000016727 12605720403 017617 0 ustar pbuser pbgroup 0000000 0000000 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/ 0000755 0000153 0000161 00000000000 12605720601 017711 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/tests/libqtdbusmock/ 0000755 0000153 0000161 00000000000 12605720601 022554 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/tests/libqtdbusmock/TestDBusMock.cpp 0000644 0000153 0000161 00000020524 12605720407 025576 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.cpp 0000644 0000153 0000161 00000002346 12605720403 021346 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.txt 0000644 0000153 0000161 00000001063 12605720403 022451 0 ustar pbuser pbgroup 0000000 0000000
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/ 0000755 0000153 0000161 00000000000 12605720601 020622 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/tests/data/valgrind.suppression 0000644 0000153 0000161 00000001544 12605720403 024750 0 ustar pbuser pbgroup 0000000 0000000 {
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/ 0000755 0000153 0000161 00000000000 12605720601 017336 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/ 0000755 0000153 0000161 00000000000 12605720601 022201 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/src/libqtdbusmock/libqtdbusmock.pc.in 0000644 0000153 0000161 00000000472 12605720403 026000 0 ustar pbuser pbgroup 0000000 0000000 libdir=@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.cpp 0000644 0000153 0000161 00000006516 12605720403 024731 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.in 0000644 0000153 0000161 00000001563 12605720403 024231 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.h 0000644 0000153 0000161 00000002221 12605720403 025634 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.cpp 0000644 0000153 0000161 00000023275 12605720407 024371 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.cpp 0000644 0000153 0000161 00000005004 12605720403 025665 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.h 0000644 0000153 0000161 00000001541 12605720403 026403 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.h 0000644 0000153 0000161 00000003031 12605720403 024363 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.h 0000644 0000153 0000161 00000010003 12605720407 024017 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.h 0000644 0000153 0000161 00000003166 12605720403 023600 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.cpp 0000644 0000153 0000161 00000004527 12605720403 024135 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.txt 0000644 0000153 0000161 00000011573 12605720403 024750 0 ustar pbuser pbgroup 0000000 0000000
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.h 0000644 0000153 0000161 00000003306 12605720403 025335 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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.txt 0000644 0000153 0000161 00000000132 12605720403 022072 0 ustar pbuser pbgroup 0000000 0000000 include(GenerateExportHeader)
add_compiler_export_flags()
add_subdirectory(libqtdbusmock) libqtdbusmock-0.5+15.10.20151009/CMakeLists.txt 0000644 0000153 0000161 00000003677 12605720403 021324 0 ustar pbuser pbgroup 0000000 0000000 project(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.sh 0000755 0000153 0000161 00000002674 12605720403 020216 0 ustar pbuser pbgroup 0000000 0000000 #! /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/ 0000755 0000153 0000161 00000000000 12605720601 017460 5 ustar pbuser pbgroup 0000000 0000000 libqtdbusmock-0.5+15.10.20151009/data/ofono-modem-mock.xml 0000644 0000153 0000161 00000001104 12605720403 023344 0 ustar pbuser pbgroup 0000000 0000000
libqtdbusmock-0.5+15.10.20151009/data/org.freedesktop.DBus.Mock.xml 0000644 0000153 0000161 00000005452 12605720403 025035 0 ustar pbuser pbgroup 0000000 0000000
libqtdbusmock-0.5+15.10.20151009/data/ofono-simmanager.xml 0000644 0000153 0000161 00000003017 12605720403 023444 0 ustar pbuser pbgroup 0000000 0000000
libqtdbusmock-0.5+15.10.20151009/data/ofono-mock.xml 0000644 0000153 0000161 00000000616 12605720403 022254 0 ustar pbuser pbgroup 0000000 0000000