Move to data driven test, in anticipation for subsequent APIs

This commit is contained in:
Luca Beltrame 2015-08-26 00:23:39 +02:00
parent d840bf5319
commit c2139d9c33
2 changed files with 49 additions and 7 deletions

View file

@ -38,14 +38,55 @@ void TestDanbooruPost::initTestCase()
void TestDanbooruPost::testPostLoading()
{
m_post = new Danbooru::DanbooruPost(m_data);
QCOMPARE(m_post->fileUrl(),
QUrl("http://konachan.net/image/eb36c568af4f4e4ea2f59eda7d8c802d/Konachan.com%20-%20205621%20azuki_%28sayori%29%20coconut_%28sayori%29%20game_cg%20nekopara%20sayori.png"));
QCOMPARE(m_post->thumbnailUrl(),
QUrl("http://konachan.net/data/preview/eb/36/eb36c568af4f4e4ea2f59eda7d8c802d.jpg"));
QCOMPARE(m_post->id(), 205621);
QCOMPARE(m_post->width(), 1280);
QCOMPARE(m_post->height(), 720);
QFETCH(int, postId);
QFETCH(int, postWidth);
QFETCH(int, postHeight);
QFETCH(int, fileSize);
QFETCH(QSet<QString>, postTags);
QFETCH(QUrl, fileUrl);
QFETCH(QUrl, thumbnailUrl);
QFETCH(QUrl, sampleUrl);
QFETCH(Danbooru::DanbooruPost::Rating, rating);
QCOMPARE(m_post->id(), postId);
QCOMPARE(m_post->width(), postWidth);
QCOMPARE(m_post->height(), postHeight);
QCOMPARE(m_post->size(), fileSize);
QCOMPARE(m_post->tags(), postTags);
QCOMPARE(m_post->fileUrl(), fileUrl);
QCOMPARE(m_post->thumbnailUrl(), thumbnailUrl);
QCOMPARE(m_post->sampleUrl(), sampleUrl);
QCOMPARE(m_post->rating(), rating);
QCOMPARE(m_post->pixmap().isNull(), true);
}
void TestDanbooruPost::testPostLoading_data()
{
QTest::addColumn<int>("postId");
QTest::addColumn<int>("postWidth");
QTest::addColumn<int>("postHeight");
QTest::addColumn<int>("fileSize");
QTest::addColumn<QSet< QString >>("postTags");
QTest::addColumn<QUrl>("fileUrl");
QTest::addColumn<QUrl>("thumbnailUrl");
QTest::addColumn<QUrl>("sampleUrl");
QTest::addColumn<Danbooru::DanbooruPost::Rating>("rating");
QSet<QString> tags = {"azuki_(sayori)", "coconut_(sayori)", "game_cg", "nekopara",
"sayori"};
QTest::newRow("konachan") << 205621 // id
<< 1280 // width
<< 720 // height
<< 885610 // file_size
<< tags // tags
<< QUrl("http://konachan.net/image/eb36c568af4f4e4ea2f59eda7d8c802d/Konachan.com%20-%20205621%20azuki_%28sayori%29%20coconut_%28sayori%29%20game_cg%20nekopara%20sayori.png")
<< QUrl("http://konachan.net/data/preview/eb/36/eb36c568af4f4e4ea2f59eda7d8c802d.jpg")
<< QUrl("http://konachan.net/jpeg/eb36c568af4f4e4ea2f59eda7d8c802d/Konachan.com%20-%20205621%20azuki_%28sayori%29%20coconut_%28sayori%29%20game_cg%20nekopara%20sayori.jpg")
<< Danbooru::DanbooruPost::Safe;
}
QTEST_MAIN(TestDanbooruPost)

View file

@ -38,6 +38,7 @@ private:
private Q_SLOTS:
void initTestCase();
void testPostLoading();
void testPostLoading_data();
};