diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 6557cae7..2fa5d2e6 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,57 +1,58 @@ ########### next target ############### SET(gui_STAT_SRCS boolfieldwidget.cpp choicefieldwidget.cpp collectiontypecombo.cpp combobox.cpp countdelegate.cpp datefieldwidget.cpp datewidget.cpp detailedentryitemdelegate.cpp dockwidget.cpp drophandler.cpp imagefieldwidget.cpp imagewidget.cpp fieldwidget.cpp filterrulewidget.cpp filterrulewidgetlister.cpp kwidgetlister.cpp lineedit.cpp linefieldwidget.cpp listwidgetitem.cpp numberfieldwidget.cpp parafieldwidget.cpp previewdialog.cpp progress.cpp ratingdelegate.cpp ratingfieldwidget.cpp ratingwidget.cpp spinbox.cpp starrating.cpp statusbar.cpp stringmapdialog.cpp stringmapwidget.cpp tablefieldwidget.cpp tabwidget.cpp treeview.cpp + urlfieldlogic.cpp urlfieldwidget.cpp ) add_library(gui STATIC ${gui_STAT_SRCS}) TARGET_LINK_LIBRARIES(gui Qt5::Core Qt5::Widgets Qt5::Gui KF5::KIOCore KF5::KIOFileWidgets KF5::KHtml KF5::SonnetCore KF5::SonnetUi KF5::XmlGui ) IF( KF5Sane_FOUND ) TARGET_LINK_LIBRARIES(gui KF5::Sane) ENDIF( KF5Sane_FOUND ) diff --git a/src/tests/fieldtest.h b/src/gui/urlfieldlogic.cpp similarity index 63% copy from src/tests/fieldtest.h copy to src/gui/urlfieldlogic.cpp index ae5b3be6..ce35bc45 100644 --- a/src/tests/fieldtest.h +++ b/src/gui/urlfieldlogic.cpp @@ -1,37 +1,53 @@ /*************************************************************************** - Copyright (C) 2009 Robby Stephenson + Copyright (C) 2019 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ -#ifndef FIELDTEST_H -#define FIELDTEST_H +#include "urlfieldlogic.h" +#include "../tellico_debug.h" -#include +#include -class FieldTest : public QObject { -Q_OBJECT +using Tellico::UrlFieldLogic; -private Q_SLOTS: - void testAll(); -}; +UrlFieldLogic::UrlFieldLogic() + : m_isRelative(false) { +} -#endif +void UrlFieldLogic::setRelative(bool relative_) { + m_isRelative = relative_; +} + +void UrlFieldLogic::setBaseUrl(const QUrl& baseUrl_) { + m_baseUrl = baseUrl_; +} + +QString UrlFieldLogic::urlText(const QUrl& url_) const { + // if it's not relative or if the base URL is not set, + // then there's nothing to do. Return the URL as-is. + // Also, if the base URL is not a local file, then ignore it + if(url_.isEmpty() || !m_isRelative || m_baseUrl.isEmpty() || !m_baseUrl.isLocalFile()) { + return url_.url(); + } + myDebug() << url_.path() << "relative to" << m_baseUrl.path() << "is" << QDir(m_baseUrl.path()).relativeFilePath(url_.path()); + return QDir(m_baseUrl.path()).relativeFilePath(url_.path()); +} diff --git a/src/tests/fieldtest.h b/src/gui/urlfieldlogic.h similarity index 75% copy from src/tests/fieldtest.h copy to src/gui/urlfieldlogic.h index ae5b3be6..c16a5238 100644 --- a/src/tests/fieldtest.h +++ b/src/gui/urlfieldlogic.h @@ -1,37 +1,53 @@ /*************************************************************************** - Copyright (C) 2009 Robby Stephenson + Copyright (C) 2019 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ -#ifndef FIELDTEST_H -#define FIELDTEST_H +#ifndef TELLICO_URLFIELDLOGIC_H +#define TELLICO_URLFIELDLOGIC_H -#include +#include -class FieldTest : public QObject { -Q_OBJECT +namespace Tellico { -private Q_SLOTS: - void testAll(); +/** + * @author Robby Stephenson + */ +class UrlFieldLogic { +public: + UrlFieldLogic(); + + void setRelative(bool relative); + bool isRelative() const { return m_isRelative; } + + void setBaseUrl(const QUrl& baseUrl); + QUrl baseUrl() const { return m_baseUrl; } + + QString urlText(const QUrl& url) const; + +private: + bool m_isRelative; + QUrl m_baseUrl; }; +} // end namespace #endif diff --git a/src/gui/urlfieldwidget.cpp b/src/gui/urlfieldwidget.cpp index 4cc7e82a..a18ab704 100644 --- a/src/gui/urlfieldwidget.cpp +++ b/src/gui/urlfieldwidget.cpp @@ -1,112 +1,103 @@ /*************************************************************************** - Copyright (C) 2005-2009 Robby Stephenson + Copyright (C) 2005-2019 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #include "urlfieldwidget.h" #include "../field.h" #include "../tellico_kernel.h" #include #include #include #include #include using Tellico::GUI::URLFieldWidget; // subclass of KUrlCompletion is needed so the KUrlLabel // can open relative links. I don't want to have to have to update // the base directory of the completion every time a new document is opened QString URLFieldWidget::URLCompletion::makeCompletion(const QString& text_) { // KUrlCompletion::makeCompletion() uses an internal variable instead // of calling KUrlCompletion::dir() so need to set the base dir before completing setDir(Kernel::self()->URL().adjusted(QUrl::PreferLocalFile | QUrl::RemoveFilename)); return KUrlCompletion::makeCompletion(text_); } URLFieldWidget::URLFieldWidget(Tellico::Data::FieldPtr field_, QWidget* parent_) : FieldWidget(field_, parent_) { // the label is a KUrlLabel KUrlLabel* urlLabel = dynamic_cast(label()); Q_ASSERT(urlLabel); m_requester = new KUrlRequester(this); m_requester->lineEdit()->setCompletionObject(new URLCompletion()); m_requester->lineEdit()->setAutoDeleteCompletionObject(true); connect(m_requester, &KUrlRequester::textChanged, this, &URLFieldWidget::checkModified); connect(m_requester, &KUrlRequester::textChanged, urlLabel, &KUrlLabel::setUrl); void (KUrlLabel::* clickedSignal)(const QString&) = &KUrlLabel::leftClickedUrl; connect(urlLabel, clickedSignal, this, &URLFieldWidget::slotOpenURL); registerWidget(); // special case, remember if it's a relative url - m_isRelative = field_->property(QStringLiteral("relative")) == QLatin1String("true"); + m_logic.setRelative(field_->property(QStringLiteral("relative")) == QLatin1String("true")); } URLFieldWidget::~URLFieldWidget() { } QString URLFieldWidget::text() const { - if(m_isRelative && Kernel::self()->URL().isLocalFile()) { - //KURl::relativeUrl() has no QUrl analog - QUrl base_url = Kernel::self()->URL(); - QUrl url = m_requester->url(); - //return Kernel::self()->URL().resolved(m_requester->url()); - return QDir(base_url.path()).relativeFilePath(url.path()); - } // for comparison purposes and to be consistent with the file listing importer // I want the full url here, including the protocol - // the requester only returns the path, so create a QUrl - // TODO: 2015-04-30 no longer necessary in KF5/Qt5? - //return QUrl(m_requester->url()).url(); - return m_requester->url().url(); + m_logic.setBaseUrl(Kernel::self()->URL()); + return m_logic.urlText(m_requester->url()); } void URLFieldWidget::setTextImpl(const QString& text_) { m_requester->setUrl(QUrl::fromUserInput(text_)); static_cast(label())->setUrl(text_); } void URLFieldWidget::clearImpl() { m_requester->clear(); editMultiple(false); } void URLFieldWidget::updateFieldHook(Tellico::Data::FieldPtr, Tellico::Data::FieldPtr newField_) { - m_isRelative = newField_->property(QStringLiteral("relative")) == QLatin1String("true"); + m_logic.setRelative(newField_->property(QStringLiteral("relative")) == QLatin1String("true")); } void URLFieldWidget::slotOpenURL(const QString& url_) { if(url_.isEmpty()) { return; } - QDesktopServices::openUrl(m_isRelative ? + QDesktopServices::openUrl(m_logic.isRelative() ? Kernel::self()->URL().resolved(QUrl::fromUserInput(url_)) : QUrl::fromUserInput(url_)); } QWidget* URLFieldWidget::widget() { return m_requester; } diff --git a/src/gui/urlfieldwidget.h b/src/gui/urlfieldwidget.h index 4963cc8e..5f5548bc 100644 --- a/src/gui/urlfieldwidget.h +++ b/src/gui/urlfieldwidget.h @@ -1,75 +1,76 @@ /*************************************************************************** Copyright (C) 2005-2009 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #ifndef TELLICO_URLFIELDWIDGET_H #define TELLICO_URLFIELDWIDGET_H #include "fieldwidget.h" +#include "urlfieldlogic.h" #include #include class KUrlRequester; namespace Tellico { namespace GUI { /** * @author Robby Stephenson */ class URLFieldWidget : public FieldWidget { Q_OBJECT public: URLFieldWidget(Data::FieldPtr field, QWidget* parent); virtual ~URLFieldWidget(); virtual QString text() const Q_DECL_OVERRIDE; virtual void setTextImpl(const QString& text) Q_DECL_OVERRIDE; public Q_SLOTS: virtual void clearImpl() Q_DECL_OVERRIDE; protected: virtual QWidget* widget() Q_DECL_OVERRIDE; virtual void updateFieldHook(Data::FieldPtr oldField, Data::FieldPtr newField) Q_DECL_OVERRIDE; protected Q_SLOTS: void slotOpenURL(const QString& url); private: class URLCompletion : public KUrlCompletion { public: URLCompletion() : KUrlCompletion() {} virtual QString makeCompletion(const QString& text) Q_DECL_OVERRIDE; }; KUrlRequester* m_requester; - bool m_isRelative; + mutable UrlFieldLogic m_logic; // mutable so the base url can be modified in text() }; } // end GUI namespace } // end namespace #endif diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 9bb1a38f..394a2b68 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,839 +1,839 @@ include(ECMAddTests) include(ECMMarkNonGuiExecutable) SET( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) # formattest includes fieldformat that include core/tellico_config.h # which is generated in the build directory INCLUDE_DIRECTORIES( ${Tellico_BINARY_DIR}/src ) add_executable(entitytest entitytest.cpp ../fieldformat.cpp) ecm_mark_nongui_executable(entitytest) add_test(entitytest entitytest) ecm_mark_as_test(entitytest) TARGET_LINK_LIBRARIES(entitytest utils config Qt5::Test ) add_executable(cuecattest cuecattest.cpp) ecm_mark_nongui_executable(cuecattest) add_test(cuecattest cuecattest) ecm_mark_as_test(cuecattest) TARGET_LINK_LIBRARIES(cuecattest utils Qt5::Test) add_executable(isbntest isbntest.cpp) ecm_mark_nongui_executable(isbntest) add_test(isbntest isbntest) ecm_mark_as_test(isbntest) TARGET_LINK_LIBRARIES(isbntest utils Qt5::Test) add_executable(lccntest lccntest.cpp) ecm_mark_nongui_executable(lccntest) add_test(lccntest lccntest) ecm_mark_as_test(lccntest) TARGET_LINK_LIBRARIES(lccntest utils Qt5::Test) add_executable(lcctest lcctest.cpp ../field.cpp ../fieldformat.cpp) ecm_mark_nongui_executable(lcctest) add_test(lcctest lcctest) ecm_mark_as_test(lcctest) TARGET_LINK_LIBRARIES(lcctest tellicomodels Qt5::Test) add_executable(formattest formattest.cpp ../fieldformat.cpp) ecm_mark_nongui_executable(formattest) add_test(formattest formattest) ecm_mark_as_test(formattest) TARGET_LINK_LIBRARIES(formattest config Qt5::Test) -add_executable(fieldtest fieldtest.cpp ../field.cpp ../fieldformat.cpp) +add_executable(fieldtest fieldtest.cpp ../field.cpp ../fieldformat.cpp ../gui/urlfieldlogic.cpp) ecm_mark_nongui_executable(fieldtest) add_test(fieldtest fieldtest) ecm_mark_as_test(fieldtest) TARGET_LINK_LIBRARIES(fieldtest config utils Qt5::Test) add_executable(comparisontest comparisontest.cpp ../field.cpp ../fieldformat.cpp) ecm_mark_nongui_executable(comparisontest) add_test(comparisontest comparisontest) ecm_mark_as_test(comparisontest) TARGET_LINK_LIBRARIES(comparisontest tellicomodels Qt5::Test) add_executable(imagetest imagetest.cpp ../utils/tellico_utils.cpp ../utils/guiproxy.cpp ../utils/cursorsaver.cpp ../fieldformat.cpp) ecm_mark_nongui_executable(imagetest) add_test(imagetest imagetest) ecm_mark_as_test(imagetest) TARGET_LINK_LIBRARIES(imagetest images KF5::Archive Qt5::Test) add_executable(imagejobtest imagejobtest.cpp ../fieldformat.cpp) ecm_mark_nongui_executable(imagejobtest) add_test(imagejobtest imagejobtest) ecm_mark_as_test(imagejobtest) TARGET_LINK_LIBRARIES(imagejobtest images KF5::Archive Qt5::Test) add_executable(iso6937test iso6937test.cpp) ecm_mark_nongui_executable(iso6937test) add_test(iso6937test iso6937test) ecm_mark_as_test(iso6937test) TARGET_LINK_LIBRARIES(iso6937test utils Qt5::Test) SET(tellicotest_SRCS ../collection.cpp ../entry.cpp ../entrygroup.cpp ../entrycomparison.cpp ../field.cpp ../fieldformat.cpp ../filter.cpp ../borrower.cpp ../collectionfactory.cpp ../derivedvalue.cpp ../progressmanager.cpp ) add_library(tellicotest STATIC ${tellicotest_SRCS}) TARGET_LINK_LIBRARIES(tellicotest Qt5::Core Qt5::Gui KF5::I18n KF5::ConfigWidgets) ADD_DEPENDENCIES(tellicotest tellico_config) SET(translatorstest_SRCS ../translators/tellicoimporter.cpp ../translators/xsltimporter.cpp ../translators/textimporter.cpp ../translators/dataimporter.cpp ../translators/importer.cpp ../translators/tellicoxmlhandler.cpp ../translators/tellico_xml.cpp ../translators/xmlstatehandler.cpp ../translators/xslthandler.cpp ) add_library(translatorstest STATIC ${translatorstest_SRCS}) TARGET_LINK_LIBRARIES(translatorstest Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml KF5::I18n KF5::Archive KF5::KIOWidgets KF5::ConfigWidgets ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBXSLT_EXSLT_LIBRARIES} ) set(TELLICO_TEST_LIBS tellicotest collections utils images core tellicomodels Qt5::Test KF5::KIOCore KF5::Archive ) add_executable(collectiontest collectiontest.cpp ../document.cpp ../translators/tellicoxmlexporter.cpp ../translators/tellicozipexporter.cpp ../translators/exporter.cpp ) ecm_mark_nongui_executable(collectiontest) add_test(collectiontest collectiontest) ecm_mark_as_test(collectiontest) TARGET_LINK_LIBRARIES(collectiontest translatorstest ${TELLICO_TEST_LIBS}) add_executable(documenttest documenttest.cpp ../document.cpp ../translators/tellicoxmlexporter.cpp ../translators/tellicozipexporter.cpp ../translators/exporter.cpp ) ecm_mark_nongui_executable(documenttest) add_test(documenttest documenttest) ecm_mark_as_test(documenttest) TARGET_LINK_LIBRARIES(documenttest translatorstest ${TELLICO_TEST_LIBS}) add_executable(filtertest filtertest.cpp) ecm_mark_nongui_executable(filtertest) add_test(filtertest filtertest) ecm_mark_as_test(filtertest) TARGET_LINK_LIBRARIES(filtertest gui ${TELLICO_TEST_LIBS}) add_executable(tellicomodeltest tellicomodeltest.cpp modeltest.cpp ../document.cpp ../translators/tellicoimporter.cpp ../translators/dataimporter.cpp ../translators/importer.cpp ../translators/tellicoxmlexporter.cpp ../translators/tellicozipexporter.cpp ../translators/exporter.cpp ../translators/tellicoxmlhandler.cpp ../translators/tellico_xml.cpp ../translators/xmlstatehandler.cpp ) ecm_mark_nongui_executable(tellicomodeltest) add_test(tellicomodeltest tellicomodeltest) ecm_mark_as_test(tellicomodeltest) TARGET_LINK_LIBRARIES(tellicomodeltest ${TELLICO_TEST_LIBS} ${LIBXML2_LIBRARIES}) ###################################################### add_executable(adstest adstest.cpp ../translators/adsimporter.cpp ../translators/importer.cpp ) ecm_mark_nongui_executable(adstest) add_test(adstest adstest) ecm_mark_as_test(adstest) TARGET_LINK_LIBRARIES(adstest ${TELLICO_TEST_LIBS}) add_executable(alexandriatest alexandriatest.cpp ../translators/alexandriaimporter.cpp ../translators/importer.cpp ../translators/alexandriaexporter.cpp ../translators/exporter.cpp ) ecm_mark_nongui_executable(alexandriatest) add_test(alexandriatest alexandriatest) ecm_mark_as_test(alexandriatest) TARGET_LINK_LIBRARIES(alexandriatest ${TELLICO_TEST_LIBS}) add_executable(amctest amctest.cpp ../translators/amcimporter.cpp ../translators/dataimporter.cpp ../translators/importer.cpp ) ecm_mark_nongui_executable(amctest) add_test(amctest amctest) ecm_mark_as_test(amctest) TARGET_LINK_LIBRARIES(amctest ${TELLICO_TEST_LIBS}) add_executable(bibtextest bibtextest.cpp ../translators/bibteximporter.cpp ../translators/importer.cpp ../translators/bibtexexporter.cpp ../translators/exporter.cpp ) ecm_mark_nongui_executable(bibtextest) add_test(bibtextest bibtextest) ecm_mark_as_test(bibtextest) TARGET_LINK_LIBRARIES(bibtextest ${TELLICO_BTPARSE_LIBS} ${TELLICO_TEST_LIBS}) add_executable(bibtexmltest bibtexmltest.cpp ../translators/bibtexmlimporter.cpp ../translators/bibtexmlexporter.cpp ../translators/exporter.cpp ) ecm_mark_nongui_executable(bibtexmltest) add_test(bibtexmltest bibtexmltest) ecm_mark_as_test(bibtexmltest) TARGET_LINK_LIBRARIES(bibtexmltest translatorstest core ${TELLICO_TEST_LIBS}) add_executable(citetest citetest.cpp ../collections/bibtexcollection.cpp ../core/filehandler.cpp ) ecm_mark_nongui_executable(citetest) add_test(citetest citetest) ecm_mark_as_test(citetest) TARGET_LINK_LIBRARIES(citetest cite tellicotest config images Qt5::Test) ADD_DEPENDENCIES(citetest tellico_config) add_executable(ciwtest ciwtest.cpp ../translators/ciwimporter.cpp ../translators/importer.cpp ) ecm_mark_nongui_executable(ciwtest) add_test(ciwtest ciwtest) ecm_mark_as_test(ciwtest) TARGET_LINK_LIBRARIES(ciwtest ${TELLICO_TEST_LIBS}) add_executable(csvtest csvtest.cpp ../translators/csvparser.cpp ../translators/csvexporter.cpp ../translators/exporter.cpp ) ecm_mark_nongui_executable(csvtest) add_test(csvtest csvtest) ecm_mark_as_test(csvtest) TARGET_LINK_LIBRARIES(csvtest ${TELLICO_CSV_LIBS} translatorstest ${TELLICO_TEST_LIBS}) add_executable(delicioustest delicioustest.cpp ../translators/deliciousimporter.cpp ) ecm_mark_nongui_executable(delicioustest) add_test(delicioustest delicioustest) ecm_mark_as_test(delicioustest) TARGET_LINK_LIBRARIES(delicioustest rtf2html-tellico translatorstest ${TELLICO_TEST_LIBS}) add_executable(filelistingtest filelistingtest.cpp ../translators/filelistingimporter.cpp ../translators/xmphandler.cpp ) ecm_mark_nongui_executable(filelistingtest) add_test(filelistingtest filelistingtest) ecm_mark_as_test(filelistingtest) TARGET_LINK_LIBRARIES(filelistingtest translatorstest ${TELLICO_TEST_LIBS} KF5::Solid ) IF( KF5FileMetaData_FOUND ) TARGET_LINK_LIBRARIES(filelistingtest KF5::FileMetaData) ENDIF( KF5FileMetaData_FOUND ) IF( Exempi_FOUND ) TARGET_LINK_LIBRARIES(filelistingtest ${Exempi_LIBRARIES}) ENDIF( Exempi_FOUND ) add_executable(gcstartest gcstartest.cpp ../translators/gcstarimporter.cpp ../translators/gcstarexporter.cpp ../translators/tellicoxmlexporter.cpp ../translators/tellicozipexporter.cpp ../translators/exporter.cpp ../document.cpp ) ecm_mark_nongui_executable(gcstartest) add_test(gcstartest gcstartest) ecm_mark_as_test(gcstartest) TARGET_LINK_LIBRARIES(gcstartest translatorstest ${TELLICO_TEST_LIBS}) add_executable(griffithtest griffithtest.cpp ../translators/griffithimporter.cpp ) ecm_mark_nongui_executable(griffithtest) add_test(griffithtest griffithtest) ecm_mark_as_test(griffithtest) TARGET_LINK_LIBRARIES(griffithtest translatorstest ${TELLICO_TEST_LIBS}) add_executable(htmlexportertest htmlexportertest.cpp ../translators/htmlexporter.cpp ../translators/tellicoxmlexporter.cpp ../translators/tellicozipexporter.cpp ../translators/exporter.cpp ../document.cpp ) ecm_mark_nongui_executable(htmlexportertest) add_test(htmlexportertest htmlexportertest) ecm_mark_as_test(htmlexportertest) TARGET_LINK_LIBRARIES(htmlexportertest translatorstest ${TELLICO_TEST_LIBS}) add_executable(modstest modstest.cpp) ecm_mark_nongui_executable(modstest) add_test(modstest modstest) ecm_mark_as_test(modstest) TARGET_LINK_LIBRARIES(modstest translatorstest ${TELLICO_TEST_LIBS}) add_executable(referencertest referencertest.cpp ../translators/referencerimporter.cpp ) ecm_mark_nongui_executable(referencertest) add_test(referencertest referencertest) ecm_mark_as_test(referencertest) TARGET_LINK_LIBRARIES(referencertest translatorstest ${TELLICO_TEST_LIBS}) add_executable(ristest ristest.cpp ../translators/risimporter.cpp ../translators/importer.cpp ) ecm_mark_nongui_executable(ristest) add_test(ristest ristest) ecm_mark_as_test(ristest) TARGET_LINK_LIBRARIES(ristest ${TELLICO_TEST_LIBS}) add_executable(tellicoreadtest tellicoreadtest.cpp ../translators/tellicoxmlexporter.cpp ../translators/tellicozipexporter.cpp ../translators/exporter.cpp ../document.cpp ) ecm_mark_nongui_executable(tellicoreadtest) add_test(tellicoreadtest tellicoreadtest) ecm_mark_as_test(tellicoreadtest) TARGET_LINK_LIBRARIES(tellicoreadtest translatorstest ${TELLICO_TEST_LIBS}) add_executable(vinoxmltest vinoxmltest.cpp ../translators/vinoxmlimporter.cpp ) ecm_mark_nongui_executable(vinoxmltest) add_test(vinoxmltest vinoxmltest) ecm_mark_as_test(vinoxmltest) TARGET_LINK_LIBRARIES(vinoxmltest translatorstest ${TELLICO_TEST_LIBS}) SET(fetcherstest_SRCS ../fetch/fetcher.cpp ../fetch/fetcherjob.cpp ../fetch/fetchresult.cpp ../fetch/fetchmanager.cpp ../fetch/messagehandler.cpp ../fetch/configwidget.cpp ../document.cpp ../translators/tellicoxmlexporter.cpp ../translators/tellicozipexporter.cpp ../translators/exporter.cpp ) # FetchManager links to SRUFetcher for the default sources # so have to include everything it needs SET(fetcherstest_SRCS ${fetcherstest_SRCS} ../fetch/srufetcher.cpp ../fetch/xmlfetcher.cpp ../gui/lineedit.cpp ../gui/combobox.cpp ../gui/stringmapwidget.cpp ) add_library(fetcherstest STATIC ${fetcherstest_SRCS}) TARGET_LINK_LIBRARIES(fetcherstest translatorstest Qt5::Core Qt5::Gui Qt5::DBus KF5::ConfigCore KF5::ConfigGui KF5::ConfigWidgets KF5::I18n KF5::Archive KF5::IconThemes KF5::XmlGui KF5::SonnetCore KF5::SonnetUi ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBXSLT_EXSLT_LIBRARIES} ) ADD_DEPENDENCIES(fetcherstest tellico_config) IF(${KF5KIO_VERSION} VERSION_GREATER "5.18.0") TARGET_LINK_LIBRARIES(fetcherstest KF5::KIOGui ) ENDIF(${KF5KIO_VERSION} VERSION_GREATER "5.18.0") # the PDF importer uses CrossRefFetcher, so include the test in the fetchers add_executable(pdftest pdftest.cpp ../translators/pdfimporter.cpp ../translators/xmphandler.cpp ../entryupdatejob.cpp ) ecm_mark_nongui_executable(pdftest) add_test(pdftest pdftest) ecm_mark_as_test(pdftest) TARGET_LINK_LIBRARIES(pdftest translatorstest fetcherstest ${TELLICO_TEST_LIBS}) IF( Exempi_FOUND ) TARGET_LINK_LIBRARIES(pdftest ${Exempi_LIBRARIES}) ENDIF( Exempi_FOUND ) IF( Poppler_Qt5_FOUND ) TARGET_LINK_LIBRARIES(pdftest Poppler::Qt5) ENDIF( Poppler_Qt5_FOUND ) # fetcher tests from here down IF(BUILD_FETCHER_TESTS) add_executable(entryupdatejobtest entryupdatejobtest.cpp ../entryupdatejob.cpp ../fetch/arxivfetcher.cpp ) ecm_mark_nongui_executable(entryupdatejobtest) add_test(entryupdatejobtest entryupdatejobtest) ecm_mark_as_test(entryupdatejobtest) TARGET_LINK_LIBRARIES(entryupdatejobtest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(allocinefetchertest allocinefetchertest.cpp abstractfetchertest.cpp ../fetch/allocinefetcher.cpp ../fetch/execexternalfetcher.cpp ../translators/bibteximporter.cpp ../translators/risimporter.cpp ../gui/collectiontypecombo.cpp ) ecm_mark_nongui_executable(allocinefetchertest) add_test(allocinefetchertest allocinefetchertest) ecm_mark_as_test(allocinefetchertest) # SonnetCore is needed for GUI::LineEdit TARGET_LINK_LIBRARIES(allocinefetchertest fetcherstest translatorstest newstuff ${TELLICO_BTPARSE_LIBS} ${TELLICO_TEST_LIBS} ) add_executable(amazonfetchertest amazonfetchertest.cpp abstractfetchertest.cpp ../fetch/amazonfetcher.cpp ../fetch/amazonrequest.cpp ../fetch/hmac_sha2.c ../fetch/sha2.c ) ecm_mark_nongui_executable(amazonfetchertest) add_test(amazonfetchertest amazonfetchertest) ecm_mark_as_test(amazonfetchertest) TARGET_LINK_LIBRARIES(amazonfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(animenfofetchertest animenfofetchertest.cpp abstractfetchertest.cpp ../fetch/animenfofetcher.cpp ) ecm_mark_nongui_executable(animenfofetchertest) add_test(animenfofetchertest animenfofetchertest) ecm_mark_as_test(animenfofetchertest) TARGET_LINK_LIBRARIES(animenfofetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(arxivfetchertest arxivfetchertest.cpp abstractfetchertest.cpp ../fetch/arxivfetcher.cpp ) ecm_mark_nongui_executable(arxivfetchertest) add_test(arxivfetchertest arxivfetchertest) ecm_mark_as_test(arxivfetchertest) TARGET_LINK_LIBRARIES(arxivfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(bedethequefetchertest bedethequefetchertest.cpp abstractfetchertest.cpp ../fetch/bedethequefetcher.cpp ) ecm_mark_nongui_executable(bedethequefetchertest) add_test(bedethequefetchertest bedethequefetchertest) ecm_mark_as_test(bedethequefetchertest) TARGET_LINK_LIBRARIES(bedethequefetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(bibliosharefetchertest bibliosharefetchertest.cpp abstractfetchertest.cpp ../fetch/bibliosharefetcher.cpp ) ecm_mark_nongui_executable(bibliosharefetchertest) add_test(bibliosharefetchertest bibliosharefetchertest) ecm_mark_as_test(bibliosharefetchertest) TARGET_LINK_LIBRARIES(bibliosharefetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(boardgamegeekfetchertest boardgamegeekfetchertest.cpp abstractfetchertest.cpp ../fetch/boardgamegeekfetcher.cpp ) ecm_mark_nongui_executable(boardgamegeekfetchertest) add_test(boardgamegeekfetchertest boardgamegeekfetchertest) ecm_mark_as_test(boardgamegeekfetchertest) TARGET_LINK_LIBRARIES(boardgamegeekfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(comicvinefetchertest comicvinefetchertest.cpp abstractfetchertest.cpp ../fetch/comicvinefetcher.cpp ) ecm_mark_nongui_executable(comicvinefetchertest) add_test(comicvinefetchertest comicvinefetchertest) ecm_mark_as_test(comicvinefetchertest) TARGET_LINK_LIBRARIES(comicvinefetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(crossreffetchertest crossreffetchertest.cpp abstractfetchertest.cpp ../fetch/crossreffetcher.cpp ) ecm_mark_nongui_executable(crossreffetchertest) add_test(crossreffetchertest crossreffetchertest) ecm_mark_as_test(crossreffetchertest) TARGET_LINK_LIBRARIES(crossreffetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(darkhorsefetchertest darkhorsefetchertest.cpp abstractfetchertest.cpp ../fetch/execexternalfetcher.cpp ../translators/bibteximporter.cpp ../translators/risimporter.cpp ../gui/collectiontypecombo.cpp ) ecm_mark_nongui_executable(darkhorsefetchertest) add_test(darkhorsefetchertest darkhorsefetchertest) ecm_mark_as_test(darkhorsefetchertest) TARGET_LINK_LIBRARIES(darkhorsefetchertest fetcherstest newstuff ${TELLICO_BTPARSE_LIBS} ${TELLICO_TEST_LIBS} ) add_executable(dbcfetchertest dbcfetchertest.cpp abstractfetchertest.cpp ../fetch/dbcfetcher.cpp ) ecm_mark_nongui_executable(dbcfetchertest) add_test(dbcfetchertest dbcfetchertest) ecm_mark_as_test(dbcfetchertest) TARGET_LINK_LIBRARIES(dbcfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(dblpfetchertest dblpfetchertest.cpp abstractfetchertest.cpp ../fetch/dblpfetcher.cpp ) ecm_mark_nongui_executable(dblpfetchertest) add_test(dblpfetchertest dblpfetchertest) ecm_mark_as_test(dblpfetchertest) TARGET_LINK_LIBRARIES(dblpfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(discogsfetchertest discogsfetchertest.cpp abstractfetchertest.cpp ../fetch/discogsfetcher.cpp ) ecm_mark_nongui_executable(discogsfetchertest) add_test(discogsfetchertest discogsfetchertest) ecm_mark_as_test(discogsfetchertest) TARGET_LINK_LIBRARIES(discogsfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(doubanfetchertest doubanfetchertest.cpp abstractfetchertest.cpp ../fetch/doubanfetcher.cpp ) ecm_mark_nongui_executable(doubanfetchertest) add_test(doubanfetchertest doubanfetchertest) ecm_mark_as_test(doubanfetchertest) TARGET_LINK_LIBRARIES(doubanfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(dvdfrfetchertest dvdfrfetchertest.cpp abstractfetchertest.cpp ../fetch/dvdfrfetcher.cpp ) ecm_mark_nongui_executable(dvdfrfetchertest) add_test(dvdfrfetchertest dvdfrfetchertest) ecm_mark_as_test(dvdfrfetchertest) TARGET_LINK_LIBRARIES(dvdfrfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(entrezfetchertest entrezfetchertest.cpp abstractfetchertest.cpp ../fetch/entrezfetcher.cpp ) ecm_mark_nongui_executable(entrezfetchertest) add_test(entrezfetchertest entrezfetchertest) ecm_mark_as_test(entrezfetchertest) TARGET_LINK_LIBRARIES(entrezfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(externalfetchertest externalfetchertest.cpp abstractfetchertest.cpp ../fetch/execexternalfetcher.cpp ../translators/bibteximporter.cpp ../translators/risimporter.cpp ../gui/collectiontypecombo.cpp ) ecm_mark_nongui_executable(externalfetchertest) add_test(externalfetchertest externalfetchertest) ecm_mark_as_test(externalfetchertest) TARGET_LINK_LIBRARIES(externalfetchertest fetcherstest newstuff ${TELLICO_BTPARSE_LIBS} ${TELLICO_TEST_LIBS} KF5::SonnetCore KF5::SonnetUi KF5::XmlGui ) add_executable(filmasterfetchertest filmasterfetchertest.cpp abstractfetchertest.cpp ../fetch/filmasterfetcher.cpp ) ecm_mark_nongui_executable(filmasterfetchertest) add_test(filmasterfetchertest filmasterfetchertest) ecm_mark_as_test(filmasterfetchertest) TARGET_LINK_LIBRARIES(filmasterfetchertest fetcherstest translatorstest ${TELLICO_TEST_LIBS}) # running gcstar in the fetcher is really unreliable add_executable(gcstarfetchertest gcstarfetchertest.cpp abstractfetchertest ../fetch/gcstarpluginfetcher.cpp ../fetch/gcstarthread.cpp ../translators/gcstarimporter.cpp ../gui/collectiontypecombo.cpp ) ecm_mark_nongui_executable(gcstarfetchertest) #add_test(gcstarfetchertest gcstarfetchertest) #ecm_mark_as_test(gcstarfetchertest) TARGET_LINK_LIBRARIES(gcstarfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(giantbombfetchertest giantbombfetchertest.cpp abstractfetchertest.cpp ../fetch/giantbombfetcher.cpp ) ecm_mark_nongui_executable(giantbombfetchertest) add_test(giantbombfetchertest giantbombfetchertest) ecm_mark_as_test(giantbombfetchertest) TARGET_LINK_LIBRARIES(giantbombfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(googlebookfetchertest googlebookfetchertest.cpp abstractfetchertest.cpp ../fetch/googlebookfetcher.cpp ) ecm_mark_nongui_executable(googlebookfetchertest) add_test(googlebookfetchertest googlebookfetchertest) ecm_mark_as_test(googlebookfetchertest) TARGET_LINK_LIBRARIES(googlebookfetchertest fetcherstest translatorstest ${TELLICO_TEST_LIBS}) add_executable(googlescholarfetchertest googlescholarfetchertest.cpp abstractfetchertest.cpp ../fetch/googlescholarfetcher.cpp ../translators/bibteximporter.cpp ) ecm_mark_nongui_executable(googlescholarfetchertest) add_test(googlescholarfetchertest googlescholarfetchertest) ecm_mark_as_test(googlescholarfetchertest) TARGET_LINK_LIBRARIES(googlescholarfetchertest fetcherstest ${TELLICO_BTPARSE_LIBS} ${TELLICO_TEST_LIBS}) add_executable(hathitrustfetchertest hathitrustfetchertest.cpp abstractfetchertest.cpp ../fetch/hathitrustfetcher.cpp ) ecm_mark_nongui_executable(hathitrustfetchertest) add_test(hathitrustfetchertest hathitrustfetchertest) ecm_mark_as_test(hathitrustfetchertest) TARGET_LINK_LIBRARIES(hathitrustfetchertest fetcherstest translatorstest ${TELLICO_TEST_LIBS}) add_executable(ibsfetchertest ibsfetchertest.cpp abstractfetchertest.cpp ../fetch/ibsfetcher.cpp ) ecm_mark_nongui_executable(ibsfetchertest) add_test(ibsfetchertest ibsfetchertest) ecm_mark_as_test(ibsfetchertest) TARGET_LINK_LIBRARIES(ibsfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(igdbfetchertest igdbfetchertest.cpp abstractfetchertest.cpp ../fetch/igdbfetcher.cpp ) ecm_mark_nongui_executable(igdbfetchertest) add_test(igdbfetchertest igdbfetchertest) ecm_mark_as_test(igdbfetchertest) TARGET_LINK_LIBRARIES(igdbfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(imdbfetchertest imdbfetchertest.cpp abstractfetchertest.cpp ../fetch/imdbfetcher.cpp ../gui/listwidgetitem.cpp ) ecm_mark_nongui_executable(imdbfetchertest) add_test(imdbfetchertest imdbfetchertest) ecm_mark_as_test(imdbfetchertest) TARGET_LINK_LIBRARIES(imdbfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(isbndbfetchertest isbndbfetchertest.cpp abstractfetchertest.cpp ../fetch/isbndbfetcher.cpp ) ecm_mark_nongui_executable(isbndbfetchertest) add_test(isbndbfetchertest isbndbfetchertest) ecm_mark_as_test(isbndbfetchertest) TARGET_LINK_LIBRARIES(isbndbfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(kinofetchertest kinofetchertest.cpp abstractfetchertest.cpp ../fetch/kinofetcher.cpp ) ecm_mark_nongui_executable(kinofetchertest) add_test(kinofetchertest kinofetchertest) ecm_mark_as_test(kinofetchertest) TARGET_LINK_LIBRARIES(kinofetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(kinopoiskfetchertest kinopoiskfetchertest.cpp abstractfetchertest.cpp ../fetch/kinopoiskfetcher.cpp ) ecm_mark_nongui_executable(kinopoiskfetchertest) add_test(kinopoiskfetchertest kinopoiskfetchertest) ecm_mark_as_test(kinopoiskfetchertest) TARGET_LINK_LIBRARIES(kinopoiskfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(kinoteatrfetchertest kinoteatrfetchertest.cpp abstractfetchertest.cpp ../fetch/kinoteatrfetcher.cpp ) ecm_mark_nongui_executable(kinoteatrfetchertest) add_test(kinoteatrfetchertest kinoteatrfetchertest) ecm_mark_as_test(kinoteatrfetchertest) TARGET_LINK_LIBRARIES(kinoteatrfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(mobygamesfetchertest mobygamesfetchertest.cpp abstractfetchertest.cpp ../fetch/mobygamesfetcher.cpp ) ecm_mark_nongui_executable(mobygamesfetchertest) add_test(mobygamesfetchertest mobygamesfetchertest) ecm_mark_as_test(mobygamesfetchertest) TARGET_LINK_LIBRARIES(mobygamesfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(moviemeterfetchertest moviemeterfetchertest.cpp abstractfetchertest.cpp ../fetch/moviemeterfetcher.cpp ) ecm_mark_nongui_executable(moviemeterfetchertest) add_test(moviemeterfetchertest moviemeterfetchertest) ecm_mark_as_test(moviemeterfetchertest) TARGET_LINK_LIBRARIES(moviemeterfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(mrlookupfetchertest mrlookupfetchertest.cpp abstractfetchertest.cpp ../fetch/mrlookupfetcher.cpp ../translators/bibteximporter.cpp ) ecm_mark_nongui_executable(mrlookupfetchertest) add_test(mrlookupfetchertest mrlookupfetchertest) ecm_mark_as_test(mrlookupfetchertest) TARGET_LINK_LIBRARIES(mrlookupfetchertest fetcherstest ${TELLICO_BTPARSE_LIBS} ${TELLICO_TEST_LIBS}) add_executable(musicbrainzfetchertest musicbrainzfetchertest.cpp abstractfetchertest.cpp ../fetch/musicbrainzfetcher.cpp ) ecm_mark_nongui_executable(musicbrainzfetchertest) add_test(musicbrainzfetchertest musicbrainzfetchertest) ecm_mark_as_test(musicbrainzfetchertest) TARGET_LINK_LIBRARIES(musicbrainzfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(openlibraryfetchertest openlibraryfetchertest.cpp abstractfetchertest.cpp ../fetch/openlibraryfetcher.cpp ) ecm_mark_nongui_executable(openlibraryfetchertest) add_test(openlibraryfetchertest openlibraryfetchertest) ecm_mark_as_test(openlibraryfetchertest) TARGET_LINK_LIBRARIES(openlibraryfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(omdbfetchertest omdbfetchertest.cpp abstractfetchertest.cpp ../fetch/omdbfetcher.cpp ) ecm_mark_nongui_executable(omdbfetchertest) add_test(omdbfetchertest omdbfetchertest) ecm_mark_as_test(omdbfetchertest) TARGET_LINK_LIBRARIES(omdbfetchertest fetcherstest translatorstest ${TELLICO_TEST_LIBS}) add_executable(springerfetchertest springerfetchertest.cpp abstractfetchertest.cpp ../fetch/springerfetcher.cpp ) ecm_mark_nongui_executable(springerfetchertest) add_test(springerfetchertest springerfetchertest) ecm_mark_as_test(springerfetchertest) TARGET_LINK_LIBRARIES(springerfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(srufetchertest srufetchertest.cpp abstractfetchertest.cpp ) ecm_mark_nongui_executable(srufetchertest) add_test(srufetchertest srufetchertest) ecm_mark_as_test(srufetchertest) # Sonnet needed for gui/lineedit TARGET_LINK_LIBRARIES(srufetchertest fetcherstest ${TELLICO_TEST_LIBS} ) add_executable(thegamesdbfetchertest thegamesdbfetchertest.cpp abstractfetchertest.cpp ../fetch/thegamesdbfetcher.cpp ) ecm_mark_nongui_executable(thegamesdbfetchertest) add_test(thegamesdbfetchertest thegamesdbfetchertest) ecm_mark_as_test(thegamesdbfetchertest) TARGET_LINK_LIBRARIES(thegamesdbfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(themoviedbfetchertest themoviedbfetchertest.cpp abstractfetchertest.cpp ../fetch/themoviedbfetcher.cpp ) ecm_mark_nongui_executable(themoviedbfetchertest) add_test(themoviedbfetchertest themoviedbfetchertest) ecm_mark_as_test(themoviedbfetchertest) TARGET_LINK_LIBRARIES(themoviedbfetchertest fetcherstest translatorstest ${TELLICO_TEST_LIBS}) add_executable(videogamegeekfetchertest videogamegeekfetchertest.cpp abstractfetchertest.cpp ../fetch/videogamegeekfetcher.cpp ) ecm_mark_nongui_executable(videogamegeekfetchertest) add_test(videogamegeekfetchertest videogamegeekfetchertest) ecm_mark_as_test(videogamegeekfetchertest) TARGET_LINK_LIBRARIES(videogamegeekfetchertest fetcherstest ${TELLICO_TEST_LIBS}) add_executable(vndbfetchertest vndbfetchertest.cpp abstractfetchertest.cpp ../fetch/vndbfetcher.cpp ) ecm_mark_nongui_executable(vndbfetchertest) add_test(vndbfetchertest vndbfetchertest) ecm_mark_as_test(vndbfetchertest) TARGET_LINK_LIBRARIES(vndbfetchertest fetcherstest ${TELLICO_TEST_LIBS}) IF( Yaz_FOUND ) add_executable(z3950fetchertest z3950fetchertest.cpp abstractfetchertest.cpp ../fetch/z3950fetcher.cpp ../fetch/z3950connection.cpp ../translators/grs1importer.cpp ../translators/adsimporter.cpp ) ecm_mark_nongui_executable(z3950fetchertest) add_test(z3950fetchertest z3950fetchertest) ecm_mark_as_test(z3950fetchertest) TARGET_LINK_LIBRARIES(z3950fetchertest fetcherstest ${Yaz_LIBRARIES} ${TELLICO_TEST_LIBS} ) ENDIF( Yaz_FOUND ) ENDIF(BUILD_FETCHER_TESTS) diff --git a/src/tests/fieldtest.cpp b/src/tests/fieldtest.cpp index c6b8e00a..878b61cc 100644 --- a/src/tests/fieldtest.cpp +++ b/src/tests/fieldtest.cpp @@ -1,91 +1,123 @@ /*************************************************************************** Copyright (C) 2009 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include "fieldtest.h" #include "../field.h" +#include "../gui/urlfieldlogic.h" #include QTEST_APPLESS_MAIN( FieldTest ) void FieldTest::testAll() { Tellico::Data::Field field1(QStringLiteral("name"), QStringLiteral("title")); // the default field type is line QCOMPARE(field1.type(), Tellico::Data::Field::Line); QCOMPARE(field1.name(), QStringLiteral("name")); QCOMPARE(field1.title(), QStringLiteral("title")); // description should match title, to begin with QCOMPARE(field1.description(), QStringLiteral("title")); QCOMPARE(field1.flags(), 0); QCOMPARE(field1.formatType(), Tellico::FieldFormat::FormatNone); field1.setTitle(QStringLiteral("newtitle")); QCOMPARE(field1.title(), QStringLiteral("newtitle")); field1.setCategory(QStringLiteral("category")); QCOMPARE(field1.category(), QStringLiteral("category")); field1.setDefaultValue(QStringLiteral("default")); QCOMPARE(field1.defaultValue(), QStringLiteral("default")); QCOMPARE(field1.isSingleCategory(), false); Tellico::Data::Field field1a = field1; QCOMPARE(field1.type(), field1a.type()); QCOMPARE(field1.category(), field1a.category()); QCOMPARE(field1.propertyList(), field1a.propertyList()); Tellico::Data::Field field2(QStringLiteral("table"), QStringLiteral("Table"), Tellico::Data::Field::Table2); // should be converted to Table type QCOMPARE(field2.type(), Tellico::Data::Field::Table); QCOMPARE(field2.property(QStringLiteral("columns")), QStringLiteral("2")); field2.setProperty(QStringLiteral("columns"), QStringLiteral("1")); QCOMPARE(field2.property(QStringLiteral("columns")), QStringLiteral("1")); QCOMPARE(field2.isSingleCategory(), true); QCOMPARE(field2.flags(), int(Tellico::Data::Field::AllowMultiple)); QVERIFY(field2.hasFlag(Tellico::Data::Field::AllowMultiple)); QStringList allowed; allowed << QStringLiteral("choice1"); Tellico::Data::Field field3(QStringLiteral("choice"), QStringLiteral("Choice"), allowed); QCOMPARE(field3.type(), Tellico::Data::Field::Choice); QCOMPARE(field3.allowed(), allowed); field3.setDefaultValue(QStringLiteral("default")); QCOMPARE(field3.defaultValue(), QString()); QCOMPARE(field3.flags(), 0); Tellico::Data::Field field4(QStringLiteral("derived"), QStringLiteral("Derived"), Tellico::Data::Field::Dependent); // should be converted to Line type QCOMPARE(field4.type(), Tellico::Data::Field::Line); QCOMPARE(field4.isSingleCategory(), false); QCOMPARE(field4.flags(), int(Tellico::Data::Field::Derived)); QVERIFY(field4.hasFlag(Tellico::Data::Field::Derived)); Tellico::Data::Field field5(QStringLiteral("readonly"), QStringLiteral("Readonly"), Tellico::Data::Field::ReadOnly); // should be converted to Line type QCOMPARE(field5.type(), Tellico::Data::Field::Line); QCOMPARE(field5.isSingleCategory(), false); QCOMPARE(field5.flags(), int(Tellico::Data::Field::NoEdit)); QVERIFY(field5.hasFlag(Tellico::Data::Field::NoEdit)); } + +void FieldTest::testUrlFieldLogic() { + Tellico::UrlFieldLogic logic; + // starts out with absolute urls + QCOMPARE(logic.isRelative(), false); + + // use a local data file to test + QUrl u = QUrl::fromLocalFile(QFINDTESTDATA("data/test.ris")); + // since the logic is still absolute, the url should be unchanged + QCOMPARE(logic.urlText(u), u.url()); + + logic.setRelative(true); + // since the base url is not set, the url should be unchanged + QCOMPARE(logic.urlText(u), u.url()); + + logic.setBaseUrl(QUrl(QStringLiteral("http://tellico-project.org"))); + // since the base url is not local, the url should be unchanged + QCOMPARE(logic.urlText(u), u.url()); + + // now use the local parent directory + QUrl base = u.adjusted(QUrl::RemoveFilename); + logic.setBaseUrl(base); + // url text should just be the file name since it's in the same folder + QCOMPARE(logic.urlText(u), QStringLiteral("test.ris")); + + // the base url is actually a tellico data file + base = QUrl::fromLocalFile(QFINDTESTDATA("data/with-image.tc")); + logic.setBaseUrl(base); + // url text should still be the file name since it's in the same folder + QCOMPARE(logic.urlText(u), QStringLiteral("test.ris")); +} diff --git a/src/tests/fieldtest.h b/src/tests/fieldtest.h index ae5b3be6..8735c748 100644 --- a/src/tests/fieldtest.h +++ b/src/tests/fieldtest.h @@ -1,37 +1,38 @@ /*************************************************************************** Copyright (C) 2009 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #ifndef FIELDTEST_H #define FIELDTEST_H #include class FieldTest : public QObject { Q_OBJECT private Q_SLOTS: void testAll(); + void testUrlFieldLogic(); }; #endif