diff options
author | BogDan Vatra <bogdan@kde.org> | 2015-01-08 09:57:10 +0200 |
---|---|---|
committer | BogDan Vatra <bogdan@kde.org> | 2015-01-08 10:02:23 +0100 |
commit | 57949b5f2d1434fd935b94331dcf97a81663d6db (patch) | |
tree | 467a0b965f53461d7f6482cd75a898611117d9ca /tests | |
parent | 05b96ae5d7f4c42bce5b82a68139eb1f90bf1e10 (diff) | |
download | qtbase-57949b5f2d1434fd935b94331dcf97a81663d6db.tar.gz qtbase-57949b5f2d1434fd935b94331dcf97a81663d6db.tar.bz2 qtbase-57949b5f2d1434fd935b94331dcf97a81663d6db.zip |
Android: Fix qimagewriter test.
We must add all test data to resources. Write output data into a writable location.
Change-Id: I5a1c212f6108abf2a82288a2c84cfb31eda5e101
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/image/qimagewriter/qimagewriter.pro | 2 | ||||
-rw-r--r-- | tests/auto/gui/image/qimagewriter/qimagewriter.qrc | 16 | ||||
-rw-r--r-- | tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp | 30 |
3 files changed, 35 insertions, 13 deletions
diff --git a/tests/auto/gui/image/qimagewriter/qimagewriter.pro b/tests/auto/gui/image/qimagewriter/qimagewriter.pro index f77ff0659b..ce6707ec92 100644 --- a/tests/auto/gui/image/qimagewriter/qimagewriter.pro +++ b/tests/auto/gui/image/qimagewriter/qimagewriter.pro @@ -5,5 +5,5 @@ SOURCES += tst_qimagewriter.cpp MOC_DIR=tmp win32-msvc:QMAKE_CXXFLAGS -= -Zm200 win32-msvc:QMAKE_CXXFLAGS += -Zm800 - +android:!android-no-sdk:RESOURCES+= qimagewriter.qrc TESTDATA += images/* diff --git a/tests/auto/gui/image/qimagewriter/qimagewriter.qrc b/tests/auto/gui/image/qimagewriter/qimagewriter.qrc new file mode 100644 index 0000000000..29b036e303 --- /dev/null +++ b/tests/auto/gui/image/qimagewriter/qimagewriter.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>images/beavis.jpg</file> + <file>images/colorful.bmp</file> + <file>images/earth.gif</file> + <file>images/font.bmp</file> + <file>images/gnus.xbm</file> + <file>images/kollada.png</file> + <file>images/marble.xpm</file> + <file>images/ship63.pbm</file> + <file>images/teapot.ppm</file> + <file>images/trolltech.gif</file> + <file>images/YCbCr_cmyk.jpg</file> + <file>images/YCbCr_rgb.jpg</file> + </qresource> +</RCC> diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index 7e826310a1..f1045a8cf7 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -90,6 +90,7 @@ private slots: void saveToTemporaryFile(); private: QString prefix; + QString writePrefix; }; // helper to skip an autotest when the given image format is not supported @@ -114,6 +115,11 @@ void tst_QImageWriter::initTestCase() prefix = QFINDTESTDATA("images/"); if (prefix.isEmpty()) QFAIL("Can't find images directory!"); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + writePrefix = QDir::homePath(); +#else + writePrefix = prefix; +#endif } // Testing get/set functions @@ -212,7 +218,7 @@ void tst_QImageWriter::writeImage() QVERIFY2(!image.isNull(), qPrintable(reader.errorString())); } { - QImageWriter writer(prefix + "gen-" + fileName, format); + QImageWriter writer(writePrefix + "gen-" + fileName, format); QVERIFY(writer.write(image)); } @@ -224,11 +230,11 @@ void tst_QImageWriter::writeImage() #endif if (!skip) { // Shouldn't be able to write to read-only file - QFile sourceFile(prefix + "gen-" + fileName); + QFile sourceFile(writePrefix + "gen-" + fileName); QFile::Permissions permissions = sourceFile.permissions(); QVERIFY(sourceFile.setPermissions(QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther)); - QImageWriter writer(prefix + "gen-" + fileName, format); + QImageWriter writer(writePrefix + "gen-" + fileName, format); QVERIFY(!writer.write(image)); QVERIFY(sourceFile.setPermissions(permissions)); @@ -237,7 +243,7 @@ void tst_QImageWriter::writeImage() QImage image2; { - QImageReader reader(prefix + "gen-" + fileName); + QImageReader reader(writePrefix + "gen-" + fileName); image2 = reader.read(); QVERIFY(!image2.isNull()); } @@ -456,7 +462,7 @@ void tst_QImageWriter::supportsOption() << QImageIOHandler::Animation << QImageIOHandler::BackgroundColor; - QImageWriter writer(prefix + fileName); + QImageWriter writer(writePrefix + fileName); for (int i = 0; i < options.size(); ++i) { QVERIFY(writer.supportsOption(QImageIOHandler::ImageOption(options.at(i)))); allOptions.remove(QImageIOHandler::ImageOption(options.at(i))); @@ -472,13 +478,13 @@ void tst_QImageWriter::saveWithNoFormat_data() QTest::addColumn<QByteArray>("format"); QTest::addColumn<QImageWriter::ImageWriterError>("error"); - QTest::newRow("garble") << prefix + QString("gen-out.garble") << QByteArray("jpeg") << QImageWriter::UnsupportedFormatError; - QTest::newRow("bmp") << prefix + QString("gen-out.bmp") << QByteArray("bmp") << QImageWriter::ImageWriterError(0); - QTest::newRow("xbm") << prefix + QString("gen-out.xbm") << QByteArray("xbm") << QImageWriter::ImageWriterError(0); - QTest::newRow("xpm") << prefix + QString("gen-out.xpm") << QByteArray("xpm") << QImageWriter::ImageWriterError(0); - QTest::newRow("png") << prefix + QString("gen-out.png") << QByteArray("png") << QImageWriter::ImageWriterError(0); - QTest::newRow("ppm") << prefix + QString("gen-out.ppm") << QByteArray("ppm") << QImageWriter::ImageWriterError(0); - QTest::newRow("pbm") << prefix + QString("gen-out.pbm") << QByteArray("pbm") << QImageWriter::ImageWriterError(0); + QTest::newRow("garble") << writePrefix + QString("gen-out.garble") << QByteArray("jpeg") << QImageWriter::UnsupportedFormatError; + QTest::newRow("bmp") << writePrefix + QString("gen-out.bmp") << QByteArray("bmp") << QImageWriter::ImageWriterError(0); + QTest::newRow("xbm") << writePrefix + QString("gen-out.xbm") << QByteArray("xbm") << QImageWriter::ImageWriterError(0); + QTest::newRow("xpm") << writePrefix + QString("gen-out.xpm") << QByteArray("xpm") << QImageWriter::ImageWriterError(0); + QTest::newRow("png") << writePrefix + QString("gen-out.png") << QByteArray("png") << QImageWriter::ImageWriterError(0); + QTest::newRow("ppm") << writePrefix + QString("gen-out.ppm") << QByteArray("ppm") << QImageWriter::ImageWriterError(0); + QTest::newRow("pbm") << writePrefix + QString("gen-out.pbm") << QByteArray("pbm") << QImageWriter::ImageWriterError(0); } void tst_QImageWriter::saveWithNoFormat() |