82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
|
|
#include "test_konachan.h"
|
|
|
|
#include <QApplication>
|
|
#include <QTimer>
|
|
#include <QCommandLineParser>
|
|
|
|
void runTest(QUrl apiUrl);
|
|
void runPostTest();
|
|
void runNextPostPageTest();
|
|
void runPoolTest();
|
|
void runPoolRetrieval();
|
|
|
|
void runYandeReTest();
|
|
|
|
Danbooru::KonachanServiceTest* testSvc = 0;
|
|
|
|
int main(int argc, char *argv[]) {
|
|
QApplication app(argc, argv);
|
|
|
|
QCommandLineParser cmdParser;
|
|
cmdParser.addHelpOption();
|
|
cmdParser.addVersionOption();
|
|
|
|
QCommandLineOption testKonachan("test-konachan", "Run Konachan.com tests");
|
|
QCommandLineOption testYandeRe("test-yandere", "Run yande.re tests");
|
|
|
|
cmdParser.addOptions({testKonachan, testYandeRe});
|
|
cmdParser.process(app);
|
|
|
|
if (cmdParser.isSet(testKonachan)) {
|
|
qDebug() << "Starting Konachan.com test";
|
|
runTest(QUrl("http://konachan.com"));
|
|
} else if (cmdParser.isSet(testYandeRe)) {
|
|
qDebug() << "Starting yande.re test";
|
|
runTest(QUrl("http://yande.re"));
|
|
}
|
|
|
|
app.exec();
|
|
}
|
|
|
|
void runTest(QUrl apiUrl)
|
|
{
|
|
testSvc = new Danbooru::KonachanServiceTest(apiUrl);
|
|
|
|
QObject::connect(testSvc->service(), &Danbooru::DanbooruServiceBase::postDownloadFinished,
|
|
testSvc, &runNextPostPageTest);
|
|
QObject::connect(testSvc->service(), &Danbooru::DanbooruServiceBase::poolDownloadFinished,
|
|
testSvc, &runPoolRetrieval);
|
|
qDebug() << "--- POST TEST ---";
|
|
testSvc->testPostService();
|
|
|
|
}
|
|
|
|
void runNextPostPageTest()
|
|
{
|
|
QObject::disconnect(testSvc->service(), &Danbooru::DanbooruServiceBase::postDownloadFinished,
|
|
testSvc, 0);
|
|
qDebug() << "--- NEXT POST PAGE TEST ---";
|
|
QObject::connect(testSvc->service(), &Danbooru::DanbooruServiceBase::postDownloadFinished,
|
|
testSvc, &runPoolTest);
|
|
qDebug() << "--- NEXT POST PAGE TEST ---";
|
|
testSvc->service()->nextPostPage();
|
|
}
|
|
|
|
|
|
void runPoolTest()
|
|
{
|
|
QObject::disconnect(testSvc->service(), &Danbooru::DanbooruServiceBase::postDownloadFinished,
|
|
testSvc, 0);
|
|
testSvc->service()->nextPostPage();
|
|
qDebug() << "--- POOL TEST ---";
|
|
testSvc->testPoolService();
|
|
}
|
|
|
|
void runPoolRetrieval()
|
|
{
|
|
QObject::disconnect(testSvc->service(), &Danbooru::DanbooruServiceBase::poolDownloadFinished,
|
|
testSvc, 0);
|
|
qDebug() << "--- POOL RETRIEVAL TEST ---";
|
|
testSvc->testPoolRetrieval(300);
|
|
}
|