mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
Port the tests
This commit is contained in:
parent
ead067d329
commit
7123b4d9d2
|
@ -15,6 +15,7 @@ include(FeatureSummary)
|
||||||
include(KDEFrameworkCompilerSettings)
|
include(KDEFrameworkCompilerSettings)
|
||||||
include(KDEInstallDirs)
|
include(KDEInstallDirs)
|
||||||
include(KDECMakeSettings)
|
include(KDECMakeSettings)
|
||||||
|
include(ECMAddTests)
|
||||||
|
|
||||||
|
|
||||||
find_package(Qt5 CONFIG REQUIRED COMPONENTS Core DBus Test Widgets PrintSupport Svg)
|
find_package(Qt5 CONFIG REQUIRED COMPONENTS Core DBus Test Widgets PrintSupport Svg)
|
||||||
|
|
|
@ -1,34 +1,57 @@
|
||||||
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
|
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
|
||||||
|
add_definitions( -DKDESRCDIR="${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||||
|
|
||||||
kde4_add_unit_test( shelltest shelltest.cpp ../shell/shellutils.cpp )
|
ecm_add_test(shelltest shelltest.cpp ../shell/shellutils.cpp
|
||||||
target_link_libraries( shelltest ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} )
|
TEST_NAME "shelltest"
|
||||||
|
LINK_LIBRARIES Qt5::Test okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( parttest parttest.cpp )
|
ecm_add_test(parttest parttest.cpp
|
||||||
target_link_libraries( parttest ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularpart okularcore )
|
TEST_NAME "parttest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore okularpart KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( documenttest documenttest.cpp )
|
#ecm_add_test(documenttest documenttest.cpp
|
||||||
target_link_libraries( documenttest ${KDE4_KDECORE_LIBS} ${KDE4_THREADWEAVER_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
|
# TEST_NAME "documenttest"
|
||||||
|
# LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
|
||||||
|
#)
|
||||||
|
|
||||||
kde4_add_unit_test( searchtest searchtest.cpp )
|
ecm_add_test(searchtest searchtest.cpp
|
||||||
target_link_libraries( searchtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
|
TEST_NAME "searchtest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( annotationstest annotationstest.cpp )
|
ecm_add_test(annotationstest annotationstest.cpp
|
||||||
target_link_libraries( annotationstest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
|
TEST_NAME "annotationstest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( urldetecttest urldetecttest.cpp )
|
ecm_add_test(urldetecttest urldetecttest.cpp
|
||||||
target_link_libraries( urldetecttest ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} )
|
TEST_NAME "urldetecttest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml KF5::CoreAddons KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( editannotationcontentstest editannotationcontentstest.cpp testingutils.cpp)
|
ecm_add_test(editannotationcontentstest editannotationcontentstest.cpp testingutils.cpp
|
||||||
target_link_libraries( editannotationcontentstest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
|
TEST_NAME "editannotationcontentstest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( addremoveannotationtest addremoveannotationtest.cpp testingutils.cpp)
|
ecm_add_test(addremoveannotationtest addremoveannotationtest.cpp testingutils.cpp
|
||||||
target_link_libraries( addremoveannotationtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
|
TEST_NAME "addremoveannotationtest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( translateannotationtest translateannotationtest.cpp testingutils.cpp)
|
ecm_add_test(translateannotationtest translateannotationtest.cpp testingutils.cpp
|
||||||
target_link_libraries( translateannotationtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
|
TEST_NAME "translateannotationtest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( modifyannotationpropertiestest modifyannotationpropertiestest.cpp testingutils.cpp)
|
ecm_add_test(modifyannotationpropertiestest modifyannotationpropertiestest.cpp testingutils.cpp
|
||||||
target_link_libraries( modifyannotationpropertiestest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
|
TEST_NAME "modifyannotationpropertiestest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
||||||
kde4_add_unit_test( editformstest editformstest.cpp )
|
ecm_add_test(editformstest editformstest.cpp
|
||||||
target_link_libraries( editformstest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
|
TEST_NAME "editformstest"
|
||||||
|
LINK_LIBRARIES Qt5::Widgets Qt5::Test okularcore KF5::KDELibs4Support
|
||||||
|
)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <KConfigDialog>
|
#include <KConfigDialog>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
#include <KTempDir>
|
#include <KTempDir>
|
||||||
|
#include <K4AboutData>
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ class PartThatHijacksQueryClose : public Okular::Part
|
||||||
public:
|
public:
|
||||||
PartThatHijacksQueryClose(QWidget* parentWidget, QObject* parent,
|
PartThatHijacksQueryClose(QWidget* parentWidget, QObject* parent,
|
||||||
const QVariantList& args, KComponentData componentData)
|
const QVariantList& args, KComponentData componentData)
|
||||||
: Okular::Part(parentWidget, parent, args, componentData),
|
: Okular::Part(parentWidget, parent, args),
|
||||||
behavior(PassThru)
|
behavior(PassThru)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ class PartThatHijacksQueryClose : public Okular::Part
|
||||||
void PartTest::testReload()
|
void PartTest::testReload()
|
||||||
{
|
{
|
||||||
QVariantList dummyArgs;
|
QVariantList dummyArgs;
|
||||||
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
Okular::Part part(NULL, NULL, dummyArgs);
|
||||||
part.openDocument(KDESRCDIR "data/file1.pdf");
|
part.openDocument(KDESRCDIR "data/file1.pdf");
|
||||||
part.reload();
|
part.reload();
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
|
@ -90,7 +91,7 @@ void PartTest::testCanceledReload()
|
||||||
void PartTest::testTOCReload()
|
void PartTest::testTOCReload()
|
||||||
{
|
{
|
||||||
QVariantList dummyArgs;
|
QVariantList dummyArgs;
|
||||||
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
Okular::Part part(NULL, NULL, dummyArgs);
|
||||||
part.openDocument(KDESRCDIR "data/tocreload.pdf");
|
part.openDocument(KDESRCDIR "data/tocreload.pdf");
|
||||||
QCOMPARE(part.m_toc->expandedNodes().count(), 0);
|
QCOMPARE(part.m_toc->expandedNodes().count(), 0);
|
||||||
part.m_toc->m_treeView->expandAll();
|
part.m_toc->m_treeView->expandAll();
|
||||||
|
@ -105,7 +106,7 @@ void PartTest::testFowardPDF()
|
||||||
QFETCH(QString, dir);
|
QFETCH(QString, dir);
|
||||||
|
|
||||||
QVariantList dummyArgs;
|
QVariantList dummyArgs;
|
||||||
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
Okular::Part part(NULL, NULL, dummyArgs);
|
||||||
|
|
||||||
KTempDir tempDir(dir);
|
KTempDir tempDir(dir);
|
||||||
QFile f(KDESRCDIR "data/synctextest.tex");
|
QFile f(KDESRCDIR "data/synctextest.tex");
|
||||||
|
@ -144,7 +145,7 @@ void PartTest::testGeneratorPreferences()
|
||||||
{
|
{
|
||||||
KConfigDialog * dialog;
|
KConfigDialog * dialog;
|
||||||
QVariantList dummyArgs;
|
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
|
// Test that we don't crash while opening the dialog
|
||||||
dialog = part.slotGeneratorPreferences();
|
dialog = part.slotGeneratorPreferences();
|
||||||
|
@ -165,13 +166,13 @@ int main(int argc, char *argv[])
|
||||||
// This is QTEST_KDEMAIN withouth the LC_ALL set
|
// This is QTEST_KDEMAIN withouth the LC_ALL set
|
||||||
setenv("LC_ALL", "en_US.UTF-8", 1);
|
setenv("LC_ALL", "en_US.UTF-8", 1);
|
||||||
assert( !QDir::homePath().isEmpty() );
|
assert( !QDir::homePath().isEmpty() );
|
||||||
setenv("KDEHOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test") ), 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") ), 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") ), 1);
|
setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/config") ).constData(), 1);
|
||||||
setenv("KDE_SKIP_KDERC", "1", 1);
|
setenv("KDE_SKIP_KDERC", "1", 1);
|
||||||
unsetenv("KDE_COLOR_DEBUG");
|
unsetenv("KDE_COLOR_DEBUG");
|
||||||
QFile::remove(QDir::homePath() + QString::fromLatin1("/.kde-unit-test/share/config/qttestrc"));
|
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);
|
KComponentData cData(&aboutData);
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
app.setApplicationName( QLatin1String("qttest") );
|
app.setApplicationName( QLatin1String("qttest") );
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace QTest
|
||||||
template<>
|
template<>
|
||||||
char* toString( const KUrl& url )
|
char* toString( const KUrl& url )
|
||||||
{
|
{
|
||||||
return qstrdup( url.url().toLocal8Bit() );
|
return qstrdup( url.url().toLocal8Bit().constData() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue