diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-01 18:41:14 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-07-01 18:41:14 +0200 |
commit | e6a94778d0c26b59e367e9f9fe4f401725fc9c4e (patch) | |
tree | c7597213d7eac14863bc3cfd7bccd247c8950710 /tests/auto | |
parent | 605ba2c2268b2dce3d0b06899101d03a67e7f251 (diff) | |
parent | a09a8d509a69ed16d8afbe15296b8332cacd6c66 (diff) |
Merge "Merge remote-tracking branch 'origin/5.3' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto')
24 files changed, 580 insertions, 70 deletions
diff --git a/tests/auto/corelib/io/qdebug/qdebug.pro b/tests/auto/corelib/io/qdebug/qdebug.pro index 820c17fc69..5e902bb105 100644 --- a/tests/auto/corelib/io/qdebug/qdebug.pro +++ b/tests/auto/corelib/io/qdebug/qdebug.pro @@ -1,5 +1,5 @@ CONFIG += testcase parallel_test TARGET = tst_qdebug -QT = core testlib +QT = core testlib concurrent SOURCES = tst_qdebug.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 07e011f449..3f53ab5f0a 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -44,6 +44,9 @@ #include <QtCore/QtDebug> #include <QtTest/QtTest> +#include <QtConcurrentRun> +#include <QFutureSynchronizer> + class tst_QDebug: public QObject { Q_OBJECT @@ -59,6 +62,7 @@ private slots: void qDebugQLatin1String() const; void textStreamModifiers() const; void defaultMessagehandler() const; + void threadSafety() const; }; void tst_QDebug::assignment() const @@ -315,5 +319,41 @@ void tst_QDebug::defaultMessagehandler() const QVERIFY(same); } +QMutex s_mutex; +QStringList s_messages; +QSemaphore s_sema; + +static void threadSafeMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + QMutexLocker lock(&s_mutex); + s_messages.append(msg); + Q_UNUSED(type); + Q_UNUSED(context); +} + +static void doDebug() // called in each thread +{ + s_sema.acquire(); + qDebug() << "doDebug"; +} + +void tst_QDebug::threadSafety() const +{ + MessageHandlerSetter mhs(threadSafeMessageHandler); + const int numThreads = 10; + QThreadPool::globalInstance()->setMaxThreadCount(numThreads); + QFutureSynchronizer<void> sync; + for (int i = 0; i < numThreads; ++i) { + sync.addFuture(QtConcurrent::run(&doDebug)); + } + s_sema.release(numThreads); + sync.waitForFinished(); + QMutexLocker lock(&s_mutex); + QCOMPARE(s_messages.count(), numThreads); + for (int i = 0; i < numThreads; ++i) { + QCOMPARE(s_messages.at(i), QStringLiteral("doDebug")); + } +} + QTEST_MAIN(tst_QDebug); #include "tst_qdebug.moc" diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index 79ea53cc6b..90afeddaa0 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -2,7 +2,6 @@ CONFIG += testcase CONFIG += parallel_test CONFIG -= app_bundle debug_and_release_target QT = core testlib network -embedded: QT += gui SOURCES = ../tst_qprocess.cpp TARGET = ../tst_qprocess diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 67cf954f98..1d6418cbc0 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1953,7 +1953,7 @@ void tst_QProcess::setStandardOutputFile2() process.start("testProcessEcho2/testProcessEcho2"); process.write(testdata, sizeof testdata); QPROCESS_VERIFY(process,waitForFinished()); - QVERIFY(!process.bytesAvailable()); + QCOMPARE(process.bytesAvailable(), Q_INT64_C(0)); QVERIFY(!QFileInfo(QProcess::nullDevice()).isFile()); } diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro index 8d117793bf..f5d06b3de9 100644 --- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro +++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro @@ -4,7 +4,7 @@ CONFIG += ordered SUBDIRS = lib \ theplugin \ tst -!win32: !mac: SUBDIRS += almostplugin +!android: !win32: !mac: SUBDIRS += almostplugin macx-*: SUBDIRS += machtest TARGET = tst_qpluginloader diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp index 3df8422a34..3a00ebd505 100644 --- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp +++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp @@ -52,6 +52,9 @@ class tst_QCollator : public QObject private Q_SLOTS: void moveSemantics(); + + void compare_data(); + void compare(); }; #ifdef Q_COMPILER_RVALUE_REFS @@ -87,6 +90,96 @@ void tst_QCollator::moveSemantics() #endif } + +void tst_QCollator::compare_data() +{ + QTest::addColumn<QString>("locale"); + QTest::addColumn<QString>("s1"); + QTest::addColumn<QString>("s2"); + QTest::addColumn<int>("result"); + QTest::addColumn<int>("caseInsensitiveResult"); + + /* + A few tests below are commented out on the mac. It's unclear why they fail, + as it looks like the collator for the locale is created correctly. + */ + + /* + It's hard to test English, because it's treated differently + on different platforms. For example, on Linux, it uses the + iso14651_t1 template file, which happens to provide good + defaults for Swedish. Mac OS X seems to do a pure bytewise + comparison of Latin-1 values, although I'm not sure. So I + just test digits to make sure that it's not totally broken. + */ + QTest::newRow("english1") << QString("en_US") << QString("5") << QString("4") << 1 << 1; + QTest::newRow("english2") << QString("en_US") << QString("4") << QString("6") << -1 << -1; + QTest::newRow("english3") << QString("en_US") << QString("5") << QString("6") << -1 << -1; + QTest::newRow("english4") << QString("en_US") << QString("a") << QString("b") << -1 << -1; + /* + In Swedish, a with ring above (E5) comes before a with + diaresis (E4), which comes before o diaresis (F6), which + all come after z. + */ +#if !defined(Q_OS_WIN) || defined(QT_USE_ICU) + QTest::newRow("swedish1") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1 << -1; +#endif + QTest::newRow("swedish2") << QString("sv_SE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1 << -1; + QTest::newRow("swedish3") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1 << -1; +#if !defined(Q_OS_OSX) && (!defined(Q_OS_WIN) || defined(QT_USE_ICU)) + QTest::newRow("swedish4") << QString("sv_SE") << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1 << -1; +#endif + + /* + In Norwegian, ae (E6) comes before o with stroke (D8), which + comes before a with ring above (E5). + */ + QTest::newRow("norwegian1") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xd8") << -1 << -1; +#if !defined(Q_OS_WIN) || defined(QT_USE_ICU) +# ifndef Q_OS_OSX + QTest::newRow("norwegian2") << QString("no_NO") << QString::fromLatin1("\xd8") << QString::fromLatin1("\xe5") << -1 << -1; +# endif + QTest::newRow("norwegian3") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xe5") << -1 << -1; +#endif // !Q_OS_WIN || QT_USE_ICU + /* + In German, z comes *after* a with diaresis (E4), + which comes before o diaresis (F6). + */ + QTest::newRow("german1") << QString("de_DE") << QString::fromLatin1("a") << QString::fromLatin1("\xe4") << -1 << -1; + QTest::newRow("german2") << QString("de_DE") << QString::fromLatin1("b") << QString::fromLatin1("\xe4") << 1 << 1; + QTest::newRow("german3") << QString("de_DE") << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1 << 1; + QTest::newRow("german4") << QString("de_DE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1 << -1; + QTest::newRow("german5") << QString("de_DE") << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1 << 1; + QTest::newRow("german6") << QString("de_DE") << QString::fromLatin1("\xc0") << QString::fromLatin1("\xe0") << 1 << 0; + QTest::newRow("german7") << QString("de_DE") << QString::fromLatin1("\xd6") << QString::fromLatin1("\xf6") << 1 << 0; + QTest::newRow("german8") << QString("de_DE") << QString::fromLatin1("oe") << QString::fromLatin1("\xf6") << 1 << 1; + QTest::newRow("german9") << QString("de_DE") << QString("A") << QString("a") << 1 << 0; + + /* + French sorting of e and e with accent + */ + QTest::newRow("french1") << QString("fr_FR") << QString::fromLatin1("\xe9") << QString::fromLatin1("e") << 1 << 1; + QTest::newRow("french2") << QString("fr_FR") << QString::fromLatin1("\xe9t") << QString::fromLatin1("et") << 1 << 1; + QTest::newRow("french3") << QString("fr_FR") << QString::fromLatin1("\xe9") << QString::fromLatin1("d") << 1 << 1; + QTest::newRow("french4") << QString("fr_FR") << QString::fromLatin1("\xe9") << QString::fromLatin1("f") << -1 << -1; + +} + + +void tst_QCollator::compare() +{ + QFETCH(QString, locale); + QFETCH(QString, s1); + QFETCH(QString, s2); + QFETCH(int, result); + QFETCH(int, caseInsensitiveResult); + + QCollator collator(locale); + QCOMPARE(collator.compare(s1, s2), result); + collator.setCaseSensitivity(Qt::CaseInsensitive); + QCOMPARE(collator.compare(s1, s2), caseInsensitiveResult); +} + QTEST_APPLESS_MAIN(tst_QCollator) #include "tst_qcollator.moc" diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp index 6780493206..285cc3042a 100644 --- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp +++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp @@ -111,6 +111,13 @@ void tst_QRingBuffer::readPointerAtPositionWithHead() buf2 = ringBuffer.readPointerAtPosition(0, length); QCOMPARE(length, qint64(0)); QVERIFY(buf2 == 0); + + // check buffer with 2 blocks + memcpy(ringBuffer.reserve(4), "0123", 4); + ringBuffer.append(QByteArray("45678", 5)); + ringBuffer.free(3); + buf2 = ringBuffer.readPointerAtPosition(1, length); + QCOMPARE(length, qint64(5)); } void tst_QRingBuffer::readPointerAtPositionEmptyRead() diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index 0f642bcc10..524f0a30ed 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -55,6 +55,7 @@ public: tst_QIcon(); private slots: + void initTestCase(); void actualSize_data(); // test with 1 pixmap void actualSize(); void actualSize2_data(); // test with 2 pixmaps with different aspect ratio @@ -79,6 +80,10 @@ private slots: private: bool haveImageFormat(QByteArray const&); + const QString m_pngImageFileName; + const QString m_pngRectFileName; + const QString m_sourceFileName; + const static QIcon staticIcon; }; @@ -92,9 +97,19 @@ bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat) } tst_QIcon::tst_QIcon() + : m_pngImageFileName(QFINDTESTDATA("image.png")) + , m_pngRectFileName(QFINDTESTDATA("rect.png")) + , m_sourceFileName(QFINDTESTDATA(__FILE__)) { } +void tst_QIcon::initTestCase() +{ + QVERIFY(!m_pngImageFileName.isEmpty()); + QVERIFY(!m_pngRectFileName.isEmpty()); + QVERIFY(!m_sourceFileName.isEmpty()); +} + void tst_QIcon::actualSize_data() { QTest::addColumn<QString>("source"); @@ -115,14 +130,13 @@ void tst_QIcon::actualSize_data() QTest::newRow("resource9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128); - QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64); - QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32); - QTest::newRow("external3") << prefix + "image.png" << QSize( 16, 64) << QSize( 16, 16); - QTest::newRow("external4") << prefix + "image.png" << QSize( 16, 128) << QSize( 16, 16); - QTest::newRow("external5") << prefix + "image.png" << QSize( 128, 16) << QSize( 16, 16); - QTest::newRow("external6") << prefix + "image.png" << QSize( 150, 150) << QSize( 128, 128); + QTest::newRow("external0") << m_pngImageFileName << QSize(128, 128) << QSize(128, 128); + QTest::newRow("external1") << m_pngImageFileName << QSize( 64, 64) << QSize( 64, 64); + QTest::newRow("external2") << m_pngImageFileName << QSize( 32, 64) << QSize( 32, 32); + QTest::newRow("external3") << m_pngImageFileName << QSize( 16, 64) << QSize( 16, 16); + QTest::newRow("external4") << m_pngImageFileName << QSize( 16, 128) << QSize( 16, 16); + QTest::newRow("external5") << m_pngImageFileName << QSize(128, 16) << QSize( 16, 16); + QTest::newRow("external6") << m_pngImageFileName << QSize(150, 150) << QSize(128, 128); // rect image QTest::newRow("external7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); QTest::newRow("external8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); @@ -170,10 +184,8 @@ void tst_QIcon::actualSize2_data() void tst_QIcon::actualSize2() { QIcon icon; - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - - icon.addPixmap(QPixmap(prefix + "image.png")); - icon.addPixmap(QPixmap(prefix + "rect.png")); + icon.addPixmap(m_pngImageFileName); + icon.addPixmap(m_pngRectFileName); QFETCH(QSize, argument); QFETCH(QSize, result); @@ -209,14 +221,13 @@ void tst_QIcon::isNull() { QVERIFY(!iconNoFileSuffix.isNull()); QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid()); - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; // test string constructor with existing file but unsupported format - QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp"); + QIcon iconUnsupportedFormat = QIcon(m_sourceFileName); QVERIFY(!iconUnsupportedFormat.isNull()); QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid()); // test string constructor with existing file and supported format - QIcon iconSupportedFormat = QIcon(prefix + "image.png"); + QIcon iconSupportedFormat = QIcon(m_pngImageFileName); QVERIFY(!iconSupportedFormat.isNull()); QVERIFY(iconSupportedFormat.actualSize(QSize(32, 32)).isValid()); } @@ -347,7 +358,7 @@ void tst_QIcon::bestMatch() void tst_QIcon::cacheKey() { - QIcon icon1("image.png"); + QIcon icon1(m_pngImageFileName); qint64 icon1_key = icon1.cacheKey(); QIcon icon2 = icon1; @@ -363,7 +374,7 @@ void tst_QIcon::detach() img.fill(0xffff0000); QIcon icon1(QPixmap::fromImage(img)); QIcon icon2 = icon1; - icon2.addFile(QFINDTESTDATA("image.png"), QSize(64, 64)); + icon2.addFile(m_pngImageFileName, QSize(64, 64)); QImage img1 = icon1.pixmap(64, 64).toImage(); QImage img2 = icon2.pixmap(64, 64).toImage(); @@ -415,11 +426,11 @@ void tst_QIcon::availableSizes() { { QIcon icon; - icon.addFile("image.png", QSize(32,32)); - icon.addFile("image.png", QSize(64,64)); - icon.addFile("image.png", QSize(128,128)); - icon.addFile("image.png", QSize(256,256), QIcon::Disabled); - icon.addFile("image.png", QSize(16,16), QIcon::Normal, QIcon::On); + icon.addFile(m_pngImageFileName, QSize(32,32)); + icon.addFile(m_pngImageFileName, QSize(64,64)); + icon.addFile(m_pngImageFileName, QSize(128,128)); + icon.addFile(m_pngImageFileName, QSize(256,256), QIcon::Disabled); + icon.addFile(m_pngImageFileName, QSize(16,16), QIcon::Normal, QIcon::On); QList<QSize> availableSizes = icon.availableSizes(); QCOMPARE(availableSizes.size(), 3); @@ -542,7 +553,7 @@ static inline bool operator<(const QSize &lhs, const QSize &rhs) #ifndef QT_NO_WIDGETS void tst_QIcon::task184901_badCache() { - QPixmap pm(QFINDTESTDATA("image.png")); + QPixmap pm(m_pngImageFileName); QIcon icon(pm); //the disabled icon must have an effect (grayed) diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index d2072e0e56..0a4456e22a 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -146,6 +146,9 @@ private slots: void fillRGB888(); + void fillPixel_data(); + void fillPixel(); + void rgbSwapped_data(); void rgbSwapped(); @@ -2058,6 +2061,42 @@ void tst_QImage::fillRGB888() } } +void tst_QImage::fillPixel_data() +{ + QTest::addColumn<QImage::Format>("format"); + QTest::addColumn<uint>("color"); + QTest::addColumn<uint>("pixelValue"); + + QTest::newRow("RGB16, transparent") << QImage::Format_RGB16 << 0x0u << 0xff000000u; + QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << 0x0u << 0xff000000u; + QTest::newRow("RGBx8888, transparent") << QImage::Format_RGBX8888 << 0x0u << 0xff000000u; + QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u; + QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u; + QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u; + + QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u; + QTest::newRow("RGB32, red") << QImage::Format_RGB32 << 0xffff0000u << 0xffff0000u; + QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u; + QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u; + + QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u; + QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u; + QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u; + QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u; +} + +void tst_QImage::fillPixel() +{ + QFETCH(QImage::Format, format); + QFETCH(uint, color); + QFETCH(uint, pixelValue); + + QImage image(1, 1, format); + + image.fill(color); + QCOMPARE(image.pixel(0, 0), pixelValue); +} + void tst_QImage::rgbSwapped_data() { QTest::addColumn<QImage::Format>("format"); @@ -2128,35 +2167,56 @@ void tst_QImage::mirrored_data() QTest::addColumn<QImage::Format>("format"); QTest::addColumn<bool>("swap_vertical"); QTest::addColumn<bool>("swap_horizontal"); - - QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false; - QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false; - QTest::newRow("Format_ARGB32_Premultiplied, vertical") << QImage::Format_ARGB32_Premultiplied << true << false; - QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false; - QTest::newRow("Format_ARGB8565_Premultiplied, vertical") << QImage::Format_ARGB8565_Premultiplied << true << false; - QTest::newRow("Format_ARGB6666_Premultiplied, vertical") << QImage::Format_ARGB6666_Premultiplied << true << false; - QTest::newRow("Format_ARGB4444_Premultiplied, vertical") << QImage::Format_ARGB4444_Premultiplied << true << false; - QTest::newRow("Format_RGB666, vertical") << QImage::Format_RGB666 << true << false; - QTest::newRow("Format_RGB555, vertical") << QImage::Format_RGB555 << true << false; - QTest::newRow("Format_ARGB8555_Premultiplied, vertical") << QImage::Format_ARGB8555_Premultiplied << true << false; - QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false; - QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false; - QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false; - QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << 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_Premultiplied, horizontal") << QImage::Format_ARGB32_Premultiplied << 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_Premultiplied, horizontal+vertical") << QImage::Format_ARGB32_Premultiplied << 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; + QTest::addColumn<int>("width"); + QTest::addColumn<int>("height"); + + QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false << 16 << 16; + QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false << 16 << 16; + QTest::newRow("Format_ARGB32_Premultiplied, vertical") << QImage::Format_ARGB32_Premultiplied << true << false << 16 << 16; + QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false << 16 << 16; + QTest::newRow("Format_ARGB8565_Premultiplied, vertical") << QImage::Format_ARGB8565_Premultiplied << true << false << 16 << 16; + QTest::newRow("Format_ARGB6666_Premultiplied, vertical") << QImage::Format_ARGB6666_Premultiplied << true << false << 16 << 16; + QTest::newRow("Format_ARGB4444_Premultiplied, vertical") << QImage::Format_ARGB4444_Premultiplied << true << false << 16 << 16; + QTest::newRow("Format_RGB666, vertical") << QImage::Format_RGB666 << true << false << 16 << 16; + QTest::newRow("Format_RGB555, vertical") << QImage::Format_RGB555 << true << false << 16 << 16; + QTest::newRow("Format_ARGB8555_Premultiplied, vertical") << QImage::Format_ARGB8555_Premultiplied << true << false << 16 << 16; + QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false << 16 << 16; + QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false << 16 << 16; + QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false << 16 << 16; + QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << true << false << 16 << 16; + QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false << 16 << 16; + QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false << 16 << 16; + QTest::newRow("Format_MonoLSB, vertical") << QImage::Format_MonoLSB << true << false << 16 << 16; + + QTest::newRow("Format_ARGB32_Premultiplied, horizontal") << QImage::Format_ARGB32_Premultiplied << false << true << 16 << 16; + QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true << 16 << 16; + QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true << 16 << 16; + QTest::newRow("Format_Indexed8, horizontal") << QImage::Format_Indexed8 << false << true << 16 << 16; + QTest::newRow("Format_Mono, horizontal") << QImage::Format_Mono << false << true << 16 << 16; + QTest::newRow("Format_MonoLSB, horizontal") << QImage::Format_MonoLSB << false << true << 16 << 16; + + QTest::newRow("Format_ARGB32_Premultiplied, horizontal+vertical") << QImage::Format_ARGB32_Premultiplied << true << true << 16 << 16; + QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true << 16 << 16; + QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true << 16 << 16; + QTest::newRow("Format_Indexed8, horizontal+vertical") << QImage::Format_Indexed8 << true << true << 16 << 16; + QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true << 16 << 16; + QTest::newRow("Format_MonoLSB, horizontal+vertical") << QImage::Format_MonoLSB << true << true << 16 << 16; + + QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false << 8 << 16; + QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false << 16 << 8; + QTest::newRow("Format_Mono, vertical, non-aligned") << QImage::Format_Mono << true << false << 19 << 25; + QTest::newRow("Format_MonoLSB, vertical, non-aligned") << QImage::Format_MonoLSB << true << false << 19 << 25; + + // Non-aligned horizontal 1-bit needs special handling so test this. + QTest::newRow("Format_Mono, horizontal, non-aligned") << QImage::Format_Mono << false << true << 13 << 17; + QTest::newRow("Format_Mono, horizontal, non-aligned") << QImage::Format_Mono << false << true << 19 << 25; + QTest::newRow("Format_Mono, horizontal+vertical, non-aligned") << QImage::Format_Mono << true << true << 25 << 47; + QTest::newRow("Format_Mono, horizontal+vertical, non-aligned") << QImage::Format_Mono << true << true << 21 << 16; + + QTest::newRow("Format_MonoLSB, horizontal, non-aligned") << QImage::Format_MonoLSB << false << true << 13 << 17; + QTest::newRow("Format_MonoLSB, horizontal, non-aligned") << QImage::Format_MonoLSB << false << true << 19 << 25; + QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 25 << 47; + QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 21 << 16; } void tst_QImage::mirrored() @@ -2164,11 +2224,14 @@ void tst_QImage::mirrored() QFETCH(QImage::Format, format); QFETCH(bool, swap_vertical); QFETCH(bool, swap_horizontal); + QFETCH(int, width); + QFETCH(int, height); - QImage image(16, 16, format); + QImage image(width, height, format); 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) ? 0x5555U : 0xCCCCU; @@ -2205,7 +2268,7 @@ void tst_QImage::mirrored() QCOMPARE(image, imageMirroredTwice); - if (format != QImage::Format_Mono) + if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB) QCOMPARE(memcmp(image.constBits(), imageMirroredTwice.constBits(), image.byteCount()), 0); else { for (int i = 0; i < image.height(); ++i) diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 79dc3f311a..b9d0adcd21 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -91,6 +91,7 @@ private slots: void convertFromImage_data(); void convertFromImage(); + void convertFromImageShouldDetach(); void testMetrics(); @@ -343,6 +344,20 @@ void tst_QPixmap::convertFromImage() QCOMPARE(pix, res); } +void tst_QPixmap::convertFromImageShouldDetach() +{ + const QString prefix = QFINDTESTDATA("convertFromImage"); + QImage img1; + QImage img2; + QVERIFY(img1.load(prefix + "/task31722_0/img1.png")); + QVERIFY(img2.load(prefix + "/task31722_0/img2.png")); + QPixmap pix = QPixmap::fromImage(img1); + QPixmap pix1 = pix; + pix.convertFromImage(img2); + QCOMPARE(pix, QPixmap::fromImage(img2)); + QCOMPARE(pix1, QPixmap::fromImage(img1)); // unchanged +} + void tst_QPixmap::scroll_data() { QTest::addColumn<QImage>("input"); diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 44edcc66c0..4740b92b84 100644 --- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -62,6 +62,7 @@ public slots: void cleanupTestCase(); void init(); void cleanup(); + void accessAfterRemoveReadyReadSlot(); private slots: void qnetworkdiskcache_data(); @@ -74,6 +75,7 @@ private slots: void data(); void metaData(); void remove(); + void accessAfterRemove(); // QTBUG-17400 void setCacheDirectory_data(); void setCacheDirectory(); void updateMetaData(); @@ -89,6 +91,8 @@ private slots: private: QTemporaryDir tempDir; + QUrl url; // used by accessAfterRemove() + QNetworkDiskCache *diskCache; // used by accessAfterRemove() }; // FIXME same as in tst_qnetworkreply.cpp .. could be unified @@ -370,6 +374,40 @@ void tst_QNetworkDiskCache::remove() QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2); } +void tst_QNetworkDiskCache::accessAfterRemove() // QTBUG-17400 +{ + QByteArray data("HTTP/1.1 200 OK\r\n" + "Content-Length: 1\r\n" + "\r\n" + "a"); + + MiniHttpServer server(data); + + QNetworkAccessManager *manager = new QNetworkAccessManager(); + SubQNetworkDiskCache subCache; + subCache.setCacheDirectory(QLatin1String("cacheDir")); + diskCache = &subCache; + manager->setCache(&subCache); + + url = QUrl("http://127.0.0.1:" + QString::number(server.serverPort())); + QNetworkRequest request(url); + + QNetworkReply *reply = manager->get(request); + connect(reply, SIGNAL(readyRead()), this, SLOT(accessAfterRemoveReadyReadSlot())); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + + reply->deleteLater(); + manager->deleteLater(); +} + +void tst_QNetworkDiskCache::accessAfterRemoveReadyReadSlot() +{ + diskCache->remove(url); // this used to cause a crash later on +} + void tst_QNetworkDiskCache::setCacheDirectory_data() { QTest::addColumn<QString>("cacheDir"); diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index c4d42206fe..99f677643c 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -55,6 +55,10 @@ # endif #endif +#ifdef Q_OS_ANDROID +# include <netinet/in.h> +#endif + class tst_QHostAddress : public QObject { Q_OBJECT diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 122ac63034..8e69d827a6 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -1976,9 +1976,9 @@ public slots: attemptedToConnect = true; sock->connectToHost(QtNetworkSettings::serverName(), 80); -#ifdef Q_OS_MAC +#if defined(Q_OS_MAC) pthread_yield_np(); -#elif defined Q_OS_LINUX +#elif defined Q_OS_LINUX && !defined Q_OS_ANDROID pthread_yield(); #endif if (!sock->waitForConnected()) { @@ -2485,7 +2485,7 @@ void tst_QTcpSocket::increaseReadBufferSizeFromSlot() // like KIO's socketconnec QVERIFY2(passive->waitForBytesWritten(5000), "Network timeout"); // set the read buffer size to less than what was written, - // and increase it from the slot, first to 384 then to 1024. + // and increase it from the slot, first to 384 then to 512. active->setReadBufferSize(256); enterLoop(10); QVERIFY2(!timeout(), "Network timeout"); diff --git a/tests/auto/other/macgui/tst_macgui.cpp b/tests/auto/other/macgui/tst_macgui.cpp index 14993145b4..4314842c50 100644 --- a/tests/auto/other/macgui/tst_macgui.cpp +++ b/tests/auto/other/macgui/tst_macgui.cpp @@ -203,6 +203,7 @@ void tst_MacGui::nonModalOrder() primary.resize(400, 400); primary.move(100, 100); primary.exec(); + QEXPECT_FAIL("", "Non-modal child windows show behind the modal dialig", Abort); QCOMPARE(primary.frontWidget, primary.secondaryWindow); } diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 0ae94fe415..745c8f2499 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -22,6 +22,7 @@ SUBDIRS=\ qobjectperformance \ qobjectrace \ qsharedpointer_and_qwidget \ + qprocess_and_guieventloop \ qtokenautomaton \ windowsmobile \ @@ -70,3 +71,5 @@ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility !embedded|wince*: SUBDIRS -= \ qdirectpainter +winrt: SUBDIRS -= \ + qprocess_and_guieventloop diff --git a/tests/auto/other/qprocess_and_guieventloop/qprocess_and_guieventloop.pro b/tests/auto/other/qprocess_and_guieventloop/qprocess_and_guieventloop.pro new file mode 100644 index 0000000000..e349fe5b11 --- /dev/null +++ b/tests/auto/other/qprocess_and_guieventloop/qprocess_and_guieventloop.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = \ + write-read-write +SUBDIRS += test.pro diff --git a/tests/auto/other/qprocess_and_guieventloop/test.pro b/tests/auto/other/qprocess_and_guieventloop/test.pro new file mode 100644 index 0000000000..54d6f194b0 --- /dev/null +++ b/tests/auto/other/qprocess_and_guieventloop/test.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +CONFIG += parallel_test +QT = core gui testlib +SOURCES = tst_qprocess_and_guieventloop.cpp +TARGET = tst_qprocess_and_guieventloop diff --git a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp new file mode 100644 index 0000000000..42153c6c80 --- /dev/null +++ b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Intel Corporation +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt 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.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QGuiApplication> +#include <QtTest/QtTest> +#include <QtCore/QProcess> + +class tst_QProcess_and_GuiEventLoop : public QObject +{ + Q_OBJECT +private slots: + void waitForAndEventLoop(); +}; + + +void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop() +{ + // based on testcase provided in QTBUG-39488 + QByteArray msg = "Hello World"; + + QProcess process; + process.start("write-read-write/write-read-write", QStringList() << msg); + QVERIFY(process.waitForStarted(5000)); + QVERIFY(process.waitForReadyRead(5000)); + QCOMPARE(process.readAll().trimmed(), msg); + + // run the GUI event dispatcher once + QSignalSpy spy(&process, SIGNAL(readyRead())); + qApp->processEvents(QEventLoop::AllEvents, 100); + + // we mustn't have read anything in the event loop + QCOMPARE(spy.count(), 0); + + // ensure the process hasn't died + QVERIFY(!process.waitForFinished(250)); + + // we mustn't have read anything during waitForFinished either + QCOMPARE(spy.count(), 0); + + // release the child for the second write + process.write("\n"); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(int(process.exitStatus()), int(QProcess::NormalExit)); + QCOMPARE(process.exitCode(), 0); + QCOMPARE(spy.count(), 1); + QCOMPARE(process.readAll().trimmed(), msg); +} + +QTEST_MAIN(tst_QProcess_and_GuiEventLoop) + +#include "tst_qprocess_and_guieventloop.moc" diff --git a/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp new file mode 100644 index 0000000000..e8fc3b5cff --- /dev/null +++ b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Intel Corporation +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt 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.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <stdio.h> + +int main(int argc, char **argv) +{ + const char *msg = argv[1]; + char buf[2]; + + puts(msg); + fflush(stdout); + + // wait for a newline + fgets(buf, sizeof buf, stdin); + + puts(msg); + fflush(stdout); + return 0; +} diff --git a/tests/auto/other/qprocess_and_guieventloop/write-read-write/write-read-write.pro b/tests/auto/other/qprocess_and_guieventloop/write-read-write/write-read-write.pro new file mode 100644 index 0000000000..e236e05c7d --- /dev/null +++ b/tests/auto/other/qprocess_and_guieventloop/write-read-write/write-read-write.pro @@ -0,0 +1,4 @@ +SOURCES = main.cpp +CONFIG -= qt app_bundle +CONFIG += console +DESTDIR = ./ diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index c5469bd33a..9a737ef96b 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1839,6 +1839,12 @@ void tst_Moc::warnings_data() << QString("IGNORE_ALL_STDOUT") << QString(":3: Warning: Macro argument mismatch.\n:4: Warning: Macro argument mismatch."); + QTest::newRow("Class declaration lacks Q_OBJECT macro.") + << QByteArray("class X : public QObject \n { \n public slots: \n void foo() {} \n };") + << QStringList() + << 1 + << QString() + << QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro."); } void tst_Moc::warnings() diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 34936fa5b8..eac8ab2236 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -1210,6 +1210,12 @@ void tst_QWidget::isEnabledTo() QVERIFY( !childWidget->isEnabledTo( testWidget ) ); QVERIFY( grandChildWidget->isEnabledTo( childWidget ) ); QVERIFY( !grandChildWidget->isEnabledTo( testWidget ) ); + + QMainWindow* childDialog = new QMainWindow(testWidget); + testWidget->setEnabled(false); + QVERIFY(!childDialog->isEnabled()); + QVERIFY(childDialog->isEnabledTo(0)); + testWidget->setEnabled(true); } void tst_QWidget::visible() diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 14d59d3630..b1e43b69ad 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -106,7 +106,7 @@ private slots: void changeStyleInChangeEvent(); void QTBUG15910_crashNullWidget(); void QTBUG36933_brokenPseudoClassLookup(); - + void styleSheetChangeBeforePolish(); //at the end because it mess with the style. void widgetStyle(); void appStyle(); @@ -147,7 +147,7 @@ tst_QStyleSheetStyle::~tst_QStyleSheetStyle() void tst_QStyleSheetStyle::numinstances() { - QWidget w; + /*QWidget w; w.resize(200, 200); centerOnScreen(&w); QCommonStyle *style = new QCommonStyle; @@ -180,7 +180,7 @@ void tst_QStyleSheetStyle::numinstances() c.setStyle(style); QCOMPARE(QStyleSheetStyle::numinstances, 2); w.setStyleSheet(""); - QCOMPARE(QStyleSheetStyle::numinstances, 0); + QCOMPARE(QStyleSheetStyle::numinstances, 0);*/ } void tst_QStyleSheetStyle::widgetsBeforeAppStyleSheet() @@ -351,7 +351,7 @@ void tst_QStyleSheetStyle::repolish() void tst_QStyleSheetStyle::widgetStyle() { - qApp->setStyleSheet(""); + /*qApp->setStyleSheet(""); QWidget *window1 = new QWidget; window1->setObjectName("window1"); @@ -488,12 +488,12 @@ void tst_QStyleSheetStyle::widgetStyle() delete widget2; delete window2; delete style1; - delete style2; + delete style2;*/ } void tst_QStyleSheetStyle::appStyle() { - qApp->setStyleSheet(""); + /* qApp->setStyleSheet(""); // qApp style can never be 0 QVERIFY(QApplication::style() != 0); QPointer<QStyle> style1 = QStyleFactory::create("Windows"); @@ -531,7 +531,7 @@ void tst_QStyleSheetStyle::appStyle() QVERIFY(qApp->style() == style1); qApp->setStyleSheet(""); - QVERIFY(qApp->style() == style1); + QVERIFY(qApp->style() == style1);*/ } void tst_QStyleSheetStyle::dynamicProperty() @@ -1754,6 +1754,29 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup() QVERIFY(testForColors(image, QColor(0xFF, 0x00, 0x00))); } +void tst_QStyleSheetStyle::styleSheetChangeBeforePolish() +{ + QWidget widget; + QVBoxLayout *vbox = new QVBoxLayout(&widget); + QFrame *frame = new QFrame(&widget); + frame->setFixedSize(200, 200); + frame->setStyleSheet("background-color: #FF0000;"); + frame->setStyleSheet("background-color: #00FF00;"); + vbox->addWidget(frame); + QFrame *frame2 = new QFrame(&widget); + frame2->setFixedSize(200, 200); + frame2->setStyleSheet("background-color: #FF0000;"); + frame2->setStyleSheet("background-color: #00FF00;"); + vbox->addWidget(frame); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + QImage image(frame->size(), QImage::Format_ARGB32); + frame->render(&image); + QVERIFY(testForColors(image, QColor(0x00, 0xFF, 0x00))); + QImage image2(frame2->size(), QImage::Format_ARGB32); + frame2->render(&image2); + QVERIFY(testForColors(image2, QColor(0x00, 0xFF, 0x00))); +} QTEST_MAIN(tst_QStyleSheetStyle) #include "tst_qstylesheetstyle.moc" diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index abc0129f8b..c38c254b9a 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -72,6 +72,7 @@ #include <qstylefactory.h> #include <qabstractitemview.h> #include <qstyleditemdelegate.h> +#include <qstandarditemmodel.h> #include <qproxystyle.h> static inline void setFrameless(QWidget *w) @@ -163,6 +164,7 @@ private slots: void itemData(); void task_QTBUG_31146_popupCompletion(); void keyboardSelection(); + void setCustomModelAndView(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1580,6 +1582,45 @@ void tst_QComboBox::setModel() QVERIFY(box.model() != oldModel); } +void tst_QComboBox::setCustomModelAndView() +{ + // QTBUG-27597, ensure the correct text is returned when using custom view and a tree model. + QComboBox combo; + combo.setWindowTitle("QTBUG-27597, setCustomModelAndView"); + combo.setEditable(true); + combo.setMinimumWidth(400); + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + combo.move(availableGeometry.center() - QPoint(200, 20)); + + QStandardItemModel *model = new QStandardItemModel(0, 1, &combo); + + QStandardItem *item = new QStandardItem(QStringLiteral("Item1")); + item->appendRow(new QStandardItem(QStringLiteral("Item11"))); + model->appendRow(item); + + item = new QStandardItem(QStringLiteral("Item2")); + model->appendRow(item); + const QString subItem21Text = QStringLiteral("Item21"); + QStandardItem *subItem = new QStandardItem(subItem21Text); + item->appendRow(subItem); + + QTreeView* view = new QTreeView(&combo); + view->setHeaderHidden(true); + view->setSelectionMode(QAbstractItemView::SingleSelection); + view->setModel(model); + view->expandAll(); + combo.setModel(model); + combo.setView(view); + combo.show(); + QVERIFY(QTest::qWaitForWindowExposed(&combo)); + combo.showPopup(); + QTRY_VERIFY(combo.view()->isVisible()); + const QRect subItemRect = view->visualRect(model->indexFromItem(subItem)); + QWidget *window = view->window(); + QTest::mouseClick(window->windowHandle(), Qt::LeftButton, 0, view->mapTo(window, subItemRect.center())); + QTRY_COMPARE(combo.currentText(), subItem21Text); +} + void tst_QComboBox::modelDeleted() { QComboBox box; |