Refactor the test application so that it is board URL agnostic
This commit is contained in:
		
					parent
					
						
							
								08402657a0
							
						
					
				
			
			
				commit
				
					
						e8b64a4ad9
					
				
			
		
					 3 changed files with 52 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -5,9 +5,13 @@
 | 
			
		|||
#include <QTimer>
 | 
			
		||||
#include <QCommandLineParser>
 | 
			
		||||
 | 
			
		||||
void runKonachanTest();
 | 
			
		||||
void runTest(QUrl apiUrl);
 | 
			
		||||
void runPostTest();
 | 
			
		||||
void runNextPostPageTest();
 | 
			
		||||
void runPoolTest();
 | 
			
		||||
void runPoolRetrieval();
 | 
			
		||||
 | 
			
		||||
void runYandeReTest();
 | 
			
		||||
void runDanbooruTest();
 | 
			
		||||
 | 
			
		||||
Danbooru::KonachanServiceTest* testSvc = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -22,37 +26,57 @@ int main(int argc, char *argv[]) {
 | 
			
		|||
    QCommandLineOption testYandeRe("test-yandere", "Run yande.re tests");
 | 
			
		||||
 | 
			
		||||
    cmdParser.addOptions({testKonachan, testYandeRe});
 | 
			
		||||
 | 
			
		||||
//     cmdParser.addOption(testKonachan);
 | 
			
		||||
//     cmdParser.addOption(testYandeRe);
 | 
			
		||||
 | 
			
		||||
    cmdParser.process(app);
 | 
			
		||||
 | 
			
		||||
    if (cmdParser.isSet(testKonachan)) {
 | 
			
		||||
        runKonachanTest();
 | 
			
		||||
        qDebug() << "Starting Konachan.com test";
 | 
			
		||||
        runTest(QUrl("http://konachan.com"));
 | 
			
		||||
    } else if (cmdParser.isSet(testYandeRe)) {
 | 
			
		||||
        runYandeReTest();
 | 
			
		||||
        qDebug() << "Starting yande.re test";
 | 
			
		||||
        runTest(QUrl("http://yande.re"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    app.exec();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void runKonachanTest()
 | 
			
		||||
void runTest(QUrl apiUrl)
 | 
			
		||||
{
 | 
			
		||||
    qDebug() << "Starting Konachan API test";
 | 
			
		||||
    qDebug() << "------ POST TEST ----";
 | 
			
		||||
    testSvc = new Danbooru::KonachanServiceTest(QUrl("http://konachan.com"));
 | 
			
		||||
    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 runYandeReTest()
 | 
			
		||||
void runPoolRetrieval()
 | 
			
		||||
{
 | 
			
		||||
    qDebug() << "Starting yande.re API test";
 | 
			
		||||
    testSvc = new Danbooru::KonachanServiceTest(QUrl("http://yande.re"));
 | 
			
		||||
    qDebug() << "------ POST TEST ----";
 | 
			
		||||
    testSvc->testPostService();
 | 
			
		||||
    qDebug() << "--- POOL TEST ---";
 | 
			
		||||
    testSvc->testPoolService();
 | 
			
		||||
    QObject::disconnect(testSvc->service(), &Danbooru::DanbooruServiceBase::poolDownloadFinished,
 | 
			
		||||
                        testSvc, 0);
 | 
			
		||||
    qDebug() << "--- POOL RETRIEVAL TEST ---";
 | 
			
		||||
    testSvc->testPoolRetrieval(300);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,11 @@ void KonachanServiceTest::testPostService() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void KonachanServiceTest::testPoolService() {
 | 
			
		||||
    m_service->getPoolList();
 | 
			
		||||
    m_service->getPoolList(1 /*limit */);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void KonachanServiceTest::testPoolRetrieval(int postid) {
 | 
			
		||||
    m_service->getPool(postid);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void KonachanServiceTest::showPostData(DanbooruPost* post) {
 | 
			
		||||
| 
						 | 
				
			
			@ -67,8 +71,8 @@ void KonachanServiceTest::showPoolData(DanbooruPool* pool) {
 | 
			
		|||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QLabel* KonachanServiceTest::previewLabel() const {
 | 
			
		||||
    return m_label;
 | 
			
		||||
DanbooruServiceBase* KonachanServiceTest::service() const {
 | 
			
		||||
    return m_service;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace Danbooru
 | 
			
		||||
| 
						 | 
				
			
			@ -64,8 +64,9 @@ public:
 | 
			
		|||
 | 
			
		||||
    void testPostService();
 | 
			
		||||
    void testPoolService();
 | 
			
		||||
    void testPoolRetrieval(int postid = 300);
 | 
			
		||||
    void testTagService();
 | 
			
		||||
    QLabel* previewLabel() const;
 | 
			
		||||
    DanbooruServiceBase* service() const;
 | 
			
		||||
 | 
			
		||||
private Q_SLOTS:
 | 
			
		||||
    void showPostData(DanbooruPost* post);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue