Commit b17b85bc authored by Laurent Montel's avatar Laurent Montel 😁

Allow to test shorturlengine

parent 7faffdf7
......@@ -262,6 +262,7 @@ add_subdirectory(storageservice/box/tests)
add_subdirectory(storageservice/dropbox/icons/)
add_subdirectory(baloodebug/autotests)
add_subdirectory(baloodebug/tests)
add_subdirectory(shorturl/autotests)
if( LibKGAPI2_FOUND )
add_subdirectory(storageservice/gdrive/tests/)
......
include_directories(${CMAKE_SOURCE_DIR}/pimcommon/
)
set( shorturlenginetest_source shorturlenginestest.cpp )
kde4_add_unit_test( shorturlenginetest ${shorturlenginetest_source})
target_link_libraries( shorturlenginetest ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} pimcommon)
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "shorturlenginestest.h"
#include "pimcommon/shorturl/shorturlutils.h"
#include "pimcommon/shorturl/abstractshorturl.h"
#include <qtest_kde.h>
#include <QSignalSpy>
ShortUrlEnginesTest::ShortUrlEnginesTest(QObject *parent)
: QObject(parent)
{
}
ShortUrlEnginesTest::~ShortUrlEnginesTest()
{
}
void ShortUrlEnginesTest::shouldCreateEngine()
{
for (int i=0; i <PimCommon::ShortUrlUtils::EndListEngine; ++i) {
PimCommon::AbstractShortUrl *abstrShortUrl = PimCommon::ShortUrlUtils::loadEngine(static_cast<PimCommon::ShortUrlUtils::EngineType>(i), 0);
QVERIFY(abstrShortUrl);
delete abstrShortUrl;
}
}
void ShortUrlEnginesTest::shouldtestenginesData()
{
}
void ShortUrlEnginesTest::shouldTestEngines()
{
}
QTEST_KDEMAIN(ShortUrlEnginesTest, NoGUI)
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SHORTURLENGINESTEST_H
#define SHORTURLENGINESTEST_H
#include <QObject>
class ShortUrlEnginesTest : public QObject
{
Q_OBJECT
public:
explicit ShortUrlEnginesTest(QObject *parent = 0);
~ShortUrlEnginesTest();
private Q_SLOTS:
void shouldCreateEngine();
void shouldtestenginesData();
void shouldTestEngines();
};
#endif // SHORTURLENGINESTEST_H
......@@ -31,8 +31,18 @@
PimCommon::AbstractShortUrl *PimCommon::ShortUrlUtils::loadEngine(QObject *parent)
{
PimCommon::AbstractShortUrl *engine = 0;
PimCommon::ShortUrlUtils::EngineType type = static_cast<PimCommon::ShortUrlUtils::EngineType>(readEngineSettings());
PimCommon::AbstractShortUrl *engine = PimCommon::ShortUrlUtils::loadEngine(type, parent);
if (!engine) {
qDebug()<<" Engine type undefined "<<type;
engine = new PimCommon::GoogleShortUrl(parent);
}
return engine;
}
PimCommon::AbstractShortUrl *PimCommon::ShortUrlUtils::loadEngine(PimCommon::ShortUrlUtils::EngineType type, QObject *parent)
{
PimCommon::AbstractShortUrl *engine = 0;
switch (type) {
case Google:
engine = new PimCommon::GoogleShortUrl(parent);
......@@ -48,8 +58,6 @@ PimCommon::AbstractShortUrl *PimCommon::ShortUrlUtils::loadEngine(QObject *paren
break;
case EndListEngine:
default:
qDebug()<<" Engine type undefined "<<type;
engine = new PimCommon::GoogleShortUrl(parent);
break;
}
return engine;
......
......@@ -19,6 +19,7 @@
#define SHORTURLUTILS_H
#include <QObject>
#include "pimcommon_export.h"
namespace PimCommon {
class AbstractShortUrl;
......@@ -34,6 +35,7 @@ namespace ShortUrlUtils
};
QString stringFromEngineType(EngineType type);
AbstractShortUrl *loadEngine(QObject *parent);
PIMCOMMON_EXPORT PimCommon::AbstractShortUrl *loadEngine(PimCommon::ShortUrlUtils::EngineType type, QObject *parent);
int readEngineSettings();
void writeEngineSettings(int value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment