diff options
Diffstat (limited to 'tests/auto')
19 files changed, 490 insertions, 111 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 80144dba20..8fd830a839 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 @@ -305,5 +309,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 b67166272b..82a0f3f832 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/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 95a9b142ec..6c496ba6d4 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(); @@ -2054,6 +2057,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"); @@ -2124,35 +2163,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() @@ -2160,11 +2220,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; @@ -2201,7 +2264,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/other/other.pro b/tests/auto/other/other.pro index e6017168d0..407237e519 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -23,6 +23,7 @@ SUBDIRS=\ qobjectperformance \ qobjectrace \ qsharedpointer_and_qwidget \ + qprocess_and_guieventloop \ qtokenautomaton \ windowsmobile \ @@ -71,3 +72,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 04140fa4a1..2e1504383f 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1828,6 +1828,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 73bec9a6b9..eac8ab2236 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -262,7 +262,6 @@ private slots: void optimizedResizeMove(); void optimizedResize_topLevel(); void resizeEvent(); - void moveEvent(); void task110173(); void testDeletionInEventHandlers(); @@ -1211,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() @@ -2109,53 +2114,41 @@ void tst_QWidget::showFullScreen() class ResizeWidget : public QWidget { public: - ResizeWidget(QWidget *p = 0) - : QWidget(p) - , m_spontaneousResizeEventCount(0) - , m_synthesizedResizeEventCount(0) - , m_spontaneousMoveEventCount(0) - , m_synthesizedMoveEventCount(0) + ResizeWidget(QWidget *p = 0) : QWidget(p) { setObjectName(QLatin1String("ResizeWidget")); setWindowTitle(objectName()); + m_resizeEventCount = 0; } protected: void resizeEvent(QResizeEvent *e){ QCOMPARE(size(), e->size()); - (e->spontaneous() ? m_spontaneousResizeEventCount : m_synthesizedResizeEventCount)++; - } - void moveEvent(QMoveEvent *e) - { - (e->spontaneous() ? m_spontaneousMoveEventCount : m_synthesizedMoveEventCount)++; + ++m_resizeEventCount; } public: - int m_spontaneousResizeEventCount; - int m_synthesizedResizeEventCount; - int m_spontaneousMoveEventCount; - int m_synthesizedMoveEventCount; + int m_resizeEventCount; }; void tst_QWidget::resizeEvent() { + QSKIP("QTBUG-30744"); + { QWidget wParent; wParent.resize(200, 200); ResizeWidget wChild(&wParent); wParent.show(); QTest::qWaitForWindowExposed(&wParent); - QCOMPARE (wChild.m_synthesizedResizeEventCount, 1); // initial resize event before paint - QCOMPARE (wChild.m_spontaneousResizeEventCount, 0); + QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint wParent.hide(); QSize safeSize(640,480); if (wChild.size() == safeSize) safeSize.setWidth(639); wChild.resize(safeSize); - QCOMPARE (wChild.m_synthesizedResizeEventCount, 1); - QCOMPARE (wChild.m_spontaneousResizeEventCount, 0); + QCOMPARE (wChild.m_resizeEventCount, 1); wParent.show(); - QCOMPARE (wChild.m_synthesizedResizeEventCount, 2); - QCOMPARE (wChild.m_spontaneousResizeEventCount, 0); + QCOMPARE (wChild.m_resizeEventCount, 2); } { @@ -2163,39 +2156,19 @@ void tst_QWidget::resizeEvent() wTopLevel.resize(200, 200); wTopLevel.show(); QTest::qWaitForWindowExposed(&wTopLevel); - const int synthesizedResizeEventCountAfterShow = wTopLevel.m_synthesizedResizeEventCount; - QCOMPARE (synthesizedResizeEventCountAfterShow, 1); // initial resize event before paint for toplevels - QCOMPARE (wTopLevel.m_spontaneousResizeEventCount, 0); + QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels wTopLevel.hide(); QSize safeSize(640,480); if (wTopLevel.size() == safeSize) safeSize.setWidth(639); wTopLevel.resize(safeSize); - QCOMPARE (wTopLevel.m_synthesizedResizeEventCount, synthesizedResizeEventCountAfterShow); - QCOMPARE (wTopLevel.m_spontaneousResizeEventCount, 0); + QCOMPARE (wTopLevel.m_resizeEventCount, 1); wTopLevel.show(); QTest::qWaitForWindowExposed(&wTopLevel); -#ifdef Q_OS_OSX - QEXPECT_FAIL("", "QTBUG-30744", Abort); -#endif - QCOMPARE (wTopLevel.m_synthesizedResizeEventCount, synthesizedResizeEventCountAfterShow + 1); - QCOMPARE (wTopLevel.m_spontaneousResizeEventCount, 0); + QCOMPARE (wTopLevel.m_resizeEventCount, 2); } } -void tst_QWidget::moveEvent() -{ - ResizeWidget wTopLevel; - wTopLevel.resize(200, 200); - centerOnScreen(&wTopLevel); - wTopLevel.show(); - QTest::qWaitForWindowExposed(&wTopLevel); - const int synthesizedMoveEventCountAfterShow = wTopLevel.m_synthesizedMoveEventCount; - wTopLevel.move(wTopLevel.pos() + QPoint(20, 20)); - QTRY_COMPARE (wTopLevel.m_synthesizedMoveEventCount, synthesizedMoveEventCountAfterShow + 1); - QCOMPARE (wTopLevel.m_spontaneousMoveEventCount, 0); -} - void tst_QWidget::showMinimized() { QWidget plain; 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; |