summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2012-01-16 11:23:30 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-17 04:54:01 +0100
commitb93ce4d78c7a35950a72fde26dda3816301f27b3 (patch)
tree94a8e01c63de71b1ee529621b6e61a1fff90eecf /tests/auto/gui
parent7beeb932fd5cbe4e213a755001f784508a63572d (diff)
Changed qimagewriter unittest to work from install directory.
- Changed to use QFINDTESTDATA and TESTDATA - skip testing permissions if test run as root user Change-Id: I5b308789202b01bdd0d630af65775ae23bf0cc4c Reviewed-by: Kurt Korbatits <kurt.korbatits@nokia.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/qimagewriter/qimagewriter.pro9
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp33
2 files changed, 25 insertions, 17 deletions
diff --git a/tests/auto/gui/image/qimagewriter/qimagewriter.pro b/tests/auto/gui/image/qimagewriter/qimagewriter.pro
index 10c950cf0a..78fb183b22 100644
--- a/tests/auto/gui/image/qimagewriter/qimagewriter.pro
+++ b/tests/auto/gui/image/qimagewriter/qimagewriter.pro
@@ -7,11 +7,4 @@ MOC_DIR=tmp
win32-msvc:QMAKE_CXXFLAGS -= -Zm200
win32-msvc:QMAKE_CXXFLAGS += -Zm800
-wince*: {
- addFiles.files = images\\*.*
- addFiles.path = images
- DEPLOYMENT += addFiles
- DEFINES += SRCDIR=\\\".\\\"
-} else {
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
+TESTDATA += images/*
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index 9acf210eeb..681dc87ae3 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -71,6 +71,7 @@ public:
public slots:
void init();
+ void initTestCase();
void cleanup();
private slots:
@@ -100,10 +101,10 @@ private slots:
void resolution();
void saveToTemporaryFile();
+private:
+ QString prefix;
};
-static const QLatin1String prefix(SRCDIR "/images/");
-
static void initializePadding(QImage *image)
{
int effectiveBytesPerLine = (image->width() * image->depth() + 7) / 8;
@@ -115,6 +116,13 @@ static void initializePadding(QImage *image)
}
}
+void tst_QImageWriter::initTestCase()
+{
+ prefix = QFINDTESTDATA("images/");
+ if (prefix.isEmpty())
+ QFAIL("Can't find images directory!");
+}
+
// Testing get/set functions
void tst_QImageWriter::getSetCheck()
{
@@ -217,15 +225,22 @@ void tst_QImageWriter::writeImage()
}
{
- // Shouldn't be able to write to read-only file
- QFile sourceFile(prefix + "gen-" + fileName);
- QFile::Permissions permissions = sourceFile.permissions();
- QVERIFY(sourceFile.setPermissions(QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther));
+ bool skip = false;
+#if defined(Q_OS_UNIX)
+ if (::geteuid() == 0)
+ skip = true;
+#endif
+ if (!skip) {
+ // Shouldn't be able to write to read-only file
+ QFile sourceFile(prefix + "gen-" + fileName);
+ QFile::Permissions permissions = sourceFile.permissions();
+ QVERIFY(sourceFile.setPermissions(QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther));
- QImageWriter writer(prefix + "gen-" + fileName, format);
- QVERIFY(!writer.write(image));
+ QImageWriter writer(prefix + "gen-" + fileName, format);
+ QVERIFY(!writer.write(image));
- QVERIFY(sourceFile.setPermissions(permissions));
+ QVERIFY(sourceFile.setPermissions(permissions));
+ }
}
QImage image2;