summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-05-04 13:16:14 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-05-04 13:19:31 +0200
commit7f8719e663edae8b08d34cc67cb5000e8402d3d7 (patch)
treeb098d2c8077a88c2ada577ac874e1416adaf66f7 /tests
parentaf851c290b7cea22f26bb8c852b0029696469d74 (diff)
parenteb82959d6688f9e58be4b67670afba3649f1f799 (diff)
Merge remote-tracking branch 'origin/5.5' into HEAD
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST8
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/qfilesystemwatcher.pro2
-rw-r--r--tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp17
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro2
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp250
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp29
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp37
-rw-r--r--tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp110
-rw-r--r--tests/manual/diaglib/textdump.cpp29
9 files changed, 373 insertions, 111 deletions
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
new file mode 100644
index 0000000000..3ac0b9dff4
--- /dev/null
+++ b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
@@ -0,0 +1,8 @@
+# QTBUG-33574 QTBUG-30943
+[signalsEmittedAfterFileMoved]
+windows 32bit msvc-2010
+windows 64bit msvc
+[watchFileAndItsDirectory:native backend-testfile]
+osx
+[watchFileAndItsDirectory:native backend-specialchars]
+osx
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/qfilesystemwatcher.pro b/tests/auto/corelib/io/qfilesystemwatcher/qfilesystemwatcher.pro
index 318e49a113..1faa089c6e 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/qfilesystemwatcher.pro
+++ b/tests/auto/corelib/io/qfilesystemwatcher/qfilesystemwatcher.pro
@@ -3,5 +3,3 @@ TARGET = tst_qfilesystemwatcher
QT = core testlib
SOURCES = tst_qfilesystemwatcher.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-CONFIG += insignificant_test # QTBUG-33574
diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
index 3886051fdc..01bf16c295 100644
--- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
+++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
@@ -297,9 +297,16 @@ void tst_QMimeData::setText() const
QVERIFY(mimeData.hasText() == false);
}
+// Publish retrieveData for verifying content validity
+class TstMetaData : public QMimeData
+{
+public:
+ using QMimeData::retrieveData;
+};
+
void tst_QMimeData::setUrls() const
{
- QMimeData mimeData;
+ TstMetaData mimeData;
QList<QUrl> shortUrlList;
QList<QUrl> longUrlList;
@@ -321,6 +328,14 @@ void tst_QMimeData::setUrls() const
QCOMPARE(mimeData.urls(), longUrlList);
QCOMPARE(mimeData.text(), QString("http://qt-project.org\nhttp://www.google.com\n"));
+ // test and verify that setData doesn't corrupt url content
+ foreach (const QString &format, mimeData.formats()) {
+ QVariant before = mimeData.retrieveData(format, QVariant::ByteArray);
+ mimeData.setData(format, mimeData.data(format));
+ QVariant after = mimeData.retrieveData(format, QVariant::ByteArray);
+ QCOMPARE(after, before);
+ }
+
// clear, verify
mimeData.clear();
QCOMPARE(mimeData.hasUrls(), false);
diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
index f5d06b3de9..5c6c56e389 100644
--- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
@@ -5,7 +5,7 @@ SUBDIRS = lib \
theplugin \
tst
!android: !win32: !mac: SUBDIRS += almostplugin
-macx-*: SUBDIRS += machtest
+macx-*: contains(QT_CONFIG, private_tests): SUBDIRS += machtest
TARGET = tst_qpluginloader
# no special install rule for subdir
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 5691a654d7..2931185c8b 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -41,6 +41,7 @@
#include <stdio.h>
#include <qpainter.h>
+#include <private/qimage_p.h>
#include <private/qdrawhelper_p.h>
Q_DECLARE_METATYPE(QImage::Format)
@@ -160,8 +161,11 @@ private slots:
void inplaceRgbMirrored();
- void inplaceConversion_data();
- void inplaceConversion();
+ void genericRgbConversion_data();
+ void genericRgbConversion();
+
+ void inplaceRgbConversion_data();
+ void inplaceRgbConversion();
void deepCopyWhenPaintingActive();
void scaled_QTBUG19157();
@@ -183,11 +187,75 @@ private slots:
void cleanupFunctions();
void devicePixelRatio();
+ void rgb30Unpremul();
+
+ void metadataPassthrough();
private:
const QString m_prefix;
};
+static QString formatToString(QImage::Format format)
+{
+ switch (format) {
+ case QImage::Format_Invalid:
+ return QStringLiteral("Invalid");
+ case QImage::Format_Mono:
+ return QStringLiteral("Mono");
+ case QImage::Format_MonoLSB:
+ return QStringLiteral("MonoLSB");
+ case QImage::Format_Indexed8:
+ return QStringLiteral("Indexed8");
+ case QImage::Format_RGB32:
+ return QStringLiteral("RGB32");
+ case QImage::Format_ARGB32:
+ return QStringLiteral("ARGB32");
+ case QImage::Format_ARGB32_Premultiplied:
+ return QStringLiteral("ARGB32pm");
+ case QImage::Format_RGB16:
+ return QStringLiteral("RGB16");
+ case QImage::Format_ARGB8565_Premultiplied:
+ return QStringLiteral("ARGB8565pm");
+ case QImage::Format_RGB666:
+ return QStringLiteral("RGB666");
+ case QImage::Format_ARGB6666_Premultiplied:
+ return QStringLiteral("ARGB6666pm");
+ case QImage::Format_RGB555:
+ return QStringLiteral("RGB555");
+ case QImage::Format_ARGB8555_Premultiplied:
+ return QStringLiteral("ARGB8555pm");
+ case QImage::Format_RGB888:
+ return QStringLiteral("RGB888");
+ case QImage::Format_RGB444:
+ return QStringLiteral("RGB444");
+ case QImage::Format_ARGB4444_Premultiplied:
+ return QStringLiteral("ARGB4444pm");
+ case QImage::Format_RGBX8888:
+ return QStringLiteral("RGBx88888");
+ case QImage::Format_RGBA8888:
+ return QStringLiteral("RGBA88888");
+ case QImage::Format_RGBA8888_Premultiplied:
+ return QStringLiteral("RGBA88888pm");
+ case QImage::Format_BGR30:
+ return QStringLiteral("BGR30");
+ case QImage::Format_A2BGR30_Premultiplied:
+ return QStringLiteral("A2BGR30pm");
+ case QImage::Format_RGB30:
+ return QStringLiteral("RGB30");
+ case QImage::Format_A2RGB30_Premultiplied:
+ return QStringLiteral("A2RGB30pm");
+ case QImage::Format_Alpha8:
+ return QStringLiteral("Alpha8");
+ case QImage::Format_Grayscale8:
+ return QStringLiteral("Grayscale8");
+ default:
+ break;
+ };
+ Q_UNREACHABLE();
+ qWarning("Unhandled image format");
+ return QStringLiteral("unknown");
+}
+
tst_QImage::tst_QImage()
: m_prefix(QFINDTESTDATA("images/"))
{
@@ -2159,23 +2227,9 @@ void tst_QImage::rgbSwapped_data()
{
QTest::addColumn<QImage::Format>("format");
- QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8;
- QTest::newRow("Format_RGB32") << QImage::Format_RGB32;
- QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32;
- QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
- QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
- QTest::newRow("Format_ARGB8565_Premultiplied") << QImage::Format_ARGB8565_Premultiplied;
- QTest::newRow("Format_ARGB6666_Premultiplied") << QImage::Format_ARGB6666_Premultiplied;
- QTest::newRow("Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied;
- QTest::newRow("Format_RGB666") << QImage::Format_RGB666;
- QTest::newRow("Format_RGB555") << QImage::Format_RGB555;
- QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied;
- QTest::newRow("Format_RGB888") << QImage::Format_RGB888;
- QTest::newRow("Format_RGB444") << QImage::Format_RGB444;
- QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888;
- QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied;
- QTest::newRow("Format_A2BGR30_Premultiplied") << QImage::Format_A2BGR30_Premultiplied;
- QTest::newRow("Format_RGB30") << QImage::Format_RGB30;
+ for (int i = QImage::Format_Indexed8; i < QImage::Format_Alpha8; ++i) {
+ QTest::newRow(qPrintable(formatToString(QImage::Format(i)))) << QImage::Format(i);
+ }
}
void tst_QImage::rgbSwapped()
@@ -2395,23 +2449,18 @@ void tst_QImage::inplaceMirrored_data()
QTest::addColumn<bool>("swap_vertical");
QTest::addColumn<bool>("swap_horizontal");
- QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false;
- QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false;
- QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false;
- QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false;
- QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false;
-
- QTest::newRow("Format_ARGB32, horizontal") << QImage::Format_ARGB32 << false << true;
- QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true;
- QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true;
- QTest::newRow("Format_Indexed8, horizontal") << QImage::Format_Indexed8 << false << true;
- QTest::newRow("Format_Mono, horizontal") << QImage::Format_Mono << false << true;
-
- QTest::newRow("Format_ARGB32, horizontal+vertical") << QImage::Format_ARGB32 << true << true;
- QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true;
- QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true;
- QTest::newRow("Format_Indexed8, horizontal+vertical") << QImage::Format_Indexed8 << true << true;
- QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true;
+ for (int i = QImage::Format_Mono; i < QImage::NImageFormats; ++i) {
+ if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8)
+ continue;
+ if (i == QImage::Format_RGB444 || i == QImage::Format_ARGB4444_Premultiplied)
+ continue;
+ QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", vertical")))
+ << QImage::Format(i) << true << false;
+ QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", horizontal")))
+ << QImage::Format(i) << false << true;
+ QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", horizontal+vertical")))
+ << QImage::Format(i) << true << true;
+ }
}
void tst_QImage::inplaceMirrored()
@@ -2425,6 +2474,7 @@ void tst_QImage::inplaceMirrored()
switch (format) {
case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
for (int i = 0; i < image.height(); ++i) {
ushort* scanLine = (ushort*)image.scanLine(i);
*scanLine = (i % 2) ? 0x0fffU : 0xf000U;
@@ -2447,7 +2497,7 @@ void tst_QImage::inplaceMirrored()
const uchar* originalPtr = image.constScanLine(0);
QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical);
- if (format != QImage::Format_Mono) {
+ if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB) {
for (int i = 0; i < imageMirrored.height(); ++i) {
int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
for (int j = 0; j < imageMirrored.width(); ++j) {
@@ -2537,23 +2587,60 @@ void tst_QImage::inplaceRgbMirrored()
#endif
}
-void tst_QImage::inplaceConversion_data()
+void tst_QImage::genericRgbConversion_data()
{
QTest::addColumn<QImage::Format>("format");
QTest::addColumn<QImage::Format>("dest_format");
- QTest::newRow("Format_RGB32 -> RGB16") << QImage::Format_RGB32 << QImage::Format_RGB16;
- QTest::newRow("Format_ARGB32 -> Format_RGBA8888") << QImage::Format_ARGB32 << QImage::Format_RGBA8888;
- QTest::newRow("Format_RGB888 -> Format_ARGB6666_Premultiplied") << QImage::Format_RGB888 << QImage::Format_ARGB6666_Premultiplied;
- QTest::newRow("Format_RGB16 -> Format_RGB555") << QImage::Format_RGB16 << QImage::Format_RGB555;
- QTest::newRow("Format_RGB666 -> Format_RGB888") << QImage::Format_RGB666 << QImage::Format_RGB888;
- QTest::newRow("Format_ARGB8565_Premultiplied, Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8565_Premultiplied << QImage::Format_ARGB8555_Premultiplied;
- QTest::newRow("Format_ARGB4444_Premultiplied, Format_RGB444") << QImage::Format_ARGB4444_Premultiplied << QImage::Format_RGB444;
- QTest::newRow("Format_RGBA8888 -> RGB16") << QImage::Format_RGBA8888 << QImage::Format_RGB16;
- QTest::newRow("Format_RGBA8888_Premultiplied -> RGB16") << QImage::Format_RGBA8888_Premultiplied << QImage::Format_RGB16;
+ for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++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)));
+ QTest::newRow(qPrintable(test)) << QImage::Format(i) << QImage::Format(j);
+ }
+ }
}
-void tst_QImage::inplaceConversion()
+void tst_QImage::genericRgbConversion()
+{
+ // Test that all RGB conversions work and maintain at least 4bit of color accuracy.
+ QFETCH(QImage::Format, format);
+ QFETCH(QImage::Format, dest_format);
+
+ QImage image(16, 16, format);
+
+ for (int i = 0; i < image.height(); ++i)
+ for (int j = 0; j < image.width(); ++j)
+ image.setPixel(j, i, qRgb(j*16, i*16, 0));
+
+ QImage imageConverted = image.convertToFormat(dest_format);
+ QCOMPARE(imageConverted.format(), dest_format);
+ for (int i = 0; i < imageConverted.height(); ++i) {
+ for (int j = 0; j < imageConverted.width(); ++j) {
+ QRgb convertedColor = imageConverted.pixel(j,i);
+ QCOMPARE(qRed(convertedColor) & 0xF0, j * 16);
+ QCOMPARE(qGreen(convertedColor) & 0xF0, i * 16);
+ }
+ }
+}
+
+void tst_QImage::inplaceRgbConversion_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<QImage::Format>("dest_format");
+
+ for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++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)));
+ QTest::newRow(qPrintable(test)) << QImage::Format(i) << QImage::Format(j);
+ }
+ }
+}
+
+void tst_QImage::inplaceRgbConversion()
{
// Test that conversions between RGB formats of the same bitwidth can be done inplace.
#if defined(Q_COMPILER_REF_QUALIFIERS)
@@ -2582,8 +2669,8 @@ void tst_QImage::inplaceConversion()
{
// Test attempted inplace conversion of images created on existing buffer
- static const quint32 readOnlyData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U };
- quint32 readWriteData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U };
+ static const quint32 readOnlyData[] = { 0xff0102ffU, 0xff0506ffU, 0xff0910ffU, 0xff1314ffU };
+ quint32 readWriteData[] = { 0xff0102ffU, 0xff0506ffU, 0xff0910ffU, 0xff1314ffU };
QImage roImage((const uchar *)readOnlyData, 2, 2, format);
QImage roInplaceConverted = std::move(roImage).convertToFormat(dest_format);
@@ -2705,18 +2792,9 @@ void tst_QImage::invertPixelsRGB_data()
{
QTest::addColumn<QImage::Format>("image_format");
- QTest::newRow("invertPixels RGB16") << QImage::Format_RGB16;
- QTest::newRow("invertPixels RGB32") << QImage::Format_RGB32;
- QTest::newRow("invertPixels BGR30") << QImage::Format_BGR30;
- QTest::newRow("invertPixels RGB444") << QImage::Format_RGB444;
- QTest::newRow("invertPixels RGB555") << QImage::Format_RGB555;
- QTest::newRow("invertPixels RGB888") << QImage::Format_RGB888;
-
- QTest::newRow("invertPixels ARGB32") << QImage::Format_ARGB32;
- QTest::newRow("invertPixels ARGB32pm") << QImage::Format_ARGB32_Premultiplied;
- QTest::newRow("invertPixels RGBA8888") << QImage::Format_RGBA8888;
- QTest::newRow("invertPixels RGBA8888pm") << QImage::Format_RGBA8888_Premultiplied;
- QTest::newRow("invertPixels RGBA4444pm") << QImage::Format_ARGB4444_Premultiplied;
+ for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) {
+ QTest::newRow(qPrintable(formatToString(QImage::Format(i)))) << QImage::Format(i);
+ }
}
void tst_QImage::invertPixelsRGB()
@@ -2827,5 +2905,53 @@ void tst_QImage::devicePixelRatio()
QCOMPARE(b.devicePixelRatio(), qreal(1.0));
}
+void tst_QImage::rgb30Unpremul()
+{
+ QImage a(3, 1, QImage::Format_A2RGB30_Premultiplied);
+ ((uint*)a.bits())[0] = (3U << 30) | (128 << 20) | (256 << 10) | 512;
+ ((uint*)a.bits())[1] = (2U << 30) | (131 << 20) | (259 << 10) | 515;
+ ((uint*)a.bits())[2] = (1U << 30) | ( 67 << 20) | (131 << 10) | 259;
+
+ QImage b = a.convertToFormat(QImage::Format_RGB30);
+ const uint* bbits = (const uint*)b.bits();
+ QCOMPARE(bbits[0], (3U << 30) | (128 << 20) | (256 << 10) | 512);
+ QCOMPARE(bbits[1], (3U << 30) | (196 << 20) | (388 << 10) | 772);
+ QCOMPARE(bbits[2], (3U << 30) | (201 << 20) | (393 << 10) | 777);
+}
+
+void tst_QImage::metadataPassthrough()
+{
+ QImage a(64, 64, QImage::Format_ARGB32);
+ a.fill(Qt::white);
+ a.setText(QStringLiteral("Test"), QStringLiteral("Text"));
+ a.setDotsPerMeterX(100);
+ a.setDotsPerMeterY(80);
+ a.setDevicePixelRatio(2.0);
+
+ QImage scaled = a.scaled(QSize(32, 32), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
+
+ scaled = a.scaled(QSize(128, 128), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage mirrored = a.mirrored();
+ QCOMPARE(mirrored.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(mirrored.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(mirrored.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage swapped = a.rgbSwapped();
+ QCOMPARE(swapped.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(swapped.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(swapped.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio());
+}
+
QTEST_GUILESS_MAIN(tst_QImage)
#include "tst_qimage.moc"
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index e677891ce5..ffc000a418 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -54,10 +54,10 @@
#include <qsortfilterproxymodel.h>
#include <qlineedit.h>
#include <qlayout.h>
+#include <private/qfiledialog_p.h>
#if defined QT_BUILD_INTERNAL
#include <private/qsidebar_p.h>
#include <private/qfilesystemmodel_p.h>
-#include <private/qfiledialog_p.h>
#endif
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
@@ -108,6 +108,7 @@ public:
public slots:
void initTestCase();
void init();
+ void cleanup();
private slots:
void currentChangedSignal();
@@ -166,7 +167,7 @@ private slots:
void rejectModalDialogs();
private:
- QByteArray userSettings;
+ void cleanupSettingsFile();
};
tst_QFiledialog::tst_QFiledialog()
@@ -177,18 +178,27 @@ tst_QFiledialog::~tst_QFiledialog()
{
}
+void tst_QFiledialog::cleanupSettingsFile()
+{
+ // clean up the sidebar between each test
+ QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
+ settings.beginGroup(QLatin1String("FileDialog"));
+ settings.remove(QString());
+ settings.endGroup();
+ settings.beginGroup(QLatin1String("Qt")); // Compatibility settings
+ settings.remove(QLatin1String("filedialog"));
+ settings.endGroup();
+}
+
void tst_QFiledialog::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
+ cleanupSettingsFile();
}
void tst_QFiledialog::init()
{
- // clean up the sidebar between each test
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("Qt"));
- settings.remove(QLatin1String("filedialog"));
-
+ QFileDialogPrivate::setLastVisitedDirectory(QUrl());
// populate the sidebar with some default settings
QNonNativeFileDialog fd;
#if defined(Q_OS_WINCE)
@@ -196,6 +206,11 @@ void tst_QFiledialog::init()
#endif
}
+void tst_QFiledialog::cleanup()
+{
+ cleanupSettingsFile();
+}
+
class MyAbstractItemDelegate : public QAbstractItemDelegate
{
public:
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index 7af62cb2a1..ed34c67aad 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -88,6 +88,7 @@ public:
virtual ~tst_QFileDialog2();
public slots:
+ void initTestCase();
void init();
void cleanup();
@@ -135,13 +136,13 @@ private slots:
void dontShowCompleterOnRoot();
private:
- QByteArray userSettings;
+ void cleanupSettingsFile();
+
QTemporaryDir tempDir;
};
tst_QFileDialog2::tst_QFileDialog2()
- : userSettings()
- , tempDir(QDir::tempPath() + "/tst_qfiledialog2.XXXXXX")
+ : tempDir(QDir::tempPath() + "/tst_qfiledialog2.XXXXXX")
{
#if defined(Q_OS_WINCE)
qApp->setAutoMaximizeThreshold(-1);
@@ -152,17 +153,29 @@ tst_QFileDialog2::~tst_QFileDialog2()
{
}
-void tst_QFileDialog2::init()
+void tst_QFileDialog2::cleanupSettingsFile()
{
- QVERIFY(tempDir.isValid());
-
- // Save the developers settings so they don't get mad when their sidebar folders are gone.
+ // clean up the sidebar between each test
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("Qt"));
- userSettings = settings.value(QLatin1String("filedialog")).toByteArray();
+ settings.beginGroup(QLatin1String("FileDialog"));
+ settings.remove(QString());
+ settings.endGroup();
+ settings.beginGroup(QLatin1String("Qt")); // Compatibility settings
settings.remove(QLatin1String("filedialog"));
+ settings.endGroup();
+}
+
+void tst_QFileDialog2::initTestCase()
+{
+ QVERIFY(tempDir.isValid());
+ QStandardPaths::setTestModeEnabled(true);
+ cleanupSettingsFile();
+}
- // populate it with some default settings
+void tst_QFileDialog2::init()
+{
+ QFileDialogPrivate::setLastVisitedDirectory(QUrl());
+ // populate the sidebar with some default settings
QNonNativeFileDialog fd;
#if defined(Q_OS_WINCE)
QTest::qWait(1000);
@@ -171,9 +184,7 @@ void tst_QFileDialog2::init()
void tst_QFileDialog2::cleanup()
{
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("Qt"));
- settings.setValue(QLatin1String("filedialog"), userSettings);
+ cleanupSettingsFile();
}
#ifdef QT_BUILD_INTERNAL
diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
index 2d4a453b58..bca5868c3f 100644
--- a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
+++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
@@ -49,6 +49,12 @@ private slots:
void convertRgb32ToRgb888_data();
void convertRgb32ToRgb888();
+ void convertRgb16_data();
+ void convertRgb16();
+
+ void convertRgb32_data();
+ void convertRgb32();
+
void convertGeneric_data();
void convertGeneric();
@@ -146,55 +152,96 @@ void tst_QImageConversion::convertRgb32ToRgb888()
}
}
-
-void tst_QImageConversion::convertGeneric_data()
+void tst_QImageConversion::convertRgb16_data()
{
QTest::addColumn<QImage>("inputImage");
QTest::addColumn<QImage::Format>("outputFormat");
QImage rgb16 = generateImageRgb16(1000, 1000);
+
+ QTest::newRow("rgb32") << rgb16 << QImage::Format_RGB32;
+ QTest::newRow("rgb888") << rgb16 << QImage::Format_RGB888;
+ QTest::newRow("rgb666") << rgb16 << QImage::Format_RGB666;
+ QTest::newRow("rgb555") << rgb16 << QImage::Format_RGB555;
+}
+
+void tst_QImageConversion::convertRgb16()
+{
+ QFETCH(QImage, inputImage);
+ QFETCH(QImage::Format, outputFormat);
+
+ QBENCHMARK {
+ QImage output = inputImage.convertToFormat(outputFormat);
+ output.constBits();
+ }
+}
+
+void tst_QImageConversion::convertRgb32_data()
+{
+ QTest::addColumn<QImage>("inputImage");
+ QTest::addColumn<QImage::Format>("outputFormat");
QImage rgb32 = generateImageRgb32(1000, 1000);
QImage argb32 = generateImageArgb32(1000, 1000);
QImage argb32pm = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- QImage rgba32 = argb32.convertToFormat(QImage::Format_RGBA8888);
- QImage a2rgb30 = argb32.convertToFormat(QImage::Format_A2RGB30_Premultiplied);
-
- QTest::newRow("rgb16 -> rgb32") << rgb16 << QImage::Format_RGB32;
- QTest::newRow("rgb16 -> rgb888") << rgb16 << QImage::Format_RGB888;
- QTest::newRow("rgb16 -> rgb666") << rgb16 << QImage::Format_RGB666;
- QTest::newRow("rgb16 -> rgb555") << rgb16 << QImage::Format_RGB555;
QTest::newRow("rgb32 -> rgb16") << rgb32 << QImage::Format_RGB16;
- QTest::newRow("rgb32 -> rgb888") << rgb32 << QImage::Format_RGB888;
- QTest::newRow("rgb32 -> rgb666") << rgb32 << QImage::Format_RGB666;
- QTest::newRow("rgb32 -> rgb555") << rgb32 << QImage::Format_RGB555;
QTest::newRow("rgb32 -> argb32") << rgb32 << QImage::Format_ARGB32;
QTest::newRow("rgb32 -> argb32pm") << rgb32 << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("rgb32 -> rgbx8888") << rgb32 << QImage::Format_RGBX8888;
QTest::newRow("rgb32 -> rgba8888") << rgb32 << QImage::Format_RGBA8888;
QTest::newRow("rgb32 -> rgba8888pm") << rgb32 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("rgb32 -> rgb30") << rgb32 << QImage::Format_RGB30;
- QTest::newRow("rgb32 -> bgr30") << rgb32 << QImage::Format_BGR30;
+ QTest::newRow("rgb32 -> a2bgr30") << rgb32 << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("rgb32 -> rgb888") << rgb32 << QImage::Format_RGB888;
+ QTest::newRow("rgb32 -> rgb666") << rgb32 << QImage::Format_RGB666;
+ QTest::newRow("rgb32 -> rgb555") << rgb32 << QImage::Format_RGB555;
- QTest::newRow("argb32 -> rgb888") << argb32 << QImage::Format_RGB888;
- QTest::newRow("argb32 -> rgb666") << argb32 << QImage::Format_RGB666;
- QTest::newRow("argb32 -> argb8565pm") << argb32 << QImage::Format_ARGB8565_Premultiplied;
- QTest::newRow("argb32 -> argb4444pm") << argb32 << QImage::Format_ARGB4444_Premultiplied;
+ QTest::newRow("argb32 -> rgb16") << argb32 << QImage::Format_RGB16;
QTest::newRow("argb32 -> rgb32") << argb32 << QImage::Format_RGB32;
QTest::newRow("argb32 -> argb32pm") << argb32 << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("argb32 -> rgbx8888") << argb32 << QImage::Format_RGBX8888;
QTest::newRow("argb32 -> rgba8888") << argb32 << QImage::Format_RGBA8888;
QTest::newRow("argb32 -> rgba8888pm") << argb32 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("argb32 -> rgb30") << argb32 << QImage::Format_RGB30;
- QTest::newRow("argb32 -> a2rgb30") << argb32 << QImage::Format_A2RGB30_Premultiplied;
+ QTest::newRow("argb32 -> a2bgr30") << argb32 << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("argb32 -> rgb888") << argb32 << QImage::Format_RGB888;
+ QTest::newRow("argb32 -> rgb666") << argb32 << QImage::Format_RGB666;
+ QTest::newRow("argb32 -> argb8565pm") << argb32 << QImage::Format_ARGB8565_Premultiplied;
+ QTest::newRow("argb32 -> argb4444pm") << argb32 << QImage::Format_ARGB4444_Premultiplied;
- QTest::newRow("argb32pm -> argb4444pm") << argb32pm << QImage::Format_ARGB4444_Premultiplied;
+ QTest::newRow("argb32pm -> rgb16") << argb32pm << QImage::Format_RGB16;
QTest::newRow("argb32pm -> rgb32") << argb32pm << QImage::Format_RGB32;
QTest::newRow("argb32pm -> argb32") << argb32pm << QImage::Format_ARGB32;
QTest::newRow("argb32pm -> rgbx8888") << argb32pm << QImage::Format_RGBX8888;
QTest::newRow("argb32pm -> rgba8888") << argb32pm << QImage::Format_RGBA8888;
QTest::newRow("argb32pm -> rgba8888pm") << argb32pm << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("argb32pm -> rgb30") << argb32pm << QImage::Format_RGB30;
- QTest::newRow("argb32pm -> a2rgb30") << argb32pm << QImage::Format_A2RGB30_Premultiplied;
+ QTest::newRow("argb32pm -> a2bgr30") << argb32pm << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("argb32pm -> rgb888") << argb32pm << QImage::Format_RGB888;
+ QTest::newRow("argb32pm -> rgb666") << argb32pm << QImage::Format_RGB666;
+ QTest::newRow("argb32pm -> argb8565pm") << argb32pm << QImage::Format_ARGB8565_Premultiplied;
+ QTest::newRow("argb32pm -> argb4444pm") << argb32pm << QImage::Format_ARGB4444_Premultiplied;
+}
+
+void tst_QImageConversion::convertRgb32()
+{
+ QFETCH(QImage, inputImage);
+ QFETCH(QImage::Format, outputFormat);
+
+ QBENCHMARK {
+ QImage output = inputImage.convertToFormat(outputFormat);
+ output.constBits();
+ }
+}
+
+void tst_QImageConversion::convertGeneric_data()
+{
+ QTest::addColumn<QImage>("inputImage");
+ QTest::addColumn<QImage::Format>("outputFormat");
+ QImage rgb32 = generateImageRgb32(1000, 1000);
+ QImage argb32 = generateImageArgb32(1000, 1000);
+ QImage rgba32 = argb32.convertToFormat(QImage::Format_RGBA8888);
+ QImage bgr30 = rgb32.convertToFormat(QImage::Format_BGR30);
+ QImage a2rgb30 = argb32.convertToFormat(QImage::Format_A2RGB30_Premultiplied);
QTest::newRow("rgba8888 -> rgb32") << rgba32 << QImage::Format_RGB32;
QTest::newRow("rgba8888 -> argb32") << rgba32 << QImage::Format_ARGB32;
@@ -202,7 +249,16 @@ void tst_QImageConversion::convertGeneric_data()
QTest::newRow("rgba8888 -> rgbx8888") << rgba32 << QImage::Format_RGBX8888;
QTest::newRow("rgba8888 -> rgba8888pm") << rgba32 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("rgba8888 -> rgb30") << rgba32 << QImage::Format_RGB30;
- QTest::newRow("rgba8888 -> a2rgb30") << rgba32 << QImage::Format_A2RGB30_Premultiplied;
+ QTest::newRow("rgba8888 -> a2bgr30") << rgba32 << QImage::Format_A2BGR30_Premultiplied;
+
+ QTest::newRow("bgr30 -> rgb32") << bgr30 << QImage::Format_RGB32;
+ QTest::newRow("bgr30 -> argb32") << bgr30 << QImage::Format_ARGB32;
+ QTest::newRow("bgr30 -> argb32pm") << bgr30 << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("bgr30 -> rgbx8888") << bgr30 << QImage::Format_RGBX8888;
+ QTest::newRow("bgr30 -> rgba8888") << bgr30 << QImage::Format_RGBA8888;
+ QTest::newRow("bgr30 -> rgba8888pm") << bgr30 << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("bgr30 -> rgb30") << bgr30 << QImage::Format_RGB30;
+ QTest::newRow("bgr30 -> a2bgr30") << bgr30 << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("a2rgb30 -> rgb32") << a2rgb30 << QImage::Format_RGB32;
QTest::newRow("a2rgb30 -> argb32") << a2rgb30 << QImage::Format_ARGB32;
@@ -210,7 +266,9 @@ void tst_QImageConversion::convertGeneric_data()
QTest::newRow("a2rgb30 -> rgbx8888") << a2rgb30 << QImage::Format_RGBX8888;
QTest::newRow("a2rgb30 -> rgba8888") << a2rgb30 << QImage::Format_RGBA8888;
QTest::newRow("a2rgb30 -> rgba8888pm") << a2rgb30 << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("a2rgb30 -> rgb30") << a2rgb30 << QImage::Format_RGB30;
QTest::newRow("a2rgb30 -> bgr30") << a2rgb30 << QImage::Format_BGR30;
+ QTest::newRow("a2rgb30 -> a2bgr30") << a2rgb30 << QImage::Format_A2BGR30_Premultiplied;
}
void tst_QImageConversion::convertGeneric()
@@ -316,12 +374,14 @@ QImage tst_QImageConversion::generateImageRgb32(int width, int height)
QImage tst_QImageConversion::generateImageArgb32(int width, int height)
{
QImage image(width, height, QImage::Format_ARGB32);
- const int byteWidth = width * 4;
for (int y = 0; y < image.height(); ++y) {
- uchar *scanline = image.scanLine(y);
- for (int x = 0; x < byteWidth; ++x)
- scanline[x] = x ^ y;
+ QRgb *scanline = (QRgb*)image.scanLine(y);
+ for (int x = 0; x < width; ++x) {
+ int alpha = (x ^ y) & 0x1ff;
+ alpha = qMax(0, qMin(alpha - 128, 255));
+ scanline[x] = qRgba(x, y, x ^ y, alpha);
+ }
}
return image;
}
diff --git a/tests/manual/diaglib/textdump.cpp b/tests/manual/diaglib/textdump.cpp
index 40295f8833..ed4d5021be 100644
--- a/tests/manual/diaglib/textdump.cpp
+++ b/tests/manual/diaglib/textdump.cpp
@@ -222,6 +222,32 @@ static const EnumLookup scriptEnumLookup[] =
{QChar::Script_Sharada, "Script_Sharada"},
{QChar::Script_SoraSompeng, "Script_SoraSompeng"},
{QChar::Script_Takri, "Script_Takri"},
+
+#if QT_VERSION >= 0x050500
+ {QChar::Script_CaucasianAlbanian, "Script_CaucasianAlbanian"},
+ {QChar::Script_BassaVah, "Script_BassaVah"},
+ {QChar::Script_Duployan, "Script_Duployan"},
+ {QChar::Script_Elbasan, "Script_Elbasan"},
+ {QChar::Script_Grantha, "Script_Grantha"},
+ {QChar::Script_PahawhHmong, "Script_PahawhHmong"},
+ {QChar::Script_Khojki, "Script_Khojki"},
+ {QChar::Script_LinearA, "Script_LinearA"},
+ {QChar::Script_Mahajani, "Script_Mahajani"},
+ {QChar::Script_Manichaean, "Script_Manichaean"},
+ {QChar::Script_MendeKikakui, "Script_MendeKikakui"},
+ {QChar::Script_Modi, "Script_Modi"},
+ {QChar::Script_Mro, "Script_Mro"},
+ {QChar::Script_OldNorthArabian, "Script_OldNorthArabian"},
+ {QChar::Script_Nabataean, "Script_Nabataean"},
+ {QChar::Script_Palmyrene, "Script_Palmyrene"},
+ {QChar::Script_PauCinHau, "Script_PauCinHau"},
+ {QChar::Script_OldPermic, "Script_OldPermic"},
+ {QChar::Script_PsalterPahlavi, "Script_PsalterPahlavi"},
+ {QChar::Script_Siddham, "Script_Siddham"},
+ {QChar::Script_Khudawadi, "Script_Khudawadi"},
+ {QChar::Script_Tirhuta, "Script_Tirhuta"},
+ {QChar::Script_WarangCiti, "Script_WarangCiti"},
+#endif // Qt 5.5
};
#endif // Qt 5.1
@@ -335,6 +361,9 @@ static const EnumLookup unicodeVersionEnumLookup[] =
{QChar::Unicode_6_1, "Unicode_6_1"},
{QChar::Unicode_6_2, "Unicode_6_2"},
{QChar::Unicode_6_3, "Unicode_6_3"},
+#if QT_VERSION >= 0x050500
+ {QChar::Unicode_7_0, "Unicode_7_0"},
+#endif // Qt 5.5
#endif // Qt 5
};