summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishesh Handa <me@vhanda.in>2014-08-12 21:36:11 (GMT)
committerVishesh Handa <me@vhanda.in>2014-08-12 21:36:11 (GMT)
commit7123b4d9d26feedb12caf326d50fd4b986a6ee97 (patch)
tree731bde4cbd190ddc53725e72e3eee52d32bde084
parentead067d329feb6914cf23e4294b4a059d5eb383d (diff)
Port the tests
-rw-r--r--CMakeLists.txt1
-rw-r--r--tests/CMakeLists.txt89
-rw-r--r--tests/parttest.cpp19
-rw-r--r--tests/shelltest.cpp2
4 files changed, 68 insertions, 43 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d71d42..3f05170 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,7 @@ include(FeatureSummary)
include(KDEFrameworkCompilerSettings)
include(KDEInstallDirs)
include(KDECMakeSettings)
+include(ECMAddTests)
find_package(Qt5 CONFIG REQUIRED COMPONENTS Core DBus Test Widgets PrintSupport Svg)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3b3fbdd..7540264 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,34 +1,57 @@
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
-
-kde4_add_unit_test( shelltest shelltest.cpp ../shell/shellutils.cpp )
-target_link_libraries( shelltest ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} )
-
-kde4_add_unit_test( parttest parttest.cpp )
-target_link_libraries( parttest ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularpart okularcore )
-
-kde4_add_unit_test( documenttest documenttest.cpp )
-target_link_libraries( documenttest ${KDE4_KDECORE_LIBS} ${KDE4_THREADWEAVER_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
-
-kde4_add_unit_test( searchtest searchtest.cpp )
-target_link_libraries( searchtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
-
-kde4_add_unit_test( annotationstest annotationstest.cpp )
-target_link_libraries( annotationstest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
-
-kde4_add_unit_test( urldetecttest urldetecttest.cpp )
-target_link_libraries( urldetecttest ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} )
-
-kde4_add_unit_test( editannotationcontentstest editannotationcontentstest.cpp testingutils.cpp)
-target_link_libraries( editannotationcontentstest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
-
-kde4_add_unit_test( addremoveannotationtest addremoveannotationtest.cpp testingutils.cpp)
-target_link_libraries( addremoveannotationtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
-
-kde4_add_unit_test( translateannotationtest translateannotationtest.cpp testingutils.cpp)
-target_link_libraries( translateannotationtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
-
-kde4_add_unit_test( modifyannotationpropertiestest modifyannotationpropertiestest.cpp testingutils.cpp)
-target_link_libraries( modifyannotationpropertiestest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
-
-kde4_add_unit_test( editformstest editformstest.cpp )
-target_link_libraries( editformstest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
+add_definitions( -DKDESRCDIR="${CMAKE_CURRENT_SOURCE_DIR}" )
+
+ecm_add_test(shelltest shelltest.cpp ../shell/shellutils.cpp
+ TEST_NAME "shelltest"
+ LINK_LIBRARIES Qt5::Test okularcore KF5::KDELibs4Support
+)
+
+ecm_add_test(parttest parttest.cpp
+ TEST_NAME "parttest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore okularpart KF5::KDELibs4Support
+)
+
+#ecm_add_test(documenttest documenttest.cpp
+# TEST_NAME "documenttest"
+# LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
+#)
+
+ecm_add_test(searchtest searchtest.cpp
+ TEST_NAME "searchtest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
+)
+
+ecm_add_test(annotationstest annotationstest.cpp
+ TEST_NAME "annotationstest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
+)
+
+ecm_add_test(urldetecttest urldetecttest.cpp
+ TEST_NAME "urldetecttest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml KF5::CoreAddons KF5::KDELibs4Support
+)
+
+ecm_add_test(editannotationcontentstest editannotationcontentstest.cpp testingutils.cpp
+ TEST_NAME "editannotationcontentstest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
+)
+
+ecm_add_test(addremoveannotationtest addremoveannotationtest.cpp testingutils.cpp
+ TEST_NAME "addremoveannotationtest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
+)
+
+ecm_add_test(translateannotationtest translateannotationtest.cpp testingutils.cpp
+ TEST_NAME "translateannotationtest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
+)
+
+ecm_add_test(modifyannotationpropertiestest modifyannotationpropertiestest.cpp testingutils.cpp
+ TEST_NAME "modifyannotationpropertiestest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test okularcore KF5::KDELibs4Support
+)
+
+ecm_add_test(editformstest editformstest.cpp
+ TEST_NAME "editformstest"
+ LINK_LIBRARIES Qt5::Widgets Qt5::Test okularcore KF5::KDELibs4Support
+)
diff --git a/tests/parttest.cpp b/tests/parttest.cpp
index db43eee..c45c1b9 100644
--- a/tests/parttest.cpp
+++ b/tests/parttest.cpp
@@ -15,6 +15,7 @@
#include <KConfigDialog>
#include <KStandardDirs>
#include <KTempDir>
+#include <K4AboutData>
#include <QTreeView>
@@ -39,7 +40,7 @@ class PartThatHijacksQueryClose : public Okular::Part
public:
PartThatHijacksQueryClose(QWidget* parentWidget, QObject* parent,
const QVariantList& args, KComponentData componentData)
- : Okular::Part(parentWidget, parent, args, componentData),
+ : Okular::Part(parentWidget, parent, args),
behavior(PassThru)
{}
@@ -65,7 +66,7 @@ class PartThatHijacksQueryClose : public Okular::Part
void PartTest::testReload()
{
QVariantList dummyArgs;
- Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
+ Okular::Part part(NULL, NULL, dummyArgs);
part.openDocument(KDESRCDIR "data/file1.pdf");
part.reload();
qApp->processEvents();
@@ -90,7 +91,7 @@ void PartTest::testCanceledReload()
void PartTest::testTOCReload()
{
QVariantList dummyArgs;
- Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
+ Okular::Part part(NULL, NULL, dummyArgs);
part.openDocument(KDESRCDIR "data/tocreload.pdf");
QCOMPARE(part.m_toc->expandedNodes().count(), 0);
part.m_toc->m_treeView->expandAll();
@@ -105,7 +106,7 @@ void PartTest::testFowardPDF()
QFETCH(QString, dir);
QVariantList dummyArgs;
- Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
+ Okular::Part part(NULL, NULL, dummyArgs);
KTempDir tempDir(dir);
QFile f(KDESRCDIR "data/synctextest.tex");
@@ -144,7 +145,7 @@ void PartTest::testGeneratorPreferences()
{
KConfigDialog * dialog;
QVariantList dummyArgs;
- Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
+ Okular::Part part(NULL, NULL, dummyArgs);
// Test that we don't crash while opening the dialog
dialog = part.slotGeneratorPreferences();
@@ -165,13 +166,13 @@ int main(int argc, char *argv[])
// This is QTEST_KDEMAIN withouth the LC_ALL set
setenv("LC_ALL", "en_US.UTF-8", 1);
assert( !QDir::homePath().isEmpty() );
- setenv("KDEHOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test") ), 1);
- setenv("XDG_DATA_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/local") ), 1);
- setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/config") ), 1);
+ setenv("KDEHOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test") ).constData(), 1);
+ setenv("XDG_DATA_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/local") ).constData(), 1);
+ setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/config") ).constData(), 1);
setenv("KDE_SKIP_KDERC", "1", 1);
unsetenv("KDE_COLOR_DEBUG");
QFile::remove(QDir::homePath() + QString::fromLatin1("/.kde-unit-test/share/config/qttestrc"));
- KAboutData aboutData( QByteArray("qttest"), QByteArray(), ki18n("KDE Test Program"), QByteArray("version") );
+ K4AboutData aboutData( QByteArray("qttest"), QByteArray(), ki18n("KDE Test Program"), QByteArray("version") );
KComponentData cData(&aboutData);
QApplication app( argc, argv );
app.setApplicationName( QLatin1String("qttest") );
diff --git a/tests/shelltest.cpp b/tests/shelltest.cpp
index 8dd581c..b6edd23 100644
--- a/tests/shelltest.cpp
+++ b/tests/shelltest.cpp
@@ -18,7 +18,7 @@ namespace QTest
template<>
char* toString( const KUrl& url )
{
- return qstrdup( url.url().toLocal8Bit() );
+ return qstrdup( url.url().toLocal8Bit().constData() );
}
}