Changed qicon unittest to work from installation directory

- Changed to use QFINDTESTDATA and TESTDATA

Change-Id: Ic9fedac82d32f8484a9d915d9d91fdaabedc85e2
Reviewed-by: Kurt Korbatits  <kurt.korbatits@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
Kurt Korbatits 2012-01-17 09:39:20 +10:00 committed by Qt by Nokia
parent 50248b1dac
commit 402a8c036b
2 changed files with 5 additions and 35 deletions

View File

@ -7,15 +7,6 @@ RESOURCES = tst_qicon.qrc
wince* {
QT += xml svg
addFiles.files += $$_PRO_FILE_PWD_/*.png
addFiles.files += $$_PRO_FILE_PWD_/*.svg
addFiles.files += $$_PRO_FILE_PWD_/*.svgz
addFiles.files += $$_PRO_FILE_PWD_/tst_qicon.cpp
addFiles.path = .
DEPLOYMENT += addFiles
DEPLOYMENT_PLUGIN += qsvg
DEFINES += SRCDIR=\\\".\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
TESTDATA += icons/* *.png *.svg *.svgz

View File

@ -54,9 +54,6 @@ public:
tst_QIcon();
private slots:
void init();
void cleanup();
void actualSize_data(); // test with 1 pixmap
void actualSize();
void actualSize2_data(); // test with 2 pixmaps with different aspect ratio
@ -82,8 +79,6 @@ private slots:
private:
bool haveImageFormat(QByteArray const&);
QString oldCurrentDir;
const static QIcon staticIcon;
};
@ -91,22 +86,6 @@ private:
// But we do not officially support this. See QTBUG-8666
const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find");
void tst_QIcon::init()
{
QString srcdir(QLatin1String(SRCDIR));
if (!srcdir.isEmpty()) {
oldCurrentDir = QDir::current().absolutePath();
QDir::setCurrent(srcdir);
}
}
void tst_QIcon::cleanup()
{
if (!oldCurrentDir.isEmpty()) {
QDir::setCurrent(oldCurrentDir);
}
}
bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat)
{
return QImageReader::supportedImageFormats().contains(desiredFormat);
@ -136,7 +115,7 @@ void tst_QIcon::actualSize_data()
QTest::newRow("resource9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30);
QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40);
const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/");
const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/";
QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128);
QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64);
QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32);
@ -191,7 +170,7 @@ void tst_QIcon::actualSize2_data()
void tst_QIcon::actualSize2()
{
QIcon icon;
const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/");
const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/";
icon.addPixmap(QPixmap(prefix + "image.png"));
icon.addPixmap(QPixmap(prefix + "rect.png"));
@ -209,7 +188,7 @@ void tst_QIcon::svgActualSize()
QSKIP("SVG support is not available");
}
const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/");
const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/";
QIcon icon(prefix + "rect.svg");
QCOMPARE(icon.actualSize(QSize(16, 16)), QSize(16, 2));
QCOMPARE(icon.pixmap(QSize(16, 16)).size(), QSize(16, 2));
@ -252,7 +231,7 @@ void tst_QIcon::isNull() {
QVERIFY(!iconNoFileSuffix.isNull());
QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid());
const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/");
const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/";
// test string constructor with existing file but unsupported format
QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp");
QVERIFY(!iconUnsupportedFormat.isNull());