Move to data driven test, in anticipation for subsequent APIs
This commit is contained in:
		
					parent
					
						
							
								d840bf5319
							
						
					
				
			
			
				commit
				
					
						c2139d9c33
					
				
			
		
					 2 changed files with 49 additions and 7 deletions
				
			
		| 
						 | 
					@ -38,14 +38,55 @@ void TestDanbooruPost::initTestCase()
 | 
				
			||||||
void TestDanbooruPost::testPostLoading()
 | 
					void TestDanbooruPost::testPostLoading()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_post = new Danbooru::DanbooruPost(m_data);
 | 
					    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"));
 | 
					    QFETCH(int, postId);
 | 
				
			||||||
    QCOMPARE(m_post->thumbnailUrl(),
 | 
					    QFETCH(int, postWidth);
 | 
				
			||||||
             QUrl("http://konachan.net/data/preview/eb/36/eb36c568af4f4e4ea2f59eda7d8c802d.jpg"));
 | 
					    QFETCH(int, postHeight);
 | 
				
			||||||
    QCOMPARE(m_post->id(), 205621);
 | 
					    QFETCH(int, fileSize);
 | 
				
			||||||
    QCOMPARE(m_post->width(), 1280);
 | 
					    QFETCH(QSet<QString>, postTags);
 | 
				
			||||||
    QCOMPARE(m_post->height(), 720);
 | 
					    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)
 | 
					QTEST_MAIN(TestDanbooruPost)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +38,7 @@ private:
 | 
				
			||||||
private Q_SLOTS:
 | 
					private Q_SLOTS:
 | 
				
			||||||
    void initTestCase();
 | 
					    void initTestCase();
 | 
				
			||||||
    void testPostLoading();
 | 
					    void testPostLoading();
 | 
				
			||||||
 | 
					    void testPostLoading_data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue