Simplify test loading
This commit is contained in:
parent
c2139d9c33
commit
b763cfbff3
2 changed files with 28 additions and 21 deletions
|
@ -28,16 +28,21 @@
|
||||||
|
|
||||||
void TestDanbooruPost::initTestCase()
|
void TestDanbooruPost::initTestCase()
|
||||||
{
|
{
|
||||||
QFile file;
|
|
||||||
file.setFileName(m_fileName);
|
|
||||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
||||||
bool ok;
|
|
||||||
m_data = Danbooru::parseDanbooruResult(file.readAll(), &ok).toList().at(0).toMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDanbooruPost::testPostLoading()
|
void TestDanbooruPost::testPostLoading()
|
||||||
{
|
{
|
||||||
m_post = new Danbooru::DanbooruPost(m_data);
|
QFETCH(QString, jsonFile);
|
||||||
|
auto fileName = QFINDTESTDATA(jsonFile);
|
||||||
|
|
||||||
|
QFile file;
|
||||||
|
file.setFileName(fileName);
|
||||||
|
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
auto data = Danbooru::parseDanbooruResult(file.readAll(), &ok).toList().at(0).toMap();
|
||||||
|
auto post = new Danbooru::DanbooruPost(data);
|
||||||
|
|
||||||
QFETCH(int, postId);
|
QFETCH(int, postId);
|
||||||
QFETCH(int, postWidth);
|
QFETCH(int, postWidth);
|
||||||
|
@ -49,20 +54,21 @@ void TestDanbooruPost::testPostLoading()
|
||||||
QFETCH(QUrl, sampleUrl);
|
QFETCH(QUrl, sampleUrl);
|
||||||
QFETCH(Danbooru::DanbooruPost::Rating, rating);
|
QFETCH(Danbooru::DanbooruPost::Rating, rating);
|
||||||
|
|
||||||
QCOMPARE(m_post->id(), postId);
|
QCOMPARE(post->id(), postId);
|
||||||
QCOMPARE(m_post->width(), postWidth);
|
QCOMPARE(post->width(), postWidth);
|
||||||
QCOMPARE(m_post->height(), postHeight);
|
QCOMPARE(post->height(), postHeight);
|
||||||
QCOMPARE(m_post->size(), fileSize);
|
QCOMPARE(post->size(), fileSize);
|
||||||
QCOMPARE(m_post->tags(), postTags);
|
QCOMPARE(post->tags(), postTags);
|
||||||
QCOMPARE(m_post->fileUrl(), fileUrl);
|
QCOMPARE(post->fileUrl(), fileUrl);
|
||||||
QCOMPARE(m_post->thumbnailUrl(), thumbnailUrl);
|
QCOMPARE(post->thumbnailUrl(), thumbnailUrl);
|
||||||
QCOMPARE(m_post->sampleUrl(), sampleUrl);
|
QCOMPARE(post->sampleUrl(), sampleUrl);
|
||||||
QCOMPARE(m_post->rating(), rating);
|
QCOMPARE(post->rating(), rating);
|
||||||
QCOMPARE(m_post->pixmap().isNull(), true);
|
QCOMPARE(post->pixmap().isNull(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDanbooruPost::testPostLoading_data()
|
void TestDanbooruPost::testPostLoading_data()
|
||||||
{
|
{
|
||||||
|
QTest::addColumn<QString>("jsonFile");
|
||||||
QTest::addColumn<int>("postId");
|
QTest::addColumn<int>("postId");
|
||||||
QTest::addColumn<int>("postWidth");
|
QTest::addColumn<int>("postWidth");
|
||||||
QTest::addColumn<int>("postHeight");
|
QTest::addColumn<int>("postHeight");
|
||||||
|
@ -76,7 +82,9 @@ void TestDanbooruPost::testPostLoading_data()
|
||||||
QSet<QString> tags = {"azuki_(sayori)", "coconut_(sayori)", "game_cg", "nekopara",
|
QSet<QString> tags = {"azuki_(sayori)", "coconut_(sayori)", "game_cg", "nekopara",
|
||||||
"sayori"};
|
"sayori"};
|
||||||
|
|
||||||
QTest::newRow("konachan") << 205621 // id
|
// Konachan.com / yande.re
|
||||||
|
QTest::newRow("konachan") << "konachan.json" // jsonFile
|
||||||
|
<< 205621 // id
|
||||||
<< 1280 // width
|
<< 1280 // width
|
||||||
<< 720 // height
|
<< 720 // height
|
||||||
<< 885610 // file_size
|
<< 885610 // file_size
|
||||||
|
@ -85,6 +93,9 @@ void TestDanbooruPost::testPostLoading_data()
|
||||||
<< QUrl("http://konachan.net/data/preview/eb/36/eb36c568af4f4e4ea2f59eda7d8c802d.jpg")
|
<< 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")
|
<< QUrl("http://konachan.net/jpeg/eb36c568af4f4e4ea2f59eda7d8c802d/Konachan.com%20-%20205621%20azuki_%28sayori%29%20coconut_%28sayori%29%20game_cg%20nekopara%20sayori.jpg")
|
||||||
<< Danbooru::DanbooruPost::Safe;
|
<< Danbooru::DanbooruPost::Safe;
|
||||||
|
// Danbooru
|
||||||
|
|
||||||
|
// Gelbooru
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,6 @@ class TestDanbooruPost: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_fileName = QFINDTESTDATA("konachan.json");
|
|
||||||
Danbooru::DanbooruPost* m_post = nullptr;
|
|
||||||
QVariantMap m_data;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue