aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt50
-rw-r--r--tests/unit/adbd-client-test.cpp (renamed from tests/adbd-client-test.cpp)4
-rw-r--r--tests/unit/rotation-lock-test.cpp (renamed from tests/rotation-lock-test.cpp)2
-rw-r--r--tests/unit/usb-snap-test.cpp (renamed from tests/usb-snap-test.cpp)4
-rw-r--r--tests/utils/adbd-server.h (renamed from tests/adbd-server.h)0
-rw-r--r--tests/utils/dbus-types.h (renamed from tests/dbus-types.h)0
-rw-r--r--tests/utils/glib-fixture.h (renamed from tests/glib-fixture.h)0
-rw-r--r--tests/utils/qmain.cpp60
-rw-r--r--tests/utils/test-dbus-fixture.h (renamed from tests/test-dbus-fixture.h)0
9 files changed, 77 insertions, 43 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1fbe407..205792e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,57 +1,31 @@
-
set(CMAKE_AUTOMOC ON)
-
find_package(GMock REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Test REQUIRED)
find_package(Qt5DBus COMPONENTS Qt5DBusMacros REQUIRED)
pkg_check_modules(TEST_DEPS
- libqtdbustest-1 REQUIRED
- libqtdbusmock-1 REQUIRED
+ libqtdbustest-1 REQUIRED
+ libqtdbusmock-1 REQUIRED
)
-include_directories(
- ${CMAKE_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
include_directories(SYSTEM
- ${DBUSTEST_INCLUDE_DIRS}
- ${TEST_DEPS_INCLUDE_DIRS}
- ${GTEST_INCLUDE_DIRS}
- ${GMOCK_INCLUDE_DIRS}
+ ${DBUSTEST_INCLUDE_DIRS}
+ ${TEST_DEPS_INCLUDE_DIRS}
+ ${GTEST_INCLUDE_DIRS}
+ ${GMOCK_INCLUDE_DIRS}
)
set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};G_MESSAGES_DEBUG=all")
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- # turn off the warnings that break Google Test
- set (CXX_WARNING_ARGS "${CXX_WARNING_ARGS} -Wno-global-constructors -Wno-weak-vtables")
+# turn off the warnings that break Google Test
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(CXX_WARNING_ARGS "${CXX_WARNING_ARGS} -Wno-global-constructors -Wno-weak-vtables")
endif()
-SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11 -g ${CXX_WARNING_ARGS}")
-
-function(add_test_by_name name)
- set (TEST_NAME ${name})
- add_executable (${TEST_NAME} ${TEST_NAME}.cpp)
- add_test (${TEST_NAME} ${TEST_NAME})
- set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}")
- add_dependencies (${TEST_NAME} indicatordisplayservice)
- target_link_libraries (${TEST_NAME} indicatordisplayservice ${SERVICE_DEPS_LIBRARIES} ${TEST_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
-endfunction()
-add_test_by_name(rotation-lock-test)
-add_test_by_name(adbd-client-test)
-
-function(add_qt_test_by_name name)
- set (TEST_NAME ${name})
- add_executable (${TEST_NAME} ${TEST_NAME}.cpp qmain.cpp)
- add_test (${TEST_NAME} ${TEST_NAME})
- set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}")
- add_dependencies (${TEST_NAME} indicatordisplayservice)
- target_link_libraries (${TEST_NAME} indicatordisplayservice ${SERVICE_DEPS_LIBRARIES} Qt5::Core Qt5::Test Qt5::DBus ${TEST_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
-endfunction()
-add_qt_test_by_name(usb-snap-test)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNING_ARGS}")
add_test(cppcheck cppcheck --enable=all -USCHEMA_DIR --error-exitcode=2 --inline-suppr -I${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
+add_subdirectory(unit)
+add_subdirectory(utils)
diff --git a/tests/adbd-client-test.cpp b/tests/unit/adbd-client-test.cpp
index ae0378b..1e28cc9 100644
--- a/tests/adbd-client-test.cpp
+++ b/tests/unit/adbd-client-test.cpp
@@ -17,8 +17,8 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
-#include <tests/test-dbus-fixture.h>
-#include <tests/adbd-server.h>
+#include <tests/utils/test-dbus-fixture.h>
+#include <tests/utils/adbd-server.h>
#include <src/adbd-client.h>
diff --git a/tests/rotation-lock-test.cpp b/tests/unit/rotation-lock-test.cpp
index b8661cc..b9630b5 100644
--- a/tests/rotation-lock-test.cpp
+++ b/tests/unit/rotation-lock-test.cpp
@@ -17,7 +17,7 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
-#include "test-dbus-fixture.h"
+#include <tests/utils/test-dbus-fixture.h>
#include <src/rotation-lock.h>
diff --git a/tests/usb-snap-test.cpp b/tests/unit/usb-snap-test.cpp
index 309980a..70c9d97 100644
--- a/tests/usb-snap-test.cpp
+++ b/tests/unit/usb-snap-test.cpp
@@ -18,8 +18,8 @@
*/
#define QT_NO_KEYWORDS
-#include <tests/dbus-types.h>
-#include <tests/glib-fixture.h>
+#include <tests/utils/dbus-types.h>
+#include <tests/utils/glib-fixture.h>
#include <src/usb-snap.h>
diff --git a/tests/adbd-server.h b/tests/utils/adbd-server.h
index 740faaa..740faaa 100644
--- a/tests/adbd-server.h
+++ b/tests/utils/adbd-server.h
diff --git a/tests/dbus-types.h b/tests/utils/dbus-types.h
index c2dfb81..c2dfb81 100644
--- a/tests/dbus-types.h
+++ b/tests/utils/dbus-types.h
diff --git a/tests/glib-fixture.h b/tests/utils/glib-fixture.h
index ccdeccd..ccdeccd 100644
--- a/tests/glib-fixture.h
+++ b/tests/utils/glib-fixture.h
diff --git a/tests/utils/qmain.cpp b/tests/utils/qmain.cpp
new file mode 100644
index 0000000..72a49b1
--- /dev/null
+++ b/tests/utils/qmain.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2014 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Pete Woods <pete.woods@canonical.com>
+ */
+
+//#include <config.h>
+
+#include <QCoreApplication>
+#include <QTimer>
+#include <gtest/gtest.h>
+
+#include <libqtdbusmock/DBusMock.h>
+
+using namespace QtDBusMock;
+
+class Runner: public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void run()
+ {
+ QCoreApplication::exit(RUN_ALL_TESTS());
+ }
+};
+
+int main(int argc, char **argv)
+{
+ qputenv("LANG", "C.UTF-8");
+ unsetenv("LC_ALL");
+
+ // boilerplate i18n
+ setlocale(LC_ALL, "");
+ bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain(GETTEXT_PACKAGE);
+
+ QCoreApplication application(argc, argv);
+ DBusMock::registerMetaTypes();
+ ::testing::InitGoogleTest(&argc, argv);
+
+ Runner runner;
+ QTimer::singleShot(0, &runner, SLOT(run()));
+
+ return application.exec();
+}
+
+#include "qmain.moc"
diff --git a/tests/test-dbus-fixture.h b/tests/utils/test-dbus-fixture.h
index 3947e58..3947e58 100644
--- a/tests/test-dbus-fixture.h
+++ b/tests/utils/test-dbus-fixture.h