From 681ff5542ca4d2405d19ddd9809b0a8cf2d697e8 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 20 Aug 2015 15:25:22 +0200 Subject: QTestLib integration In order to work with the new CI system, we need to link with testlib. Change-Id: I285d651c2e1189a79153a6d942c10522305f2f3c Reviewed-by: Paul Olav Tvete --- tests/mirserver/Clipboard/Clipboard.pro | 2 +- tests/mirserver/QtEventFeeder/QtEventFeeder.pro | 2 +- tests/mirserver/Screen/Screen.pro | 2 +- tests/modules/Application/Application.pro | 2 +- .../ApplicationManager/ApplicationManager.pro | 2 +- .../DesktopFileReader/DesktopFileReader.pro | 2 +- tests/modules/General/General.pro | 2 +- tests/modules/MirSurfaceItem/MirSurfaceItem.pro | 2 +- tests/modules/SessionManager/SessionManager.pro | 2 +- tests/modules/SharedWakelock/SharedWakelock.pro | 6 ++++- tests/modules/TaskController/TaskController.pro | 2 +- tests/modules/common/common.pri | 2 +- tests/testcommon.pri | 8 ++++++- tests/testlibs/testmain.cpp | 26 +++++++++++++++++++++- 14 files changed, 48 insertions(+), 14 deletions(-) diff --git a/tests/mirserver/Clipboard/Clipboard.pro b/tests/mirserver/Clipboard/Clipboard.pro index 2d74ef1..1b9642d 100644 --- a/tests/mirserver/Clipboard/Clipboard.pro +++ b/tests/mirserver/Clipboard/Clipboard.pro @@ -1,4 +1,4 @@ -TARGET = clipboard_test +TESTNAME = clipboard include (../../testcommon.pri) diff --git a/tests/mirserver/QtEventFeeder/QtEventFeeder.pro b/tests/mirserver/QtEventFeeder/QtEventFeeder.pro index 2ad9bbf..c201481 100644 --- a/tests/mirserver/QtEventFeeder/QtEventFeeder.pro +++ b/tests/mirserver/QtEventFeeder/QtEventFeeder.pro @@ -1,4 +1,4 @@ -TARGET = qteventfeeder_test +TESTNAME = qteventfeeder include (../../testcommon.pri) diff --git a/tests/mirserver/Screen/Screen.pro b/tests/mirserver/Screen/Screen.pro index c7cadfe..19c953e 100644 --- a/tests/mirserver/Screen/Screen.pro +++ b/tests/mirserver/Screen/Screen.pro @@ -1,4 +1,4 @@ -TARGET = screen_test +TESTNAME = screen include (../../testcommon.pri) diff --git a/tests/modules/Application/Application.pro b/tests/modules/Application/Application.pro index e8290b5..7aa1999 100644 --- a/tests/modules/Application/Application.pro +++ b/tests/modules/Application/Application.pro @@ -1,4 +1,4 @@ -TARGET = application_test +TESTNAME = application include (../../testcommon.pri) diff --git a/tests/modules/ApplicationManager/ApplicationManager.pro b/tests/modules/ApplicationManager/ApplicationManager.pro index 686b96d..86e287e 100644 --- a/tests/modules/ApplicationManager/ApplicationManager.pro +++ b/tests/modules/ApplicationManager/ApplicationManager.pro @@ -1,4 +1,4 @@ -TARGET = application_manager_test +TESTNAME = application_manager include (../../testcommon.pri) diff --git a/tests/modules/DesktopFileReader/DesktopFileReader.pro b/tests/modules/DesktopFileReader/DesktopFileReader.pro index 3bc4093..bc876ae 100644 --- a/tests/modules/DesktopFileReader/DesktopFileReader.pro +++ b/tests/modules/DesktopFileReader/DesktopFileReader.pro @@ -1,4 +1,4 @@ -TARGET = desktopfilereader_test +TESTNAME = desktopfilereader include (../../testcommon.pri) diff --git a/tests/modules/General/General.pro b/tests/modules/General/General.pro index 851b7b6..a458cf4 100644 --- a/tests/modules/General/General.pro +++ b/tests/modules/General/General.pro @@ -1,4 +1,4 @@ -TARGET = objectlistmodel_test +TESTNAME = objectlistmodel include (../../testcommon.pri) diff --git a/tests/modules/MirSurfaceItem/MirSurfaceItem.pro b/tests/modules/MirSurfaceItem/MirSurfaceItem.pro index 9cd5f86..6c94c1b 100644 --- a/tests/modules/MirSurfaceItem/MirSurfaceItem.pro +++ b/tests/modules/MirSurfaceItem/MirSurfaceItem.pro @@ -1,4 +1,4 @@ -TARGET = mirsurfaceitem_test +TESTNAME = mirsurfaceitem include (../../testcommon.pri) diff --git a/tests/modules/SessionManager/SessionManager.pro b/tests/modules/SessionManager/SessionManager.pro index 4ae2910..6f7a475 100644 --- a/tests/modules/SessionManager/SessionManager.pro +++ b/tests/modules/SessionManager/SessionManager.pro @@ -1,4 +1,4 @@ -TARGET = session_manager_test +TESTNAME = session_manager include (../../testcommon.pri) diff --git a/tests/modules/SharedWakelock/SharedWakelock.pro b/tests/modules/SharedWakelock/SharedWakelock.pro index 85f422a..4cc96c2 100644 --- a/tests/modules/SharedWakelock/SharedWakelock.pro +++ b/tests/modules/SharedWakelock/SharedWakelock.pro @@ -1,4 +1,4 @@ -TARGET = sharedwakelock_test +TESTNAME = sharedwakelock CONFIG += gtest_own_main @@ -14,5 +14,9 @@ QT += testlib dbus PKGCONFIG += libqtdbusmock-1 libqtdbustest-1 +# It is also possible to use hardcoded paths for testing: +# LIBS += -lqtdbustest -lqtdbusmock +# INCLUDEPATH += /usr/include/libqtdbustest-1 +# INCLUDEPATH += /usr/include/libqtdbusmock-1 SOURCES += sharedwakelock_test.cpp diff --git a/tests/modules/TaskController/TaskController.pro b/tests/modules/TaskController/TaskController.pro index fbd6da8..50d41ad 100644 --- a/tests/modules/TaskController/TaskController.pro +++ b/tests/modules/TaskController/TaskController.pro @@ -1,4 +1,4 @@ -TARGET = taskcontroller_test +TESTNAME = taskcontroller include (../../testcommon.pri) diff --git a/tests/modules/common/common.pri b/tests/modules/common/common.pri index 2b6fc67..845d436 100644 --- a/tests/modules/common/common.pri +++ b/tests/modules/common/common.pri @@ -6,4 +6,4 @@ HEADERS += \ INCLUDEPATH += $$PWD -QT += quick dbus testlib +QT += quick dbus diff --git a/tests/testcommon.pri b/tests/testcommon.pri index 2b8ed16..85cf2c4 100644 --- a/tests/testcommon.pri +++ b/tests/testcommon.pri @@ -1,10 +1,16 @@ include (testlibs/testlibs.pri) -SOURCES += $$PWD/testlibs/testmain.cpp +!gtest_own_main: SOURCES += $$PWD/testlibs/testmain.cpp CONFIG += testcase CONFIG += c++11 +QT += testlib + +TARGET = tst_$$TESTNAME + +DEFINES += TEST_NAME=$$TARGET + # if there is a common directory above the test, include it exists ($$OUT_PWD/../common/common.pri) { include ($$OUT_PWD/../common/common.pri) diff --git a/tests/testlibs/testmain.cpp b/tests/testlibs/testmain.cpp index 3f77fc0..a7aa848 100644 --- a/tests/testlibs/testmain.cpp +++ b/tests/testlibs/testmain.cpp @@ -15,8 +15,32 @@ */ #include +#include + +class TEST_NAME : public QObject +{ + Q_OBJECT + +public: + TEST_NAME(); +private slots: + void runAllTests(); +}; + +TEST_NAME::TEST_NAME() +{ +} + +void TEST_NAME::runAllTests() +{ + int retVal = RUN_ALL_TESTS(); + QCOMPARE(retVal, 0); +} int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + TEST_NAME gTest; + return QTest::qExec(&gTest, argc, argv); } + +#include "testmain.moc" -- cgit v1.2.3