diff options
Diffstat (limited to 'tests/auto/gui/image')
21 files changed, 325 insertions, 292 deletions
diff --git a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro index 7ed69ce1d1..485472c70c 100644 --- a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro +++ b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qicoimageformat SOURCES+= tst_qicoimageformat.cpp QT += testlib diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp index 6d2ed6d304..2dbb078ae0 100644 --- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -38,17 +33,8 @@ class tst_QIcoImageFormat : public QObject { Q_OBJECT -public: - tst_QIcoImageFormat(); - virtual ~tst_QIcoImageFormat(); - - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); private slots: + void initTestCase(); void format(); void canRead_data(); void canRead(); @@ -71,26 +57,6 @@ private: QString m_IconPath; }; - -tst_QIcoImageFormat::tst_QIcoImageFormat() -{ -} - -tst_QIcoImageFormat::~tst_QIcoImageFormat() -{ - -} - -void tst_QIcoImageFormat::init() -{ - -} - -void tst_QIcoImageFormat::cleanup() -{ - -} - void tst_QIcoImageFormat::initTestCase() { m_IconPath = QFINDTESTDATA("icons"); @@ -98,11 +64,6 @@ void tst_QIcoImageFormat::initTestCase() QFAIL("Cannot find icons directory containing testdata!"); } -void tst_QIcoImageFormat::cleanupTestCase() -{ - -} - void tst_QIcoImageFormat::format() { { @@ -143,7 +104,7 @@ void tst_QIcoImageFormat::canRead() QFETCH(QString, fileName); QFETCH(int, isValid); - QImageReader reader(m_IconPath + "/" + fileName); + QImageReader reader(m_IconPath + QLatin1Char('/') + fileName); QCOMPARE(reader.canRead(), (isValid == 0 ? false : true)); } @@ -177,7 +138,7 @@ void tst_QIcoImageFormat::SequentialFile() QFETCH(QString, fileName); QFETCH(int, isValid); - QSequentialFile *file = new QSequentialFile(m_IconPath + "/" + fileName); + QSequentialFile *file = new QSequentialFile(m_IconPath + QLatin1Char('/') + fileName); QVERIFY(file); QVERIFY(file->open(QFile::ReadOnly)); QImageReader reader(file); @@ -214,7 +175,7 @@ void tst_QIcoImageFormat::imageCount() QFETCH(QString, fileName); QFETCH(int, count); - QImageReader reader(m_IconPath + "/" + fileName); + QImageReader reader(m_IconPath + QLatin1Char('/') + fileName); QCOMPARE(reader.imageCount(), count); } @@ -242,7 +203,7 @@ void tst_QIcoImageFormat::jumpToNextImage() QFETCH(QString, fileName); QFETCH(int, count); - QImageReader reader(m_IconPath + "/" + fileName); + QImageReader reader(m_IconPath + QLatin1Char('/') + fileName); bool bJumped = reader.jumpToImage(0); while (bJumped) { count--; @@ -265,7 +226,7 @@ void tst_QIcoImageFormat::loopCount() QFETCH(QString, fileName); QFETCH(int, count); - QImageReader reader(m_IconPath + "/" + fileName); + QImageReader reader(m_IconPath + QLatin1Char('/') + fileName); QCOMPARE(reader.loopCount(), count); } @@ -293,7 +254,7 @@ void tst_QIcoImageFormat::nextImageDelay() QFETCH(QString, fileName); QFETCH(int, count); - QImageReader reader(m_IconPath + "/" + fileName); + QImageReader reader(m_IconPath + QLatin1Char('/') + fileName); if (count == -1) { QCOMPARE(reader.nextImageDelay(), 0); } else { @@ -322,7 +283,7 @@ void tst_QIcoImageFormat::pngCompression() QFETCH(int, width); QFETCH(int, height); - QImageReader reader(m_IconPath + "/" + fileName); + QImageReader reader(m_IconPath + QLatin1Char('/') + fileName); QImage image; reader.jumpToImage(index); diff --git a/tests/auto/gui/image/qicon/icons/themeparent/icon-theme.cache b/tests/auto/gui/image/qicon/icons/themeparent/icon-theme.cache Binary files differnew file mode 100644 index 0000000000..a323875989 --- /dev/null +++ b/tests/auto/gui/image/qicon/icons/themeparent/icon-theme.cache diff --git a/tests/auto/gui/image/qicon/qicon.pro b/tests/auto/gui/image/qicon/qicon.pro index 6ff20ec8fa..f5570c2497 100644 --- a/tests/auto/gui/image/qicon/qicon.pro +++ b/tests/auto/gui/image/qicon/qicon.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qicon QT += testlib diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index 7333dd739f..a0914b7700 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -36,6 +31,7 @@ #include <QImageReader> #include <qicon.h> #include <qiconengine.h> +#include <QtCore/QStandardPaths> #include <algorithm> @@ -64,6 +60,7 @@ private slots: void streamAvailableSizes_data(); void streamAvailableSizes(); void fromTheme(); + void fromThemeCache(); #ifndef QT_NO_WIDGETS void task184901_badCache(); @@ -646,8 +643,97 @@ void tst_QIcon::fromTheme() QIcon::setThemeName(""); abIcon = QIcon::fromTheme("address-book-new"); QVERIFY(abIcon.isNull()); + + // Passing a full path to fromTheme is not very useful, but should work anyway + QIcon fullPathIcon = QIcon::fromTheme(m_pngImageFileName); + QVERIFY(!fullPathIcon.isNull()); +} + +static inline QString findGtkUpdateIconCache() +{ + QString binary = QLatin1String("gtk-update-icon-cache"); +#ifdef Q_OS_WIN + binary += QLatin1String(".exe"); +#endif + return QStandardPaths::findExecutable(binary); } +void tst_QIcon::fromThemeCache() +{ + QTemporaryDir dir; + QVERIFY2(dir.isValid(), qPrintable(dir.errorString())); + + QVERIFY(QDir().mkpath(dir.path() + QLatin1String("/testcache/16x16/actions"))); + QVERIFY(QFile(QStringLiteral(":/styles/commonstyle/images/standardbutton-open-16.png")) + .copy( dir.path() + QLatin1String("/testcache/16x16/actions/button-open.png"))); + + { + QFile index(dir.path() + QLatin1String("/testcache/index.theme")); + QVERIFY(index.open(QFile::WriteOnly)); + index.write("[Icon Theme]\nDirectories=16x16/actions\n[16x16/actions]\nSize=16\nContext=Actions\nType=Fixed\n"); + } + QIcon::setThemeSearchPaths(QStringList() << dir.path()); + QIcon::setThemeName("testcache"); + + // We just created a theme with that icon, it must exist + QVERIFY(!QIcon::fromTheme("button-open").isNull()); + + QString cacheName = dir.path() + QLatin1String("/testcache/icon-theme.cache"); + + // An invalid cache should not prevent lookup + { + QFile cacheFile(cacheName); + QVERIFY(cacheFile.open(QFile::WriteOnly)); + QDataStream(&cacheFile) << quint16(1) << quint16(0) << "invalid corrupted stuff in there\n"; + } + QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes + QVERIFY(!QIcon::fromTheme("button-open").isNull()); + + // An empty cache should prevent the lookup + { + QFile cacheFile(cacheName); + QVERIFY(cacheFile.open(QFile::WriteOnly)); + QDataStream ds(&cacheFile); + ds << quint16(1) << quint16(0); // 0: version + ds << quint32(12) << quint32(20); // 4: hash offset / dir list offset + ds << quint32(1) << quint32(0xffffffff); // 12: one empty bucket + ds << quint32(1) << quint32(28); // 20: list with one element + ds.writeRawData("16x16/actions", sizeof("16x16/actions")); // 28 + } + QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes + QVERIFY(QIcon::fromTheme("button-open").isNull()); // The icon was not in the cache, it should not be found + + // Adding an icon should be changing the modification date of one sub directory which should make the cache ignored + QTest::qWait(1000); // wait enough to have a different modification time in seconds + QVERIFY(QFile(QStringLiteral(":/styles/commonstyle/images/standardbutton-save-16.png")) + .copy(dir.path() + QLatin1String("/testcache/16x16/actions/button-save.png"))); + QVERIFY(QFileInfo(cacheName).lastModified() < QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified()); + QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes + QVERIFY(!QIcon::fromTheme("button-open").isNull()); + + // Try to run the actual gtk-update-icon-cache and make sure that icons are still found + const QString gtkUpdateIconCache = findGtkUpdateIconCache(); + if (gtkUpdateIconCache.isEmpty()) { + QIcon::setThemeSearchPaths(QStringList()); + QSKIP("gtk-update-icon-cache not run (binary not found)"); + } +#ifndef QT_NO_PROCESS + QProcess process; + process.start(gtkUpdateIconCache, + QStringList() << QStringLiteral("-f") << QStringLiteral("-t") << (dir.path() + QLatin1String("/testcache"))); + QVERIFY2(process.waitForStarted(), qPrintable(QLatin1String("Unable to start: ") + + gtkUpdateIconCache + QLatin1String(": ") + + process.errorString())); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); +#endif // QT_NO_PROCESS + QVERIFY(QFileInfo(cacheName).lastModified() >= QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified()); + QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes + QVERIFY(!QIcon::fromTheme("button-open").isNull()); + QVERIFY(!QIcon::fromTheme("button-open-fallback").isNull()); + QVERIFY(QIcon::fromTheme("notexist-fallback").isNull()); +} void tst_QIcon::task223279_inconsistentAddFile() { diff --git a/tests/auto/gui/image/qicon/tst_qicon.qrc b/tests/auto/gui/image/qicon/tst_qicon.qrc index 1505ca925b..3c8fbba7c2 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.qrc +++ b/tests/auto/gui/image/qicon/tst_qicon.qrc @@ -15,6 +15,7 @@ <file>./icons/themeparent/32x32/actions/address-book-new.png</file> <file>./icons/themeparent/32x32/actions/appointment-new.png</file> <file>./icons/themeparent/index.theme</file> +<file>./icons/themeparent/icon-theme.cache</file> <file>./icons/themeparent/scalable/actions/address-book-new.svg</file> <file>./icons/themeparent/scalable/actions/appointment-new.svg</file> <file>./styles/commonstyle/images/standardbutton-open-16.png</file> diff --git a/tests/auto/gui/image/qimage/qimage.pro b/tests/auto/gui/image/qimage/qimage.pro index 42280d3bd4..36d64a275f 100644 --- a/tests/auto/gui/image/qimage/qimage.pro +++ b/tests/auto/gui/image/qimage/qimage.pro @@ -1,11 +1,10 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qimage SOURCES += tst_qimage.cpp QT += core-private gui-private testlib contains(QT_CONFIG, c++11): CONFIG += c++11 -android:!android-no-sdk:RESOURCES+=qimage.qrc +android: RESOURCES+=qimage.qrc TESTDATA += images/* diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 6f088bea24..85d258de5b 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -114,6 +109,7 @@ private slots: void smoothScale2_data(); void smoothScale2(); void smoothScale3(); + void smoothScale4(); void smoothScaleBig(); void smoothScaleAlpha(); @@ -975,13 +971,17 @@ void tst_QImage::createAlphaMask_data() int alphas[] = { 0, 127, 255 }; for (unsigned a1 = 0; a1 < sizeof(alphas) / sizeof(int); ++a1) { + const QByteArray a1B = QByteArray::number(alphas[a1]); for (unsigned a2 = 0; a2 < sizeof(alphas) / sizeof(int); ++a2) { if (a1 == a2) continue; + const QByteArray a2B = QByteArray::number(alphas[a2]); for (int x=10; x<18; x+=3) { + const QByteArray xB = QByteArray::number(x); for (int y=100; y<108; y+=3) { - QTest::newRow(qPrintable(QString::fromLatin1("x=%1, y=%2, a1=%3, a2=%4").arg(x).arg(y).arg(alphas[a1]).arg(alphas[a2]))) - << x << y << alphas[a1] << alphas[a2]; + const QByteArray testName = "x=" + xB + ", y=" + QByteArray::number(y) + + ", a1=" + a1B + ", a2=" + a2B; + QTest::newRow(testName.constData()) << x << y << alphas[a1] << alphas[a2]; } } } @@ -1078,34 +1078,34 @@ void tst_QImage::rotate_data() degrees << 0 << 90 << 180 << 270; foreach (int d, degrees) { - QString title = QString("%1 %2").arg(d); - QTest::newRow(qPrintable(title.arg("Format_RGB32"))) + const QByteArray dB = QByteArray::number(d); + QTest::newRow((dB + " Format_RGB32").constData()) << QImage::Format_RGB32 << d; - QTest::newRow(qPrintable(title.arg("Format_ARGB32"))) + QTest::newRow((dB + " Format_ARGB32").constData()) << QImage::Format_ARGB32 << d; - QTest::newRow(qPrintable(title.arg("Format_ARGB32_Premultiplied"))) + QTest::newRow((dB + " Format_ARGB32_Premultiplied").constData()) << QImage::Format_ARGB32_Premultiplied << d; - QTest::newRow(qPrintable(title.arg("Format_RGB16"))) + QTest::newRow((dB + " Format_RGB16").constData()) << QImage::Format_RGB16 << d; - QTest::newRow(qPrintable(title.arg("Format_ARGB8565_Premultiplied"))) + QTest::newRow((dB + " Format_ARGB8565_Premultiplied").constData()) << QImage::Format_ARGB8565_Premultiplied << d; - QTest::newRow(qPrintable(title.arg("Format_RGB666"))) + QTest::newRow((dB + " Format_RGB666").constData()) << QImage::Format_RGB666 << d; - QTest::newRow(qPrintable(title.arg("Format_RGB555"))) + QTest::newRow((dB + " Format_RGB555").constData()) << QImage::Format_RGB555 << d; - QTest::newRow(qPrintable(title.arg("Format_ARGB8555_Premultiplied"))) + QTest::newRow((dB + " Format_ARGB8555_Premultiplied").constData()) << QImage::Format_ARGB8555_Premultiplied << d; - QTest::newRow(qPrintable(title.arg("Format_RGB888"))) + QTest::newRow((dB + " Format_RGB888").constData()) << QImage::Format_RGB888 << d; - QTest::newRow(qPrintable(title.arg("Format_Indexed8"))) + QTest::newRow((dB + " Format_Indexed8").constData()) << QImage::Format_Indexed8 << d; - QTest::newRow(qPrintable(title.arg("Format_RGBX8888"))) + QTest::newRow((dB + " Format_RGBX8888").constData()) << QImage::Format_RGBX8888 << d; - QTest::newRow(qPrintable(title.arg("Format_RGBA8888_Premultiplied"))) + QTest::newRow((dB + " Format_RGBA8888_Premultiplied").constData()) << QImage::Format_RGBA8888_Premultiplied << d; - QTest::newRow(qPrintable(title.arg("Format_Alpha8"))) + QTest::newRow((dB + " Format_Alpha8").constData()) << QImage::Format_Alpha8 << d; - QTest::newRow(qPrintable(title.arg("Format_Grayscale8"))) + QTest::newRow((dB + " Format_Grayscale8").constData()) << QImage::Format_Grayscale8 << d; } } @@ -1661,9 +1661,11 @@ void tst_QImage::smoothScale2_data() int sizes[] = { 2, 3, 4, 6, 7, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 }; QImage::Format formats[] = { QImage::Format_RGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_Invalid }; for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) { - QString formatstr = formats[j] == QImage::Format_RGB32 ? QStringLiteral("rgb32") : QStringLiteral("argb32pm"); + QByteArray formatstr = formats[j] == QImage::Format_RGB32 ? QByteArrayLiteral("rgb32") : QByteArrayLiteral("argb32pm"); for (int i = 0; sizes[i] != 0; ++i) { - QTest::newRow(QString("%1 %2x%2").arg(formatstr).arg(sizes[i]).toUtf8()) << (int)formats[j] << sizes[i]; + const QByteArray sizeB = QByteArray::number(sizes[i]); + QTest::newRow((formatstr + ' ' + sizeB + 'x' + sizeB).constData()) + << (int)formats[j] << sizes[i]; } } } @@ -1706,6 +1708,30 @@ void tst_QImage::smoothScale2() QCOMPARE(qBlue(pixel), qBlue(expected)); } + // scale x up + scaled = img.scaled(QSize(size, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + for (int y = 0; y < scaled.height(); ++y) { + for (int x = 0; x < scaled.width(); ++x) { + pixel = scaled.pixel(x, y); + QCOMPARE(qAlpha(pixel), qAlpha(expected)); + QCOMPARE(qRed(pixel), qRed(expected)); + QCOMPARE(qGreen(pixel), qGreen(expected)); + QCOMPARE(qBlue(pixel), qBlue(expected)); + } + } + + // scale y up + scaled = img.scaled(QSize(size * 2, size), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + for (int y = 0; y < scaled.height(); ++y) { + for (int x = 0; x < scaled.width(); ++x) { + pixel = scaled.pixel(x, y); + QCOMPARE(qAlpha(pixel), qAlpha(expected)); + QCOMPARE(qRed(pixel), qRed(expected)); + QCOMPARE(qGreen(pixel), qGreen(expected)); + QCOMPARE(qBlue(pixel), qBlue(expected)); + } + } + // scale x up, y up scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); for (int y = 0; y < scaled.height(); ++y) { @@ -1771,6 +1797,26 @@ void tst_QImage::smoothScale3() } } +// Tests smooth upscale is smooth +void tst_QImage::smoothScale4() +{ + QImage img(4, 4, QImage::Format_RGB32); + for (int y = 0; y < 4; ++y) { + for (int x = 0; x < 4; ++x) { + img.setPixel(x, y, qRgb(x * 255 / 3, y * 255 / 3, 0)); + } + } + QImage scaled = img.scaled(37, 23, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + for (int y = 0; y < scaled.height(); ++y) { + for (int x = 0; x < scaled.width(); ++x) { + if (x > 0) + QVERIFY(qRed(scaled.pixel(x, y)) >= qRed(scaled.pixel(x - 1, y))); + if (y > 0) + QVERIFY(qGreen(scaled.pixel(x, y)) >= qGreen(scaled.pixel(x, y - 1))); + } + } +} + void tst_QImage::smoothScaleBig() { #if defined(Q_OS_WINCE) @@ -2693,10 +2739,11 @@ void tst_QImage::genericRgbConversion_data() QTest::addColumn<QImage::Format>("dest_format"); for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) { + const QString formatI = formatToString(QImage::Format(i)); for (int j = QImage::Format_RGB32; j < QImage::Format_Alpha8; ++j) { if (i == j) continue; - QString test = QString::fromLatin1("%1 -> %2").arg(formatToString(QImage::Format(i))).arg(formatToString(QImage::Format(j))); + const QString test = formatI + QLatin1String(" -> ") + formatToString(QImage::Format(j)); QTest::newRow(qPrintable(test)) << QImage::Format(i) << QImage::Format(j); } } @@ -3137,6 +3184,14 @@ void tst_QImage::pixelColor() QImage t = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied); QCOMPARE(t.pixel(0,0), argb32pm.pixel(0,0)); + + // Try specifying an invalid position. + QTest::ignoreMessage(QtWarningMsg, "QImage::setPixelColor: coordinate (-1,-1) out of range"); + argb32.setPixelColor(-1, -1, QColor(Qt::red)); + + // Try setting an invalid color. + QTest::ignoreMessage(QtWarningMsg, "QImage::setPixelColor: color is invalid"); + argb32.setPixelColor(0, 0, QColor()); } void tst_QImage::pixel() diff --git a/tests/auto/gui/image/qimageiohandler/qimageiohandler.pro b/tests/auto/gui/image/qimageiohandler/qimageiohandler.pro index bbcf8d23c9..428ff62959 100644 --- a/tests/auto/gui/image/qimageiohandler/qimageiohandler.pro +++ b/tests/auto/gui/image/qimageiohandler/qimageiohandler.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qimageiohandler QT += testlib diff --git a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp index 552df30b56..e24ba4fa81 100644 --- a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp +++ b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/auto/gui/image/qimagereader/qimagereader.pro b/tests/auto/gui/image/qimagereader/qimagereader.pro index 2ab06abe83..3d35bf59da 100644 --- a/tests/auto/gui/image/qimagereader/qimagereader.pro +++ b/tests/auto/gui/image/qimagereader/qimagereader.pro @@ -5,7 +5,7 @@ MOC_DIR=tmp QT += core-private gui-private network testlib RESOURCES += qimagereader.qrc -android: !android-no-sdk { +android { RESOURCES += android_testdata.qrc } diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index ff15dc5b6d..bd02dc6255 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -174,7 +169,7 @@ private: // helper to skip an autotest when the given image format is not supported #define SKIP_IF_UNSUPPORTED(format) do { \ if (!QByteArray(format).isEmpty() && !QImageReader::supportedImageFormats().contains(format)) \ - QSKIP("\"" + QByteArray(format) + "\" images are not supported"); \ + QSKIP('"' + QByteArray(format) + "\" images are not supported"); \ } while (0) // Testing get/set functions @@ -802,7 +797,7 @@ void tst_QImageReader::animatedGif() QVERIFY(!image.isNull()); int i = 0; while(!image.isNull()){ - QString frameName = QString(":images/qt%1.gif").arg(++i); + QString frameName = QLatin1String(":images/qt") + QString::number(++i) + QLatin1String(".gif"); QCOMPARE(image, QImage(frameName)); image = io.read(); } @@ -1654,14 +1649,14 @@ void tst_QImageReader::pixelCompareWithBaseline() // least one file succeeded we know that the plugin was built. // The other failures are then real failures. QImage icoImg; - const QString inputFileName(QString::fromLatin1("images/%1").arg(fileName)); + const QString inputFileName(QLatin1String("images/") + fileName); QFileInfo fi(inputFileName); ++enteredCount; // might fail if the plugin does not exist, which is ok. if (icoImg.load(inputFileName)) { icoImg = icoImg.convertToFormat(QImage::Format_ARGB32_Premultiplied); - const QString baselineFileName(QString::fromLatin1("baseline/%1.png").arg(fi.baseName())); + const QString baselineFileName(QLatin1String("baseline/") + fi.baseName() + QLatin1String(".png")); #if 0 icoImg.save(baselineFileName); #else diff --git a/tests/auto/gui/image/qimagewriter/qimagewriter.pro b/tests/auto/gui/image/qimagewriter/qimagewriter.pro index 31184bffdb..34adedd187 100644 --- a/tests/auto/gui/image/qimagewriter/qimagewriter.pro +++ b/tests/auto/gui/image/qimagewriter/qimagewriter.pro @@ -3,5 +3,5 @@ TARGET = tst_qimagewriter QT += testlib SOURCES += tst_qimagewriter.cpp MOC_DIR=tmp -android:!android-no-sdk:RESOURCES+= qimagewriter.qrc +android: RESOURCES+= qimagewriter.qrc TESTDATA += images/* diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index dfefd6f036..7a94217641 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -60,13 +55,8 @@ class tst_QImageWriter : public QObject { Q_OBJECT -public: - tst_QImageWriter(); - public slots: - void init(); void initTestCase(); - void cleanup(); private slots: void getSetCheck(); @@ -96,7 +86,7 @@ private: // helper to skip an autotest when the given image format is not supported #define SKIP_IF_UNSUPPORTED(format) do { \ if (!QByteArray(format).isEmpty() && !QImageReader::supportedImageFormats().contains(format)) \ - QSKIP("\"" + QByteArray(format) + "\" images are not supported"); \ + QSKIP('"' + QByteArray(format) + "\" images are not supported"); \ } while (0) static void initializePadding(QImage *image) @@ -162,18 +152,6 @@ void tst_QImageWriter::getSetCheck() QCOMPARE(1.1f, obj1.gamma()); } -tst_QImageWriter::tst_QImageWriter() -{ -} - -void tst_QImageWriter::init() -{ -} - -void tst_QImageWriter::cleanup() -{ -} - void tst_QImageWriter::writeImage_data() { QTest::addColumn<QString>("fileName"); @@ -259,8 +237,8 @@ void tst_QImageWriter::writeImage2_data() QImage image = image0.convertToFormat(imgFormat); initializePadding(&image); foreach (const QString format, formats) { - const QString fileName = QString("solidcolor_%1.%2").arg(imgFormat) - .arg(format); + const QString fileName = QLatin1String("solidcolor_") + + QString::number(imgFormat) + QLatin1Char('.') + format; QTest::newRow(fileName.toLatin1()) << fileName << format.toLatin1() << image; diff --git a/tests/auto/gui/image/qmovie/qmovie.pro b/tests/auto/gui/image/qmovie/qmovie.pro index 4e7030b1f7..a04ad73b80 100644 --- a/tests/auto/gui/image/qmovie/qmovie.pro +++ b/tests/auto/gui/image/qmovie/qmovie.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qmovie QT += testlib qtHaveModule(widgets): QT += widgets diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp index b8c99ca324..bcaa759faa 100644 --- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp +++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/auto/gui/image/qpicture/qpicture.pro b/tests/auto/gui/image/qpicture/qpicture.pro index a24b8ec481..0fc851ce11 100644 --- a/tests/auto/gui/image/qpicture/qpicture.pro +++ b/tests/auto/gui/image/qpicture/qpicture.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qpicture QT += testlib qtHaveModule(widgets): QT += widgets diff --git a/tests/auto/gui/image/qpicture/tst_qpicture.cpp b/tests/auto/gui/image/qpicture/tst_qpicture.cpp index 5406284c05..5c812fd1b2 100644 --- a/tests/auto/gui/image/qpicture/tst_qpicture.cpp +++ b/tests/auto/gui/image/qpicture/tst_qpicture.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 286f00c111..8dc6f901e6 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -64,12 +59,8 @@ class tst_QPixmap : public QObject public: tst_QPixmap(); - virtual ~tst_QPixmap(); - public slots: - void init(); - void cleanup(); void initTestCase(); void cleanupTestCase(); @@ -213,18 +204,6 @@ tst_QPixmap::tst_QPixmap() { } -tst_QPixmap::~tst_QPixmap() -{ -} - -void tst_QPixmap::init() -{ -} - -void tst_QPixmap::cleanup() -{ -} - void tst_QPixmap::initTestCase() { QVERIFY(!m_prefix.isEmpty()); @@ -446,7 +425,8 @@ void tst_QPixmap::scroll() else QVERIFY(pixmap.cacheKey() != oldKey); - QString fileName = QString(":/images/%1.png").arg(QTest::currentDataTag()); + const QString fileName = QLatin1String(":/images/") + QLatin1String(QTest::currentDataTag()) + + QLatin1String(".png"); QPixmap output(fileName); QCOMPARE(input.isNull(), output.isNull()); QVERIFY(lenientCompare(pixmap, output)); @@ -459,7 +439,7 @@ void tst_QPixmap::fill_data() QTest::addColumn<bool>("syscolor"); QTest::addColumn<bool>("bitmap"); for (int color = Qt::black; color < Qt::darkYellow; ++color) - QTest::newRow(QString("syscolor_%1").arg(color).toLatin1()) + QTest::newRow(("syscolor_" + QByteArray::number(color)).constData()) << uint(color) << true << false; #if defined (Q_OS_WINCE) @@ -1001,7 +981,9 @@ void tst_QPixmap::toWinHICON() HBITMAP bitmap = qt_pixmapToWinHBITMAP(empty, Alpha); SelectObject(bitmap_dc, bitmap); - QImage imageFromFile(image + QString(QLatin1String("_%1x%2.png")).arg(width).arg(height)); + const QString fileName = image + QLatin1Char('_') + QString::number(width) + QLatin1Char('x') + + QString::number(height) + QLatin1String(".png"); + QImage imageFromFile(fileName); imageFromFile = imageFromFile.convertToFormat(QImage::Format_ARGB32_Premultiplied); HICON icon = qt_pixmapToWinHICON(QPixmap::fromImage(imageFromFile)); @@ -1037,7 +1019,9 @@ void tst_QPixmap::fromWinHICON() QImage imageFromHICON = qt_pixmapFromWinHICON(icon).toImage(); DestroyIcon(icon); - QImage imageFromFile(image + QString(QLatin1String("_%1x%2.png")).arg(width).arg(height)); + const QString fileName = image + QLatin1Char('_') + QString::number(width) + QLatin1Char('x') + + QString::number(height) + QLatin1String(".png"); + QImage imageFromFile(fileName); imageFromFile = imageFromFile.convertToFormat(QImage::Format_ARGB32_Premultiplied); // fuzzy comparison must be used, as the pixel values change slightly during conversion diff --git a/tests/auto/gui/image/qpixmapcache/qpixmapcache.pro b/tests/auto/gui/image/qpixmapcache/qpixmapcache.pro index a81712ba23..fe3b5a2db3 100644 --- a/tests/auto/gui/image/qpixmapcache/qpixmapcache.pro +++ b/tests/auto/gui/image/qpixmapcache/qpixmapcache.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qpixmapcache QT += gui-private testlib SOURCES += tst_qpixmapcache.cpp diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp index a3cf66da18..8dcf104035 100644 --- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -147,7 +142,7 @@ void tst_QPixmapCache::setCacheLimit() QVERIFY(QPixmapCache::find(key, p1) == 0); QPixmapCache::setCacheLimit(1000); key = QPixmapCache::insert(*p1); - QCOMPARE(getPrivate(key)->isValid, true); + QVERIFY(key.isValid()); QCOMPARE(getPrivate(key)->key, 1); delete p1; @@ -189,7 +184,7 @@ void tst_QPixmapCache::setCacheLimit() key2 = QPixmapCache::insert(*p1); QCOMPARE(getPrivate(key2)->key, 1); //This old key is not valid anymore after the flush - QCOMPARE(getPrivate(key)->isValid, false); + QVERIFY(!key.isValid()); QVERIFY(QPixmapCache::find(key, &p2) == 0); delete p1; } @@ -233,7 +228,7 @@ void tst_QPixmapCache::find() //at that time the first key has been erase because no more place in the cache QVERIFY(QPixmapCache::find(key, &p1) == 0); - QCOMPARE(getPrivate(key)->isValid, false); + QVERIFY(!key.isValid()); } void tst_QPixmapCache::insert() @@ -313,7 +308,7 @@ void tst_QPixmapCache::replace() p2.fill(Qt::yellow); QPixmapCache::Key key = QPixmapCache::insert(p1); - QCOMPARE(getPrivate(key)->isValid, true); + QVERIFY(key.isValid()); QPixmap p3; QVERIFY(QPixmapCache::find(key, &p3) == 1); @@ -321,7 +316,7 @@ void tst_QPixmapCache::replace() QPixmapCache::replace(key, p2); QVERIFY(QPixmapCache::find(key, &p3) == 1); - QCOMPARE(getPrivate(key)->isValid, true); + QVERIFY(key.isValid()); QCOMPARE(getPrivate(key)->key, 1); QCOMPARE(p3.width(), 10); @@ -438,7 +433,7 @@ void tst_QPixmapCache::clear() for (int k = 0; k < numberOfKeys; ++k) { QVERIFY(QPixmapCache::find(keys.at(k), &p1) == 0); - QCOMPARE(getPrivate(keys[k])->isValid, false); + QVERIFY(!keys[k].isValid()); } } |