Basic infrastructure for test tools to check that things are working
This commit is contained in:
parent
f088eb6948
commit
9a3fd3819f
6 changed files with 130 additions and 1 deletions
|
@ -29,4 +29,4 @@ target_link_libraries(danbooru PUBLIC
|
|||
|
||||
install(TARGETS danbooru ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
|
14
src/libdanbooru/tests/CMakeLists.txt
Normal file
14
src/libdanbooru/tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
set (test_SRCS
|
||||
test_konachan.cpp
|
||||
test_apis.cpp)
|
||||
|
||||
add_executable(test_service
|
||||
${test_SRCS}
|
||||
)
|
||||
target_link_libraries(test_service PRIVATE
|
||||
Qt5::Widgets
|
||||
Qt5::Core
|
||||
KF5::KIOCore
|
||||
KF5::GuiAddons
|
||||
danbooru
|
||||
)
|
13
src/libdanbooru/tests/test_apis.cpp
Normal file
13
src/libdanbooru/tests/test_apis.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
#include "test_konachan.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTimer>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
qDebug() << "Starting Konachan API test";
|
||||
Danbooru::KonachanServiceTest* testSvc = new Danbooru::KonachanServiceTest();
|
||||
QTimer::singleShot(2000, testSvc, &Danbooru::KonachanServiceTest::testPostService);
|
||||
app.exec();
|
||||
}
|
0
src/libdanbooru/tests/test_connect.h
Normal file
0
src/libdanbooru/tests/test_connect.h
Normal file
48
src/libdanbooru/tests/test_konachan.cpp
Normal file
48
src/libdanbooru/tests/test_konachan.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2015 Luca Beltrame <lbeltrame@kde.org>
|
||||
*
|
||||
* This file is part of Danbooru Client.
|
||||
*
|
||||
* Danbooru Client 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Danbooru Client 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 Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test_konachan.h"
|
||||
|
||||
namespace Danbooru {
|
||||
|
||||
KonachanServiceTest::KonachanServiceTest():
|
||||
m_service(0)
|
||||
{
|
||||
m_service = new KonachanDanbooruService(boardUrl);
|
||||
m_service->setMaxPosts(1);
|
||||
connect(m_service, &DanbooruServiceBase::postDownloaded, this, &KonachanServiceTest::showPostData);
|
||||
}
|
||||
|
||||
KonachanServiceTest::~KonachanServiceTest() {
|
||||
delete m_service;
|
||||
}
|
||||
|
||||
void KonachanServiceTest::testPostService() {
|
||||
m_service->getPostList();
|
||||
}
|
||||
|
||||
void KonachanServiceTest::showPostData(DanbooruPost* post) {
|
||||
qDebug() << "Post File URL" << post->fileUrl().toString();
|
||||
qDebug() << "Post ID" << post->id();
|
||||
qDebug() << "Post tags" << post->tags();
|
||||
qDebug() << "Post rating" << post->rating();
|
||||
post->pixmap().save("tmp.png");
|
||||
}
|
||||
|
||||
} // namespace Danbooru
|
54
src/libdanbooru/tests/test_konachan.h
Normal file
54
src/libdanbooru/tests/test_konachan.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2015 Luca Beltrame <lbeltrame@kde.org>
|
||||
*
|
||||
* This file is part of Danbooru Client.
|
||||
*
|
||||
* Danbooru Client 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Danbooru Client 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 Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DANBOORU_TEST_CONNECT_H_
|
||||
#define DANBOORU_TEST_CONNECT_H_
|
||||
|
||||
#include "../konachan.h"
|
||||
#include "../servicebase.h"
|
||||
#include "../danboorupost.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
|
||||
namespace Danbooru {
|
||||
|
||||
class KonachanServiceTest: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
DanbooruServiceBase* m_service;
|
||||
const QUrl boardUrl = QUrl("http://www.konachan.com");
|
||||
public:
|
||||
KonachanServiceTest();
|
||||
~KonachanServiceTest();
|
||||
|
||||
void testPostService();
|
||||
|
||||
private Q_SLOTS:
|
||||
void showPostData(DanbooruPost* post);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue