Fix tst_bench_qimagereader
It couldn't find the test images if not build in sources. Change-Id: Ieeb5a76694a37d05b3e9a4ed0154885040b0812f Reviewed-by: Daniel Smith <Daniel.Smith@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
1d89748772
commit
2cddaf0071
@ -8,3 +8,5 @@ SOURCES += tst_qimagereader.cpp
|
||||
|
||||
qtConfig(gif): DEFINES += QTEST_HAVE_GIF
|
||||
qtConfig(jpeg): DEFINES += QTEST_HAVE_JPEG
|
||||
|
||||
TESTDATA += images/*
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
virtual ~tst_QImageReader();
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
@ -69,6 +70,7 @@ private slots:
|
||||
|
||||
private:
|
||||
QList< QPair<QString, QByteArray> > images; // filename, format
|
||||
QString prefix;
|
||||
};
|
||||
|
||||
tst_QImageReader::tst_QImageReader()
|
||||
@ -102,6 +104,13 @@ tst_QImageReader::~tst_QImageReader()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QImageReader::initTestCase()
|
||||
{
|
||||
prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("Can't find images directory!");
|
||||
}
|
||||
|
||||
void tst_QImageReader::init()
|
||||
{
|
||||
}
|
||||
@ -128,7 +137,7 @@ void tst_QImageReader::readImage()
|
||||
QFETCH(QByteArray, format);
|
||||
|
||||
QBENCHMARK {
|
||||
QImageReader io("images/" + fileName, format);
|
||||
QImageReader io(prefix + fileName, format);
|
||||
QImage image = io.read();
|
||||
QVERIFY(!image.isNull());
|
||||
}
|
||||
@ -159,7 +168,7 @@ void tst_QImageReader::setScaledSize()
|
||||
QFETCH(QByteArray, format);
|
||||
|
||||
QBENCHMARK {
|
||||
QImageReader reader("images/" + fileName, format);
|
||||
QImageReader reader(prefix + fileName, format);
|
||||
reader.setScaledSize(newSize);
|
||||
QImage image = reader.read();
|
||||
QCOMPARE(image.size(), newSize);
|
||||
@ -186,7 +195,7 @@ void tst_QImageReader::setClipRect()
|
||||
QFETCH(QByteArray, format);
|
||||
|
||||
QBENCHMARK {
|
||||
QImageReader reader("images/" + fileName, format);
|
||||
QImageReader reader(prefix + fileName, format);
|
||||
reader.setClipRect(newRect);
|
||||
QImage image = reader.read();
|
||||
QCOMPARE(image.rect(), newRect);
|
||||
@ -205,7 +214,7 @@ void tst_QImageReader::setScaledClipRect()
|
||||
QFETCH(QByteArray, format);
|
||||
|
||||
QBENCHMARK {
|
||||
QImageReader reader("images/" + fileName, format);
|
||||
QImageReader reader(prefix + fileName, format);
|
||||
reader.setScaledSize(QSize(300, 300));
|
||||
reader.setScaledClipRect(newRect);
|
||||
QImage image = reader.read();
|
||||
|
Loading…
x
Reference in New Issue
Block a user