From 88c4388022de192d2834ffa16b4d5f572993da58 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 25 Apr 2016 17:02:54 +0200 Subject: tst_QWidget: make it stable on OS X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch QSKIPs all tests that: - take to much time sitting in some QTRY_VERIFY or similar before failing - result in 'not in fullscreen mode' warning (with PASS) - thus completely flaky. - Where previously determined to not apply to OS X using QT_OS_MAC The intent is to make the test run-time more reasonable, both when running the test locally and on the CI system. Reduce the BLACKLIST - to avoid a 'double elimination' the tests that are skipped now, should not be BLACKLISTed so that we fix them for good. Task-number: QTBUG-52974 Change-Id: I34dc2010d0debc6b5b99f2375a6da902b7a17b29 Reviewed-by: Morten Johan Sørvig --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 14 ----- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 62 +++++++++++++++++++---- 2 files changed, 53 insertions(+), 23 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 4563da8d48..773f4205af 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -1,10 +1,8 @@ # OSX QTBUG-25300 QTBUG-45502 [normalGeometry] ubuntu-14.04 -osx [saveRestoreGeometry] ubuntu-14.04 -osx [restoreVersion1Geometry] ubuntu-14.04 osx @@ -20,20 +18,12 @@ ubuntu-14.04 ubuntu-14.04 [largerThanScreen_QTBUG30142] ubuntu-14.04 -[windowState] -osx [showMaximized] osx [setGeometry] osx -[stackUnder] -osx [raise] osx -[widgetAt] -osx -[sheetOpacity] -osx [resizeEvent] osx [setWindowGeometry] @@ -50,10 +40,6 @@ osx osx [render_systemClip] osx -[update] -osx -[doubleRepaint] -osx [childAt_unifiedToolBar] osx [showMinimizedKeepsFocus] diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index c2b01ea087..20bdf00292 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -1877,6 +1877,10 @@ void tst_QWidget::activation() void tst_QWidget::windowState() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("xcb")) QSKIP("X11: Many window managers do not support window state properly, which causes this test to fail."); if (m_platform == QStringLiteral("wayland")) @@ -2088,6 +2092,10 @@ void tst_QWidget::showMaximized() void tst_QWidget::showFullScreen() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); QWidget plain; @@ -2447,6 +2455,10 @@ void tst_QWidget::reparent() // Qt/Embedded does it differently. void tst_QWidget::icon() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + QPixmap p(20,20); p.fill(Qt::red); testWidget->setWindowIcon(p); @@ -2498,6 +2510,10 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() void tst_QWidget::normalGeometry() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); QWidget parent; @@ -2848,8 +2864,6 @@ void tst_QWidget::raise() } } -// Cocoa has no Z-Order for views, we hack it, but it results in paint events. -#ifndef QT_OS_MAC void tst_QWidget::lower() { QScopedPointer parent(new QWidget); @@ -2911,12 +2925,13 @@ void tst_QWidget::lower() list2 << child4 << child1 << child2 << child3; QCOMPARE(parent->children(), list2); } -#endif -// Cocoa has no Z-Order for views, we hack it, but it results in paint events. -#ifndef QT_OS_MAC void tst_QWidget::stackUnder() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974: Cocoa has no Z-Order for views, we hack it, but it results in paint events."); +#endif + QScopedPointer parent(new QWidget); parent->setObjectName(QLatin1String("stackUnder")); parent->setWindowTitle(parent->objectName()); @@ -2997,7 +3012,6 @@ void tst_QWidget::stackUnder() child->reset(); } } -#endif void drawPolygon(QPaintDevice *dev, int w, int h) { @@ -3086,6 +3100,10 @@ void tst_QWidget::testContentsPropagation() void tst_QWidget::saveRestoreGeometry() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); const QPoint position = m_availableTopLeft + QPoint(100, 100); @@ -3311,6 +3329,10 @@ void tst_QWidget::restoreVersion1Geometry() void tst_QWidget::widgetAt() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); Q_CHECK_PAINTEVENTS @@ -3526,6 +3548,7 @@ void tst_QWidget::testDeletionInEventHandlers() #ifdef Q_OS_OSX void tst_QWidget::sheetOpacity() { + QSKIP("QTBUG-52974: this test will most probably be deleted - to be investigated."); QWidget tmpWindow; QWidget sheet(&tmpWindow, Qt::Sheet); tmpWindow.show(); @@ -4176,6 +4199,10 @@ void tst_QWidget::showHideEventWhileMinimize() void tst_QWidget::update() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + QTest::qWait(10); // Wait for the initStuff to do it's stuff. Q_CHECK_PAINTEVENTS @@ -5165,10 +5192,13 @@ void tst_QWidget::showAndMoveChild() VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), Qt::red); } -// Cocoa only has rect granularity. -#ifndef QT_OS_MAC + void tst_QWidget::subtractOpaqueSiblings() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974: Cocoa only has rect granularity."); +#endif + QWidget w; w.setGeometry(50, 50, 300, 300); @@ -5201,7 +5231,6 @@ void tst_QWidget::subtractOpaqueSiblings() QRegion(medium->geometry().translated(large->pos())) - tall->geometry()); } -#endif void tst_QWidget::deleteStyle() { @@ -5243,6 +5272,10 @@ public slots: void tst_QWidget::multipleToplevelFocusCheck() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); TopLevelFocusCheck w1; @@ -7916,6 +7949,10 @@ void tst_QWidget::sendUpdateRequestImmediately() void tst_QWidget::doubleRepaint() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + #if defined(Q_OS_OSX) if (!macHasAccessToWindowsServer()) QSKIP("Not having window server access causes the wrong number of repaints to be issues"); @@ -9580,6 +9617,10 @@ void tst_QWidget::childAt_unifiedToolBar() void tst_QWidget::taskQTBUG_11373() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + QScopedPointer myWindow(new QMainWindow); QWidget * center = new QWidget(); myWindow -> setCentralWidget(center); @@ -10442,6 +10483,9 @@ public: // when mousing over it. void tst_QWidget::taskQTBUG_27643_enterEvents() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974: this test can crash!"); +#endif // Move the mouse cursor to a safe location so it won't interfere QCursor::setPos(m_safeCursorPos); -- cgit v1.2.3 From 11ad50074b57df7559d39a0620a1e1b35d0ac061 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 27 Apr 2016 08:40:16 +0200 Subject: tst_qudpsocket - remove insignificant BLACKLIST should make it, recent regression in QUdpSocket went unnoticed (first) because of 'insignificant'. We'd like to avoid such regressions in future (again, using BLACKLIST if needed and fixig the real problem then). NB: BLACKLIST in this patch was extended to deal with previously unnoticed failures on Windows and OS X. 'multicast' and related family of of functions on OS X will probably stay like this (seems to be a Darwin's quirk), datagram size related tests - fixed in dev or 5.7 (change is in nativesocket engine, 'bytesAvailable'). Task-number: QTBUG-52714 Change-Id: I039b05935a02983ce1648de449907dfa765f7db7 Reviewed-by: Friedemann Kleint --- tests/auto/network/socket/qudpsocket/BLACKLIST | 12 ++++++++++++ tests/auto/network/socket/qudpsocket/test/test.pro | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST index 3e936aebf6..fb8455e6d3 100644 --- a/tests/auto/network/socket/qudpsocket/BLACKLIST +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -6,3 +6,15 @@ osx osx [multicast:same bind, group ipv4 address] osx +[writeDatagramToNonExistingPeer] +windows +[asyncReadDatagram] +windows +[multicastLeaveAfterClose] +osx +[readyRead] +osx +[readyReadForEmptyDatagram] +osx +[asyncReadDatagram] +osx diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index 8ad16c652d..e4812416dc 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -22,5 +22,3 @@ wince* { } TARGET = tst_qudpsocket - -CONFIG+=insignificant_test # QTBUG-25367, QTBUG-25368 -- cgit v1.2.3 From e1d0da65261077bfd720887d6e6216497abb4c5f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Apr 2016 12:36:28 -0700 Subject: Fix Clang -Wexpansion-to-defined warning by deprecating QT_SUPPORTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C and C++ standards say it's undefined whether the preprocessor supports macros that expand to defined() will operate as an ifdef. Clang 3.9 started complaining about that fact. One solution was to change QT_SUPPORTS to check for zero or one, which means we need to change the #defines QT_NO_xxx to #define QT_NO_xxx 1. The C standard says we don't need to #define to 0, as an unknown token is interpreted as zero. However, that might produce a warning (GCC with -Wundef), so changing the macro this way is not recommended. Instead, we deprecate the macro and replace the uses with #ifdef/ndef. Change-Id: Id75834dab9ed466e94c7ffff1444874d5680b96a Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qarraydata/simplevector.h | 2 +- .../corelib/tools/qarraydata/tst_qarraydata.cpp | 30 +++++++++++----------- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 2 +- .../corelib/tools/qlinkedlist/tst_qlinkedlist.cpp | 4 +-- tests/auto/corelib/tools/qlist/tst_qlist.cpp | 6 ++--- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 4 +-- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 22 ++++++++-------- 7 files changed, 35 insertions(+), 35 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h index 091d871e82..9c7e1ae228 100644 --- a/tests/auto/corelib/tools/qarraydata/simplevector.h +++ b/tests/auto/corelib/tools/qarraydata/simplevector.h @@ -93,7 +93,7 @@ public: bool isStatic() const { return d->ref.isStatic(); } bool isShared() const { return d->ref.isShared(); } bool isSharedWith(const SimpleVector &other) const { return d == other.d; } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) bool isSharable() const { return d->ref.isSharable(); } void setSharable(bool sharable) { d.setSharable(sharable); } #endif diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 31e44bc3ae..31ade26067 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -44,7 +44,7 @@ struct SharedNullVerifier { Q_ASSERT(QArrayData::shared_null[0].ref.isStatic()); Q_ASSERT(QArrayData::shared_null[0].ref.isShared()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Q_ASSERT(QArrayData::shared_null[0].ref.isSharable()); #endif } @@ -101,7 +101,7 @@ void tst_QArrayData::referenceCounting() QCOMPARE(array.ref.atomic.load(), 1); QVERIFY(!array.ref.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(array.ref.isSharable()); #endif @@ -123,7 +123,7 @@ void tst_QArrayData::referenceCounting() // Now would be a good time to free/release allocated data } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { // Reference counting initialized to 0 (non-sharable) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 }; @@ -151,7 +151,7 @@ void tst_QArrayData::referenceCounting() QCOMPARE(array.ref.atomic.load(), -1); QVERIFY(array.ref.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(array.ref.isSharable()); #endif @@ -178,7 +178,7 @@ void tst_QArrayData::sharedNullEmpty() QCOMPARE(null->ref.atomic.load(), -1); QCOMPARE(empty->ref.atomic.load(), -1); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(null->ref.isSharable()); QVERIFY(empty->ref.isSharable()); #endif @@ -309,7 +309,7 @@ void tst_QArrayData::simpleVector() QVERIFY(!v7.isShared()); QVERIFY(!v8.isShared()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v1.isSharable()); QVERIFY(v2.isSharable()); QVERIFY(v3.isSharable()); @@ -502,7 +502,7 @@ void tst_QArrayData::simpleVector() for (int i = 0; i < 120; ++i) QCOMPARE(v1[i], v8[i % 10]); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { v7.setSharable(true); QVERIFY(v7.isSharable()); @@ -672,7 +672,7 @@ void tst_QArrayData::allocate_data() QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0); QVERIFY(shared_empty); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, QArrayData::Unsharable); QVERIFY(unsharable_empty); #endif @@ -686,7 +686,7 @@ void tst_QArrayData::allocate_data() } options[] = { { "Default", QArrayData::Default, false, true, shared_empty }, { "Reserved", QArrayData::CapacityReserved, true, true, shared_empty }, -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { "Reserved | Unsharable", QArrayData::CapacityReserved | QArrayData::Unsharable, true, false, unsharable_empty }, @@ -736,7 +736,7 @@ void tst_QArrayData::allocate() else QCOMPARE(data->alloc, uint(capacity)); QCOMPARE(data->capacityReserved, uint(isCapacityReserved)); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(bool, isSharable); QCOMPARE(data->ref.isSharable(), isSharable); #endif @@ -1316,7 +1316,7 @@ static inline bool arrayIsFilledWith(const QArrayDataPointer &array, void tst_QArrayData::setSharable_data() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QTest::addColumn >("array"); QTest::addColumn("size"); QTest::addColumn("capacity"); @@ -1362,7 +1362,7 @@ void tst_QArrayData::setSharable_data() void tst_QArrayData::setSharable() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(QArrayDataPointer, array); QFETCH(size_t, size); QFETCH(size_t, capacity); @@ -1492,7 +1492,7 @@ void fromRawData_impl() QVERIFY((const T *)raw.constBegin() != array); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { // Immutable, unsharable SimpleVector raw = SimpleVector::fromRawData(array, @@ -1578,7 +1578,7 @@ void tst_QArrayData::literals() QVERIFY(v.isStatic()); #endif -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); #endif QCOMPARE((void*)(const char*)(v.constBegin() + v.size()), (void*)(const char*)v.constEnd()); @@ -1629,7 +1629,7 @@ void tst_QArrayData::variadicLiterals() QVERIFY(v.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); #endif QCOMPARE((const int *)(v.constBegin() + v.size()), (const int *)v.constEnd()); diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 6a5c6b5670..d485040a14 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1191,7 +1191,7 @@ void tst_QHash::noNeedlessRehashes() void tst_QHash::const_shared_null() { QHash hash2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QHash hash1; hash1.setSharable(false); QVERIFY(hash1.isDetached()); diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index d3ace40164..848fdae445 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -1027,7 +1027,7 @@ template void tst_QLinkedList::constSharedNull() const { QLinkedList list2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QLinkedList list1; list1.setSharable(false); QVERIFY(list1.isDetached()); @@ -1059,7 +1059,7 @@ void tst_QLinkedList::constSharedNullComplex() const void tst_QLinkedList::setSharableInt() const { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QLinkedList orglist; orglist << 0 << 1 << 2 << 3 << 4 << 5; int size = 6; diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 1bb31afa9c..87f0012002 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1892,7 +1892,7 @@ template void tst_QList::constSharedNull() const { QList list2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QList list1; list1.setSharable(false); QVERIFY(list1.isDetached()); @@ -1926,7 +1926,7 @@ void tst_QList::constSharedNullComplex() const template void generateSetSharableData() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QTest::addColumn >("list"); QTest::addColumn("size"); @@ -1938,7 +1938,7 @@ void generateSetSharableData() template void runSetSharableTest() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(QList, list); QFETCH(int, size); diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index bb6535b635..1fb9dc6d7d 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1012,7 +1012,7 @@ void tst_QMap::qmultimap_specific() void tst_QMap::const_shared_null() { QMap map2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QMap map1; map1.setSharable(false); QVERIFY(map1.isDetached()); @@ -1109,7 +1109,7 @@ const T &const_(const T &t) void tst_QMap::setSharable() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QMap map; map.insert(1, "um"); diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 87822bca6f..edcf4c72b6 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -431,7 +431,7 @@ void tst_QVector::copyConstructor() const QVector v2(v1); QCOMPARE(v1, v2); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v1; @@ -595,7 +595,7 @@ void tst_QVector::append() const QVERIFY(v.size() == 3); QCOMPARE(v.at(v.size() - 1), SimpleValue::at(0)); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v(2); @@ -930,7 +930,7 @@ void tst_QVector::eraseEmpty() const v.erase(v.begin(), v.end()); QCOMPARE(v.size(), 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v; @@ -969,7 +969,7 @@ void tst_QVector::eraseEmptyReserved() const v.erase(v.begin(), v.end()); QCOMPARE(v.size(), 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v; @@ -1085,7 +1085,7 @@ void tst_QVector::erase(bool shared) const if (shared) QCOMPARE(SimpleValue::vector(12), *svc.copy); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v = SimpleValue::vector(10); @@ -1172,7 +1172,7 @@ template void tst_QVector::eraseReserved() const v.erase(v.begin() + 1, v.end() - 1); QCOMPARE(v.size(), 2); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v(10); @@ -1907,7 +1907,7 @@ void tst_QVector::resizePOD_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, 5); @@ -1982,7 +1982,7 @@ void tst_QVector::resizeComplexMovable_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, 'Q'); @@ -2061,7 +2061,7 @@ void tst_QVector::resizeComplex_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, '0'); @@ -2500,7 +2500,7 @@ void tst_QVector::initializeListCustom() void tst_QVector::const_shared_null() { QVector v2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector v1; v1.setSharable(false); @@ -2511,7 +2511,7 @@ void tst_QVector::const_shared_null() QVERIFY(!v2.isDetached()); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section template void tst_QVector::setSharable_data() const -- cgit v1.2.3 From 194a56ea79a4aa11a01dda0491427bb5ba4b37fd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Dec 2015 17:44:34 -0800 Subject: QTest: Fix printing of values of Q_ENUMs QMetaEnum::key(n) returns the n-th key, which is not necessarily the one of value n. For the key of value n, we want QMetaEnum::valueToKey(n). Change-Id: Ic90fe6b1cbe84978a02fffff141bf4a06074917a Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp | 5 +++-- tests/auto/testlib/selftests/expected_cmptest.lightxml | 4 ++-- tests/auto/testlib/selftests/expected_cmptest.txt | 4 ++-- tests/auto/testlib/selftests/expected_cmptest.xml | 4 ++-- tests/auto/testlib/selftests/expected_cmptest.xunitxml | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 6446fec510..09a90508d3 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -156,8 +156,9 @@ void tst_Cmptest::compare_unregistered_enums() void tst_Cmptest::compare_registered_enums() { - QCOMPARE(Qt::ArrowCursor, Qt::ArrowCursor); - QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor); + // use an enum that doesn't start at 0 + QCOMPARE(Qt::Monday, Qt::Monday); + QCOMPARE(Qt::Monday, Qt::Sunday); } static bool boolfunc() { return true; } diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 36929cec6b..8f02e2e1ad 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -16,8 +16,8 @@ + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday]]> diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index 70c54704f9..9205658509 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -4,8 +4,8 @@ PASS : tst_Cmptest::initTestCase() FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same Loc: [tst_cmptest.cpp(154)] FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same - Actual (Qt::ArrowCursor): ArrowCursor - Expected (Qt::BusyCursor) : BusyCursor + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday Loc: [tst_cmptest.cpp(160)] PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_pointerfuncs() diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index 9437e8e4b7..55a9706227 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -18,8 +18,8 @@ + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday]]> diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index fa970d4172..c26f723cfc 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -11,8 +11,8 @@ + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday" result="fail"/> -- cgit v1.2.3 From 558718ff4406638410364db7c1310cb38963d6df Mon Sep 17 00:00:00 2001 From: Vyacheslav Grigoryev Date: Fri, 6 May 2016 01:29:27 +0300 Subject: QTableView: Fix selection for reordered or hidden rows/columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old code sometimes made incorrect selections when rows or columns were hidden or moved. It used logical top left and bottom right indexes to create a selection rectangle. However on moved or hidden cells a wrong rectangle was made. This fix calculates a simple rectangle without hidden cells and makes use of the row/column select functionality provided by the selection model, to make the right selection. [ChangeLog][QtWidgets][QTableView] Fixed a selection bug when rows or columns were hidden (QTBUG-50171) Task-number: QTBUG-50171 Change-Id: Id186012af26da7b2051ff5eb1c13e6b7494cca77 Reviewed-by: Thorbjørn Lund Martsum --- .../itemviews/qtableview/tst_qtableview.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index e5abd6bc46..2bb3f6a136 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -203,6 +203,7 @@ private slots: void taskQTBUG_8777_scrollToSpans(); void taskQTBUG_10169_sizeHintForRow(); void taskQTBUG_30653_doItemsLayout(); + void taskQTBUG_50171_selectRowAfterSwapColumns(); #ifndef QT_NO_WHEELEVENT void mouseWheel_data(); @@ -4476,5 +4477,40 @@ void tst_QTableView::taskQTBUG_30653_doItemsLayout() QCOMPARE(scrollToBottomOffset, doItemsLayoutOffset); } +void tst_QTableView::taskQTBUG_50171_selectRowAfterSwapColumns() +{ + { + QtTestTableView tableView; + QtTestTableModel model(2, 3); + tableView.setModel(&model); + + tableView.horizontalHeader()->swapSections(1, 2); + tableView.horizontalHeader()->hideSection(0); + tableView.selectRow(1); + + QItemSelectionModel* tableSelectionModel = tableView.selectionModel(); + QCOMPARE(tableSelectionModel->isRowSelected(1, QModelIndex()), true); + QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 0)), false); + QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 1)), false); + QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 2)), false); + } + + { + QtTestTableView tableView; + QtTestTableModel model(3, 2); + tableView.setModel(&model); + + tableView.verticalHeader()->swapSections(1, 2); + tableView.verticalHeader()->hideSection(0); + tableView.selectColumn(1); + + QItemSelectionModel* sModel = tableView.selectionModel(); + QCOMPARE(sModel->isColumnSelected(1, QModelIndex()), true); + QCOMPARE(sModel->isSelected(tableView.model()->index(0, 0)), false); + QCOMPARE(sModel->isSelected(tableView.model()->index(1, 0)), false); + QCOMPARE(sModel->isSelected(tableView.model()->index(2, 0)), false); + } +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" -- cgit v1.2.3 From 8de2986a42ff452d2ca7f28d23ce1156be326b62 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 6 May 2016 23:41:14 -0700 Subject: tst_QDBusMarshall: make sure we compile on linked, old dbus If we're linking to libdbus-1, qdbus_symbols_p.h #includes dbus/dbus.h, which may be old and not #define the Unix FD macros. tst_QDBusMarshall had the definition for one of the macros but not the other, so add the missing second one. Change-Id: Id69569111e7d4e619e22ffff144c35edcd6f348b Reviewed-by: Frederik Gladhorn --- tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 57fd5084be..b628738fe3 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -41,6 +41,11 @@ #include #include +#ifndef DBUS_TYPE_UNIX_FD +# define DBUS_TYPE_UNIX_FD int('h') +# define DBUS_TYPE_UNIX_FD_AS_STRING "h" +#endif + static const char serviceName[] = "org.qtproject.autotests.qpong"; static const char objectPath[] = "/org/qtproject/qpong"; static const char *interfaceName = serviceName; @@ -1088,9 +1093,6 @@ static bool canSendUnixFd(DBusConnection *connection) can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); #endif -#ifndef DBUS_TYPE_UNIX_FD -# define DBUS_TYPE_UNIX_FD int('h') -#endif return can_send_type && can_send_type(connection, DBUS_TYPE_UNIX_FD); } -- cgit v1.2.3 From fe23db053a5b3f2097b332ad3269cd0eb5a55168 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 18 Mar 2016 20:29:51 -0700 Subject: Add an autotest for the QtDBus message spy hook There's exactly one application that needs this functionality (kded/ kiod), but we should test it too. Change-Id: Icaa7fb2a490246bda156ffff143d210c6f5f207f Reviewed-by: David Faure --- tests/auto/dbus/dbus.pro | 1 + .../dbus/qdbusconnection/tst_qdbusconnection.cpp | 139 ++++++++++++++++++++- .../dbus/qdbusconnection/tst_qdbusconnection.h | 9 +- .../qdbusconnection_spyhook.pro | 7 ++ .../tst_qdbusconnection_spyhook.cpp | 57 +++++++++ 5 files changed, 211 insertions(+), 2 deletions(-) create mode 100644 tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro create mode 100644 tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp (limited to 'tests/auto') diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro index 67cbc4bfef..c5cddee5f5 100644 --- a/tests/auto/dbus/dbus.pro +++ b/tests/auto/dbus/dbus.pro @@ -11,6 +11,7 @@ SUBDIRS+=\ qdbusconnection_no_app \ qdbusconnection_no_bus \ qdbusconnection_no_libdbus \ + qdbusconnection_spyhook \ qdbuscontext \ qdbusinterface \ qdbuslocalcalls \ diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index f378091c58..9b16cf74a5 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2015 Intel Corporation. +** Copyright (C) 2016 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -55,6 +55,31 @@ void MyObjectWithoutInterface::method(const QDBusMessage &msg) //qDebug() << msg; } +int tst_QDBusConnection::hookCallCount; +tst_QDBusConnection::tst_QDBusConnection() +{ +#ifdef HAS_HOOKSETUPFUNCTION +# define QCOMPARE_HOOKCOUNT(n) QCOMPARE(hookCallCount, n); hookCallCount = 0 +# define QVERIFY_HOOKCALLED() QCOMPARE(hookCallCount, 1); hookCallCount = 0 + hookSetupFunction(); +#else +# define QCOMPARE_HOOKCOUNT(n) qt_noop() +# define QVERIFY_HOOKCALLED() qt_noop() +#endif +} + +// called before each testcase +void tst_QDBusConnection::init() +{ + hookCallCount = 0; +} + +void tst_QDBusConnection::cleanup() +{ + QVERIFY2(!hookCallCount, "Unchecked call"); +} + + void tst_QDBusConnection::noConnection() { QDBusConnection con = QDBusConnection::connectToBus("unix:path=/dev/null", "testconnection"); @@ -359,9 +384,11 @@ void tst_QDBusConnection::registerObject() QCOMPARE(con.objectRegisteredAt(path), static_cast(&obj)); QVERIFY(callMethod(con, path)); QCOMPARE(obj.path, path); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, path)); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::registerObjectWithInterface_data() @@ -393,9 +420,11 @@ void tst_QDBusConnection::registerObjectWithInterface() QVERIFY(callMethod(con, path, interface)); QCOMPARE(obj.path, path); QCOMPARE(obj.interface, interface); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, path, interface)); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::registerObjectPeer_data() @@ -432,6 +461,7 @@ void tst_QDBusConnection::registerObjectPeer() MyObject obj; QVERIFY(callMethodPeer(con, path)); QCOMPARE(obj.path, path); + QVERIFY_HOOKCALLED(); } QDBusConnection::connectToPeer(server.address(), "afterFoo"); @@ -441,6 +471,7 @@ void tst_QDBusConnection::registerObjectPeer() QDBusConnection con("foo"); QVERIFY(con.isConnected()); QVERIFY(callMethodPeer(con, path)); + QVERIFY_HOOKCALLED(); } server.unregisterObject(); @@ -449,6 +480,7 @@ void tst_QDBusConnection::registerObjectPeer() QDBusConnection con("foo"); QVERIFY(con.isConnected()); QVERIFY(!callMethodPeer(con, path)); + QVERIFY_HOOKCALLED(); } server.registerObject(); @@ -457,6 +489,7 @@ void tst_QDBusConnection::registerObjectPeer() QDBusConnection con("foo"); QVERIFY(con.isConnected()); QVERIFY(callMethodPeer(con, path)); + QVERIFY_HOOKCALLED(); } QDBusConnection::disconnectFromPeer("foo"); @@ -478,10 +511,15 @@ void tst_QDBusConnection::registerObject2() // make sure nothing is using our paths: QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p2")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { // register one object at root: @@ -489,76 +527,99 @@ void tst_QDBusConnection::registerObject2() QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/")); QCOMPARE(obj.path, QString("/")); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); { // register one at an element: MyObject obj; QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); // re-register it somewhere else QVERIFY(con.registerObject("/p2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p2")); QCOMPARE(obj.path, QString("/p2")); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p2")); + QVERIFY_HOOKCALLED(); { // register at a deep path MyObject obj; QVERIFY(con.registerObject("/p1/q/r", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/q/r")); QCOMPARE(obj.path, QString("/p1/q/r")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethod(con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { MyObject obj; QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // try unregistering con.unregisterObject("/p1/q2"); QVERIFY(!callMethod(con, "/p1/q2")); + QVERIFY_HOOKCALLED(); // register it again QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // now try removing things around it: con.unregisterObject("/p2"); QVERIFY(callMethod(con, "/p1/q2")); // unrelated object shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering just the parent shouldn't affect it + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q2/r"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering non-existing child shouldn't affect it either + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering sibling (before) shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/r"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering sibling (after) shouldn't affect + QVERIFY_HOOKCALLED(); // now remove it: con.unregisterObject("/p1", QDBusConnection::UnregisterTree); QVERIFY(!callMethod(con, "/p1/q2")); // we removed the full tree + QVERIFY_HOOKCALLED(); } } @@ -577,10 +638,15 @@ void tst_QDBusConnection::registerObjectPeer2() // make sure nothing is using our paths: QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p2")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { // register one object at root: @@ -588,76 +654,101 @@ void tst_QDBusConnection::registerObjectPeer2() QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/")); QCOMPARE(obj.path, QString("/")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); { // register one at an element: MyObject obj; QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); // re-register it somewhere else QVERIFY(con.registerObject("/p2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p2")); QCOMPARE(obj.path, QString("/p2")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p2")); + QVERIFY_HOOKCALLED(); { // register at a deep path MyObject obj; QVERIFY(con.registerObject("/p1/q/r", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/q/r")); QCOMPARE(obj.path, QString("/p1/q/r")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethodPeer(srv_con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { MyObject obj; QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // try unregistering con.unregisterObject("/p1/q2"); QVERIFY(!callMethodPeer(srv_con, "/p1/q2")); + QVERIFY_HOOKCALLED(); // register it again QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // now try removing things around it: con.unregisterObject("/p2"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unrelated object shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering just the parent shouldn't affect it + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q2/r"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering non-existing child shouldn't affect it either + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (before) shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/r"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (after) shouldn't affect + QVERIFY_HOOKCALLED(); // now remove it: con.unregisterObject("/p1", QDBusConnection::UnregisterTree); QVERIFY(!callMethodPeer(srv_con, "/p1/q2")); // we removed the full tree + QVERIFY_HOOKCALLED(); } QDBusConnection::disconnectFromPeer("foo"); @@ -669,6 +760,7 @@ void tst_QDBusConnection::registerQObjectChildren() // make sure no one is there QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); { MyObject obj, *a, *b, *c, *cc; @@ -691,32 +783,47 @@ void tst_QDBusConnection::registerQObjectChildren() // make calls QVERIFY(callMethod(con, "/p1")); QCOMPARE(obj.callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/a")); QCOMPARE(a->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/b")); QCOMPARE(b->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/c")); QCOMPARE(c->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/c/cc")); QCOMPARE(cc->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/d")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c/abc")); + QVERIFY_HOOKCALLED(); // pull an object, see if it goes away: delete b; QVERIFY(!callMethod(con, "/p1/b")); + QVERIFY_HOOKCALLED(); delete c; QVERIFY(!callMethod(con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); } QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/a")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/b")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::registerQObjectChildrenPeer() @@ -734,6 +841,7 @@ void tst_QDBusConnection::registerQObjectChildrenPeer() QDBusConnection srv_con = server.connection(); QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); { MyObject obj, *a, *b, *c, *cc; @@ -756,32 +864,47 @@ void tst_QDBusConnection::registerQObjectChildrenPeer() // make calls QVERIFY(callMethodPeer(srv_con, "/p1")); QCOMPARE(obj.callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/a")); QCOMPARE(a->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/b")); QCOMPARE(b->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/c")); QCOMPARE(c->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/c/cc")); QCOMPARE(cc->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/d")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c/abc")); + QVERIFY_HOOKCALLED(); // pull an object, see if it goes away: delete b; QVERIFY(!callMethodPeer(srv_con, "/p1/b")); + QVERIFY_HOOKCALLED(); delete c; QVERIFY(!callMethodPeer(srv_con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); } QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/a")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/b")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); QDBusConnection::disconnectFromPeer("foo"); } @@ -827,20 +950,25 @@ void tst_QDBusConnection::callSelf() QVERIFY(connection.registerService(serviceName())); QDBusInterface interface(serviceName(), "/test"); QVERIFY(interface.isValid()); + QVERIFY_HOOKCALLED(); interface.call(QDBus::Block, "test0"); QCOMPARE(testObject.func, QString("test0")); + QVERIFY_HOOKCALLED(); interface.call(QDBus::Block, "test1", 42); QCOMPARE(testObject.func, QString("test1 42")); + QVERIFY_HOOKCALLED(); QDBusMessage reply = interface.call(QDBus::Block, "test2"); QCOMPARE(testObject.func, QString("test2")); QCOMPARE(reply.arguments().value(0).toInt(), 43); + QVERIFY_HOOKCALLED(); QDBusMessage msg = QDBusMessage::createMethodCall(serviceName(), "/test", QString(), "test3"); msg << 44; reply = connection.call(msg); QCOMPARE(reply.arguments().value(0).toInt(), 45); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::callSelfByAnotherName_data() @@ -908,12 +1036,14 @@ void tst_QDBusConnection::callSelfByAnotherName() QDBusMessage reply = con.call(msg, QDBus::Block, 1000); QVERIFY(reply.type() == QDBusMessage::ReplyMessage); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::multipleInterfacesInQObject() { QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); MyObject obj; con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots); @@ -924,6 +1054,7 @@ void tst_QDBusConnection::multipleInterfacesInQObject() QDBusMessage reply = con.call(msg, QDBus::Block); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); QVERIFY(reply.arguments().count() == 0); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::slotsWithLessParameters() @@ -981,6 +1112,7 @@ void tst_QDBusConnection::nestedCallWithCallback() QTestEventLoop::instance().enterLoop(15); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(signalsReceived, 1); + QCOMPARE_HOOKCOUNT(2); } void tst_QDBusConnection::serviceRegistrationRaceCondition() @@ -1145,6 +1277,7 @@ void tst_QDBusConnection::callVirtualObject() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY_HOOKCALLED(); QCOMPARE(obj.callCount, 1); QCOMPARE(obj.lastMessage.service(), con2.baseService()); @@ -1162,6 +1295,7 @@ void tst_QDBusConnection::callVirtualObject() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY_HOOKCALLED(); QCOMPARE(obj.callCount, 2); QCOMPARE(obj.lastMessage.service(), con2.baseService()); @@ -1179,6 +1313,7 @@ void tst_QDBusConnection::callVirtualObject() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY_HOOKCALLED(); QTest::qWait(100); QVERIFY(errorReply.isError()); QCOMPARE(errorReply.reply().errorName(), QString("org.freedesktop.DBus.Error.UnknownObject")); @@ -1207,6 +1342,7 @@ void tst_QDBusConnection::callVirtualObjectLocal() QCOMPARE(obj.lastMessage.interface(), QString()); QCOMPARE(obj.lastMessage.path(), path); QCOMPARE(obj.replyArguments, reply.arguments()); + QVERIFY_HOOKCALLED(); obj.replyArguments << QString("alien abduction"); QDBusMessage subPathMessage = QDBusMessage::createMethodCall(con.baseService(), childPath, QString(), "hello"); @@ -1216,6 +1352,7 @@ void tst_QDBusConnection::callVirtualObjectLocal() QCOMPARE(obj.lastMessage.interface(), QString()); QCOMPARE(obj.lastMessage.path(), childPath); QCOMPARE(obj.replyArguments, subPathReply.arguments()); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::pendingCallWhenDisconnected() diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h index 720e484cc2..b47daa118b 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2015 Intel Corporation. +** Copyright (C) 2016 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -79,11 +79,18 @@ class tst_QDBusConnection: public QObject Q_OBJECT int signalsReceived; +public: + static int hookCallCount; + tst_QDBusConnection(); + public slots: void oneSlot() { ++signalsReceived; } void exitLoop() { ++signalsReceived; QTestEventLoop::instance().exitLoop(); } void secondCallWithCallback(); + void init(); + void cleanup(); + private slots: void noConnection(); void connectToBus(); diff --git a/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro b/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro new file mode 100644 index 0000000000..020d30380d --- /dev/null +++ b/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qdbusconnection_spyhook +QT = core dbus testlib +SOURCES += tst_qdbusconnection_spyhook.cpp +HEADERS += ../qdbusconnection/tst_qdbusconnection.h +DEFINES += SRCDIR=\\\"$$PWD/\\\" tst_QDBusConnection=tst_QDBusConnection_SpyHook +include(../dbus-testcase.pri) diff --git a/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp new file mode 100644 index 0000000000..fa1c19920a --- /dev/null +++ b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Intel Corporation. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#define HAS_HOOKSETUPFUNCTION 1 +static void hookSetupFunction(); + +// Ugly hack, look away +#include "../qdbusconnection/tst_qdbusconnection.cpp" + +QT_BEGIN_NAMESPACE +extern Q_DBUS_EXPORT void qDBusAddSpyHook(void (*Hook)(const QDBusMessage&)); +QT_END_NAMESPACE + +static void hookFunction(const QDBusMessage &) +{ +// qDebug() << "hook called"; + ++tst_QDBusConnection::hookCallCount; +} + +static void hookSetupFunction() +{ + QT_PREPEND_NAMESPACE(qDBusAddSpyHook)(hookFunction); +} + +QTEST_MAIN(tst_QDBusConnection_SpyHook) -- cgit v1.2.3 From b168c6c8248662da31dbaaf2afb8e771a9ecdc85 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 22:21:53 -0800 Subject: QStorageInfo: fix matching of mountpoints to sibling directories The path "/usrfoo" starts with "/usr", so if you tried to get QStorageInfo("/usrfoo") when "/usr" is a mount point, you'd get the wrong filesystem. [ChangeLog][QtCore][QStorageInfo] Fixed a bug that caused QStorageInfo to report information for the wrong filesystem if there is a mounted filesystem at a path that is a prefix of the requested path (e.g., it would report "/usr" filesystem for "/usrfoo"). Task-number: QTBUG-49498 Change-Id: I3e15a26e0e424169ac2bffff1417b7a27cd0132d Reviewed-by: Jake Petroules --- tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index efbcdc78e0..1afcf05135 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -162,6 +162,7 @@ void tst_QStorageInfo::tempFile() #endif qint64 free = storage1.bytesFree(); + QVERIFY(free != -1); file.write(QByteArray(1024*1024, '1')); file.flush(); @@ -185,6 +186,7 @@ void tst_QStorageInfo::caching() qint64 free = storage1.bytesFree(); QStorageInfo storage2(storage1); QVERIFY(free == storage2.bytesFree()); + QVERIFY(free != -1); file.write(QByteArray(1024*1024, '\0')); file.flush(); -- cgit v1.2.3 From 9f6f06c31906c5261e578d742c48f39c0d867f37 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 May 2016 10:32:37 +0200 Subject: tst_QMdiArea::subWindowActivated2(): Allow for several activated events. On some X11 window managers, 2 events are received when hiding/reshowing and activating the window, which became apparent after 91f536dd71cd154675264c27273020f4de310ec2. Change-Id: I66fdc4f69d87ac898b18d5dfddc957617bb8f916 Reviewed-by: Simon Hausmann --- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 57be110c15..f832ebfee0 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -499,7 +499,7 @@ void tst_QMdiArea::subWindowActivated2() mdiArea.show(); mdiArea.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); - QTRY_COMPARE(spy.count(), 1); + QTRY_VERIFY(!spy.isEmpty()); // Normally 1, but 2 events might be received on some X11 window managers QVERIFY(mdiArea.currentSubWindow()); QTRY_COMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); -- cgit v1.2.3 From 50723bf3d0d56ba58dbf2343ea890b2d874239e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 4 Oct 2015 01:00:09 -0400 Subject: Make sure the QDBusVirtualObject virtuals are called in the right thread Change-Id: I42e7ef1a481840699a8dffff1409e30f191e822f Reviewed-by: Frederik Gladhorn --- tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index 93d3eacb08..91cae3272a 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -407,6 +407,7 @@ public: VirtualObject() :success(true) {} QString introspect(const QString &path) const { + Q_ASSERT(QThread::currentThread() == thread()); if (path == "/some/path/superNode") return "zitroneneis"; if (path == "/some/path/superNode/foo") @@ -417,6 +418,7 @@ public: } bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) { + Q_ASSERT(QThread::currentThread() == thread()); ++callCount; lastMessage = message; -- cgit v1.2.3 From 7f5e8a5e3475c7f400a47ca821e78feb2e590222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 3 May 2016 11:51:41 +0200 Subject: OS X: Remove unified toolbar test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Qt 5 unified toolbar implementation does not move the toolbar to the “non-client” area. This test is no longer relevant. Change-Id: Ia32de2260f8ef400a0dc5acf3e5e3ff59083657a Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 2 -- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 41 +---------------------- 2 files changed, 1 insertion(+), 42 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 773f4205af..8fc882112e 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -40,8 +40,6 @@ osx osx [render_systemClip] osx -[childAt_unifiedToolBar] -osx [showMinimizedKeepsFocus] osx-10.10 [moveWindowInShowEvent:1] diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 20bdf00292..7e72007ac0 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -435,7 +435,6 @@ private slots: void movedAndResizedAttributes(); void childAt(); #ifdef Q_OS_OSX - void childAt_unifiedToolBar(); void taskQTBUG_11373(); #endif void taskQTBUG_17333_ResizeInfiniteRecursion(); @@ -9577,49 +9576,10 @@ void tst_QWidget::childAt() } #ifdef Q_OS_OSX -void tst_QWidget::childAt_unifiedToolBar() -{ - QLabel *label = new QLabel(QLatin1String("foo")); - QToolBar *toolBar = new QToolBar; - toolBar->addWidget(new QLabel("dummy")); - toolBar->addWidget(label); - - QMainWindow mainWindow; - mainWindow.addToolBar(toolBar); - mainWindow.show(); - - // Calculate the top-left corner of the tool bar and the label (in mainWindow's coordinates). - QPoint labelTopLeft = label->mapTo(&mainWindow, QPoint()); - QPoint toolBarTopLeft = toolBar->mapTo(&mainWindow, QPoint()); - - QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast(toolBar)); - QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast(label)); - - // Enable unified tool bars. - mainWindow.setUnifiedTitleAndToolBarOnMac(true); - QTest::qWait(50); - - // The tool bar is now in the "non-client" area of QMainWindow, i.e. - // outside the mainWindow's rect(), and since mapTo et al. doesn't work - // in that case (see commit 35667fd45ada49269a5987c235fdedfc43e92bb8), - // we use mapToGlobal/mapFromGlobal to re-calculate the corners. - QPoint oldToolBarTopLeft = toolBarTopLeft; - toolBarTopLeft = mainWindow.mapFromGlobal(toolBar->mapToGlobal(QPoint())); - QVERIFY2(toolBarTopLeft != oldToolBarTopLeft, - msgComparisonFailed(toolBarTopLeft, "!=", oldToolBarTopLeft)); - QVERIFY2(toolBarTopLeft.y() < 0, - msgComparisonFailed(toolBarTopLeft.y(), "<", 0)); - labelTopLeft = mainWindow.mapFromGlobal(label->mapToGlobal(QPoint())); - - QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast(toolBar)); - QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast(label)); -} void tst_QWidget::taskQTBUG_11373() { -#ifdef Q_OS_OSX QSKIP("QTBUG-52974"); -#endif QScopedPointer myWindow(new QMainWindow); QWidget * center = new QWidget(); @@ -9636,6 +9596,7 @@ void tst_QWidget::taskQTBUG_11373() // The drawer should still not be visible, since we haven't shown it. QCOMPARE(drawer->isVisible(), false); } + #endif void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion() -- cgit v1.2.3 From 95b8dfdb6fa834d93646352cf3715d0c71fe29da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 10 May 2016 12:18:24 +0200 Subject: tst_qwidget: remove sheetOpacity test Sheets are no longer transparent on newer OS X versions. Change-Id: Iaaed5aea9c9b130a5d991acd36717b76c3927cfb Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 7e72007ac0..183feb4020 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -269,7 +269,6 @@ private slots: void widgetAt(); #ifdef Q_OS_OSX - void sheetOpacity(); void setMask(); #endif void optimizedResizeMove(); @@ -3545,18 +3544,6 @@ void tst_QWidget::testDeletionInEventHandlers() } #ifdef Q_OS_OSX -void tst_QWidget::sheetOpacity() -{ - QSKIP("QTBUG-52974: this test will most probably be deleted - to be investigated."); - QWidget tmpWindow; - QWidget sheet(&tmpWindow, Qt::Sheet); - tmpWindow.show(); - sheet.show(); - QCOMPARE(int(sheet.windowOpacity() * 255), 242); // 95% - sheet.setParent(0, Qt::Dialog); - QCOMPARE(int(sheet.windowOpacity() * 255), 255); -} - class MaskedPainter : public QWidget { public: -- cgit v1.2.3 From 7e539002eec2229df21d405acd76dc4f1e1c0ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 3 May 2016 09:25:11 +0200 Subject: Enable movedAndResizedAttributes test. The test passes on OS X now. Task-number: QTBUG-8941 Change-Id: I7b57dc30ede7c1ed0bcb8bacb458ea56f222d987 Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 183feb4020..10d32472be 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -9455,10 +9455,6 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() void tst_QWidget::movedAndResizedAttributes() { -#if defined (Q_OS_OSX) - QEXPECT_FAIL("", "FixMe, QTBUG-8941 and QTBUG-8977", Abort); - QVERIFY(false); -#else // Use Qt::Tool as fully decorated windows have a minimum width of 160 on QWidget w(0, Qt::Tool); w.show(); @@ -9504,7 +9500,6 @@ void tst_QWidget::movedAndResizedAttributes() w.resize(100, 100); QVERIFY(w.testAttribute(Qt::WA_Moved)); QVERIFY(w.testAttribute(Qt::WA_Resized)); -#endif } void tst_QWidget::childAt() -- cgit v1.2.3 From acf43c17b647cdbfc3186bb8bf7e183df67a090b Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 1 Mar 2016 15:44:06 +0300 Subject: QFileSystemModel: create nodes with correct QFileInfos Create parent nodes with the corresponding paths, not with the absolute path of the child node. Otherwise we will get incorrect QFileInfo at least in the following case: QFileSystemModel model; model.setRootPath("/usr/bin"); QModelIndex idx = model.setRootPath("/usr"); qDebug() << model.fileInfo(idx).absoluteFilePath(); Without the fix it prints "/usr/bin". It's a regression triggered by 61cefb2f7a7cb16dfa2732e26d2319017039ef62 (De-inline QFileSystemModel::fileInfo() and implement it efficiently). Change-Id: I3b4e5f5b256711e27ad50824eaa8492dbc096808 Task-number: QTBUG-51586 Reviewed-by: Lars Knoll --- .../widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 16 ++++++++++++++++ .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 42e2bd09a5..05f42cf685 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -569,6 +569,22 @@ void tst_QFiledialog::completer() if (expectedFile.startsWith(input, caseSensitivity)) ++expected; } + // The temporary dir may create a node in QFileSystemModel + // which will bypass filters. If the path to the temporary + // dir contains an element which should be a subdirectory + // of x dir, but which is not listed, then take it into + // accont. + if (!tempDir.isNull()) { + QString xPath = x.absolutePath(); + if (!xPath.endsWith(QLatin1Char('/'))) + xPath.append(QLatin1Char('/')); + QString tmpPath = tempDir->path(); + if (tmpPath.startsWith(xPath)) { + QString bypassedDirName = tmpPath.mid(xPath.size()).section(QLatin1Char('/'), 0, 0); + if (!expectedFiles.contains(bypassedDirName)) + ++expected; + } + } } QTRY_COMPARE(cModel->rowCount(), expected); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 19b1d0e7c8..b27943f071 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -126,6 +126,8 @@ private slots: void doNotUnwatchOnFailedRmdir(); void specialFiles(); + void fileInfo(); + protected: bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList()); @@ -1146,6 +1148,25 @@ void tst_QFileSystemModel::specialFiles() QTRY_VERIFY(!fileListUnderIndex(&model, rootIndex).contains(testFileName)); } +void tst_QFileSystemModel::fileInfo() +{ + QFileSystemModel model; + QModelIndex idx; + + QVERIFY(model.fileInfo(idx).filePath().isEmpty()); + + const QString dirPath = flatDirTestPath; + QDir dir(dirPath); + const QString subdir = QStringLiteral("subdir"); + QVERIFY(dir.mkdir(subdir)); + const QString subdirPath = dir.absoluteFilePath(subdir); + + idx = model.setRootPath(subdirPath); + QCOMPARE(model.fileInfo(idx), QFileInfo(subdirPath)); + idx = model.setRootPath(dirPath); + QCOMPARE(model.fileInfo(idx), QFileInfo(dirPath)); +} + QTEST_MAIN(tst_QFileSystemModel) #include "tst_qfilesystemmodel.moc" -- cgit v1.2.3 From 78eeb6b066113c678fe15531ca10e70964f6b9a4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 11 May 2016 15:10:50 +0300 Subject: QFont::exactMatch() should return false for aliases This is a partial revert of 992f233c in Qt 4 repo. The rest of the change cannot be reverted, since it added public API, but that API might be useful anyway. The patch was wrong, basically. QFont::exactMatch() should not claim that you can get an exact match for a typeface alias. It also introduced some weird inconsistencies: For instance, if the first font the alias resolved to in FontConfig did not exist, then exactMatch() would return false, even if it then resolved to the next one which existed. This caused a test failure on OpenSuse, where the preferred font for "sans" is Arial, which doesn't exist, so Roboto will be used instead. [ChangeLog][QtGui][Important Behavior Changes] QFont::exactMatch() now returns false when the provided typeface is an alias. Task-number: QTBUG-46054 Change-Id: I7532d2879b492544620aa0d1d87dd493a4923af9 Reviewed-by: Simon Hausmann --- tests/auto/gui/text/qfont/tst_qfont.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 57530653c1..da1e4aa225 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -115,13 +115,10 @@ void tst_QFont::exactMatch() QSKIP("Exact matching on windows misses a lot because of the sample chars"); #endif - - if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) { - QVERIFY(QFont("sans").exactMatch()); - QVERIFY(QFont("sans-serif").exactMatch()); - QVERIFY(QFont("serif").exactMatch()); - QVERIFY(QFont("monospace").exactMatch()); - } + QVERIFY(!QFont("sans").exactMatch()); + QVERIFY(!QFont("sans-serif").exactMatch()); + QVERIFY(!QFont("serif").exactMatch()); + QVERIFY(!QFont("monospace").exactMatch()); QSKIP("This test is bogus on Unix with support for font aliases in fontconfig"); -- cgit v1.2.3 From d70205cd2ba9242e477856df853dcd7d7770425b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 11 May 2016 15:19:09 +0300 Subject: Remove dead code from tst_QFont::exactMatch() All this code was skipped on all platforms, so keeping it is just confusing. Change-Id: I405d2e791b22a2494fe5ccac6e3bf08905dc4e5a Reviewed-by: Simon Hausmann --- tests/auto/gui/text/qfont/tst_qfont.cpp | 145 -------------------------------- 1 file changed, 145 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index da1e4aa225..d8a6afb804 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -110,155 +110,10 @@ void tst_QFont::exactMatch() // Check if a non-existing font hasn't an exact match font = QFont( "BogusFont", 33 ); QVERIFY( !font.exactMatch() ); - -#ifdef Q_OS_WIN - QSKIP("Exact matching on windows misses a lot because of the sample chars"); -#endif - QVERIFY(!QFont("sans").exactMatch()); QVERIFY(!QFont("sans-serif").exactMatch()); QVERIFY(!QFont("serif").exactMatch()); QVERIFY(!QFont("monospace").exactMatch()); - - QSKIP("This test is bogus on Unix with support for font aliases in fontconfig"); - - QFontDatabase fdb; - - QList systems = fdb.writingSystems(); - for (int system = 0; system < systems.count(); ++system) { - QStringList families = fdb.families(systems[system]); - if (families.isEmpty()) - return; - - QStringList::ConstIterator f_it, f_end = families.end(); - for (f_it = families.begin(); f_it != f_end; ++f_it) { - const QString &family = *f_it; - if (family.contains('[')) - continue; - - QStringList styles = fdb.styles(family); - QVERIFY(!styles.isEmpty()); - QStringList::ConstIterator s_it, s_end = styles.end(); - for (s_it = styles.begin(); s_it != s_end; ++s_it) { - const QString &style = *s_it; - - if (fdb.isSmoothlyScalable(family, style)) { - // smoothly scalable font... don't need to load every pointsize - font = fdb.font(family, style, 12); - QFontInfo fontinfo(font); - - if (! fontinfo.exactMatch()) { - // Unfortunately, this can fail, since - // QFontDatabase does not fill in all font - // properties. Check to make sure that the - // test didn't fail for obvious reasons - - if (fontinfo.family().isEmpty() - && fontinfo.pointSize() == 0) { - // this is a box rendering engine... this can happen from - // time to time, especially on X11 with iso10646-1 or - // unknown font encodings - continue; - } - -#ifdef Q_OS_WIN - if (font.family().startsWith("MS ") || fontinfo.family().startsWith("MS ")) { - /* qDebug("Family matching skipped for MS-Alias font: %s, fontinfo: %s", - font.family().latin1(), fontinfo.family().latin1()); - */ - } else -#endif - { - if (!(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty())) { - qDebug("Test about to fail for font: %s, fontinfo: %s", - font.family().toLatin1().constData(), - fontinfo.family().toLatin1().constData()); - } - QVERIFY(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty()); - } - if (font.pointSize() != -1) { - QCOMPARE(font.pointSize(), fontinfo.pointSize()); - } else { - QCOMPARE(font.pixelSize(), fontinfo.pixelSize()); - } - QCOMPARE(font.italic(), fontinfo.italic()); - if (font.weight() != fontinfo.weight()) { - qDebug("font is %s", font.toString().toLatin1().constData()); - } - QCOMPARE(font.weight(), fontinfo.weight()); - } else { - font.setFixedPitch(!fontinfo.fixedPitch()); - QFontInfo fontinfo1(font); - QVERIFY( !fontinfo1.exactMatch() ); - - font.setFixedPitch(fontinfo.fixedPitch()); - QFontInfo fontinfo2(font); - QVERIFY( fontinfo2.exactMatch() ); - } - } -#if 0 - // ############## can only work if we have float point sizes in QFD - else { - QList sizes = fdb.pointSizes(family, style); - QVERIFY(!sizes.isEmpty()); - QList::ConstIterator z_it, z_end = sizes.end(); - for (z_it = sizes.begin(); z_it != z_end; ++z_it) { - const int size = *z_it; - - // Initialize the font, and check if it is an exact match - font = fdb.font(family, style, size); - QFontInfo fontinfo(font, (QFont::Script) script); - - if (! fontinfo.exactMatch()) { - // Unfortunately, this can fail, since - // QFontDatabase does not fill in all font - // properties. Check to make sure that the - // test didn't fail for obvious reasons - - if (fontinfo.family().isEmpty() - && fontinfo.pointSize() == 0) { - // this is a box rendering engine... this can happen from - // time to time, especially on X11 with iso10646-1 or - // unknown font encodings - continue; - } - - // no need to skip MS-fonts here it seems - if (!(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty())) { - qDebug("Test about to fail for font: %s, fontinfo: %s", - font.family().latin1(), fontinfo.family().latin1()); - } - QVERIFY(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty()); - if (font.pointSize() != -1) { - QCOMPARE(font.pointSize(), fontinfo.pointSize()); - } else { - QCOMPARE(font.pixelSize(), fontinfo.pixelSize()); - } - QCOMPARE(font.italic(), fontinfo.italic()); - QCOMPARE(font.weight(), fontinfo.weight()); - } else { - font.setFixedPitch(!fontinfo.fixedPitch()); - QFontInfo fontinfo1(font, (QFont::Script) script); - QVERIFY( !fontinfo1.exactMatch() ); - - font.setFixedPitch(fontinfo.fixedPitch()); - QFontInfo fontinfo2(font, (QFont::Script) script); - QVERIFY( fontinfo2.exactMatch() ); - } - } - } -#endif - } - } - } } void tst_QFont::italicOblique() -- cgit v1.2.3 From 2ac3fab45f1388591b3d1b73b8419ba45d63f064 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Thu, 12 May 2016 16:20:47 +0200 Subject: Fixed crash in QAuthenticator::operator== [ChangeLog][QtNetwork][QAuthenticator] Fixed crash when comparing a initialized QAuthenticator with an uninitialized QAuthenticator. Task-number: QTBUG-53338 Change-Id: Ib8b732b9c65c02ee542885e5d6fe9bd1589a6b1a Reviewed-by: Timur Pocheptsov --- .../network/kernel/qauthenticator/tst_qauthenticator.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 026a2a2722..90a6aa5811 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -52,6 +52,8 @@ private Q_SLOTS: void ntlmAuth_data(); void ntlmAuth(); + + void equalityOperators(); }; tst_QAuthenticator::tst_QAuthenticator() @@ -152,6 +154,20 @@ void tst_QAuthenticator::ntlmAuth() QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM ")); } +void tst_QAuthenticator::equalityOperators() +{ + QAuthenticator s1, s2; + QVERIFY(s2 == s1); + QVERIFY(s1 == s2); + QVERIFY(!(s1 != s2)); + QVERIFY(!(s2 != s1)); + s1.setUser("User"); + QVERIFY(!(s2 == s1)); + QVERIFY(!(s1 == s2)); + QVERIFY(s1 != s2); + QVERIFY(s2 != s1); +} + QTEST_MAIN(tst_QAuthenticator); #include "tst_qauthenticator.moc" -- cgit v1.2.3 From 5316befba2b2f63a4c4a4185a09bc6b149d3f842 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 10 May 2016 16:21:08 +0200 Subject: ICO image format: fix regression in writing when size >= 256 In commit c6c9304, the earlier size limit of 128 was raised to the format's defined maximum of 256. But the required special storage of this size in the image structures was not implemented. Hence, attempting to store such big icons would result in invalid image files. Fix the size storing details, and add some autotests of ico format writing since that was practically uncovered. Task-number: QTBUG-53259 Change-Id: I00e17a04e90c32dcf1124ba5adaf53728fb74dc7 Reviewed-by: Friedemann Kleint --- .../image/qicoimageformat/tst_qicoimageformat.cpp | 47 +++++++++++++++++++++ tests/auto/gui/image/qimagewriter/images/App.ico | Bin 0 -> 318 bytes .../gui/image/qimagewriter/tst_qimagewriter.cpp | 3 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/auto/gui/image/qimagewriter/images/App.ico (limited to 'tests/auto') diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp index bff762fd04..6d2ed6d304 100644 --- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp @@ -64,6 +64,8 @@ private slots: void nextImageDelay(); void pngCompression_data(); void pngCompression(); + void write_data(); + void write(); private: QString m_IconPath; @@ -335,6 +337,51 @@ void tst_QIcoImageFormat::pngCompression() QCOMPARE(image.height(), height); } +void tst_QIcoImageFormat::write_data() +{ + QTest::addColumn("inSize"); + QTest::addColumn("outSize"); + + QTest::newRow("64x64") << QSize(64, 64) << QSize(64, 64); + QTest::newRow("128x200") << QSize(128, 200) << QSize(128, 200); + QTest::newRow("256x256") << QSize(256, 256) << QSize(256, 256); + QTest::newRow("400x400") << QSize(400, 400) << QSize(256, 256); +} + +void tst_QIcoImageFormat::write() +{ + QFETCH(QSize, inSize); + QFETCH(QSize, outSize); + + QImage inImg; + { + QImageReader reader(m_IconPath + "/valid/Qt.ico"); + reader.jumpToImage(4); + reader.setScaledSize(inSize); + inImg = reader.read(); + QVERIFY(!inImg.isNull()); + QCOMPARE(inImg.size(), inSize); + } + + QBuffer buf; + { + buf.open(QIODevice::WriteOnly); + QImageWriter writer(&buf, "ico"); + QVERIFY(writer.write(inImg)); + buf.close(); + } + { + buf.open(QIODevice::ReadOnly); + QImageReader reader(&buf); + QVERIFY(reader.canRead()); + QCOMPARE(reader.format(), QByteArray("ico")); + QImage outImg = reader.read(); + QVERIFY(!outImg.isNull()); + QCOMPARE(outImg.size(), outSize); + buf.close(); + } +} + QTEST_MAIN(tst_QIcoImageFormat) #include "tst_qicoimageformat.moc" diff --git a/tests/auto/gui/image/qimagewriter/images/App.ico b/tests/auto/gui/image/qimagewriter/images/App.ico new file mode 100644 index 0000000000..03b80a68f8 Binary files /dev/null and b/tests/auto/gui/image/qimagewriter/images/App.ico differ diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index b3fdd00eb6..0347ef8810 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -199,6 +199,7 @@ void tst_QImageWriter::writeImage_data() QTest::newRow("PBM: ship63") << QString("ship63.pbm") << true << QByteArray("pbm"); QTest::newRow("XBM: gnus") << QString("gnus.xbm") << false << QByteArray("xbm"); QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg"); + QTest::newRow("ICO: App") << QString("App.ico") << true << QByteArray("ico"); } void tst_QImageWriter::writeImage() @@ -260,7 +261,7 @@ void tst_QImageWriter::writeImage2_data() QTest::addColumn("image"); const QStringList formats = QStringList() << "bmp" << "xpm" << "png" - << "ppm"; //<< "jpeg"; + << "ppm" << "ico"; //<< "jpeg"; QImage image0(70, 70, QImage::Format_ARGB32); image0.fill(QColor(Qt::red).rgb()); -- cgit v1.2.3 From ae975859f940f19a24d1224ae6271efbeb687173 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 12 May 2016 18:03:50 +0200 Subject: Revert "tst_qudpsocket - remove insignificant" This reverts commit 11ad50074b57df7559d39a0620a1e1b35d0ac061. Unfortunately, udpsocket strikes back this time on OS X < 10.10 - never seens these test failing before. Since this prevents 5.6->5.7 merge, I have to revert it until the problem investigated/fixed on OS X. Alas :( Change-Id: I52f6512d88c25d2e3071cb845e91faefbd455e27 Reviewed-by: Friedemann Kleint --- tests/auto/network/socket/qudpsocket/BLACKLIST | 12 ------------ tests/auto/network/socket/qudpsocket/test/test.pro | 2 ++ 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST index fb8455e6d3..3e936aebf6 100644 --- a/tests/auto/network/socket/qudpsocket/BLACKLIST +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -6,15 +6,3 @@ osx osx [multicast:same bind, group ipv4 address] osx -[writeDatagramToNonExistingPeer] -windows -[asyncReadDatagram] -windows -[multicastLeaveAfterClose] -osx -[readyRead] -osx -[readyReadForEmptyDatagram] -osx -[asyncReadDatagram] -osx diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index e4812416dc..8ad16c652d 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -22,3 +22,5 @@ wince* { } TARGET = tst_qudpsocket + +CONFIG+=insignificant_test # QTBUG-25367, QTBUG-25368 -- cgit v1.2.3 From 186d391f256705f58b421e0cf20260e352e79603 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 11 May 2016 13:43:16 +0300 Subject: Work around QFont bug in QFontDialog test The QFontDialog test will currently fail for some PCF bitmap fonts because the list of smooth sizes it uses to populate its size list contains unsupported sizes. We work around this by adding QEXPECT_FAIL when we detect that the failure is going to happen. Task-number: QTBUG-46056 Task-number: QTBUG-53299 Change-Id: Ia665cca220f3622405d1a2336e8d587545cccbc6 Reviewed-by: Simon Hausmann --- tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index 796b4b9fdb..9aacd3105e 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -193,11 +193,14 @@ void tst_QFontDialog::task256466_wrongStyle() for (int i = 0; i < familyList->model()->rowCount(); ++i) { QModelIndex currentFamily = familyList->model()->index(i, 0); familyList->setCurrentIndex(currentFamily); + int expectedSize = sizeList->currentIndex().data().toInt(); const QFont current = dialog.currentFont(), expected = fdb.font(currentFamily.data().toString(), - styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt()); + styleList->currentIndex().data().toString(), expectedSize); QCOMPARE(current.family(), expected.family()); QCOMPARE(current.style(), expected.style()); + if (expectedSize == 0 && !QFontDatabase().isScalable(current.family(), current.styleName())) + QEXPECT_FAIL("", "QTBUG-53299: Smooth sizes for unscalable font contains unsupported size", Continue); QCOMPARE(current.pointSizeF(), expected.pointSizeF()); } } -- cgit v1.2.3 From a26435d65ceac5d714d5cc7d5af2326e162d7a41 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 12 Apr 2016 15:58:32 -0700 Subject: Print the QStorageInfo dump on test start So we know what we're looking at if there's a test failure. This is like QNetworkInterface. Change-Id: Id75834dab9ed466e94c7ffff1444bf51f615e944 Reviewed-by: Thiago Macieira --- .../corelib/io/qstorageinfo/tst_qstorageinfo.cpp | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index 1afcf05135..004ace4e2e 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -32,14 +32,18 @@ ****************************************************************************/ #include - #include +#include + +#include "../../../../manual/qstorageinfo/printvolumes.cpp" + class tst_QStorageInfo : public QObject { Q_OBJECT private slots: void defaultValues(); + void dump(); void operatorEqual(); #ifndef Q_OS_WINRT void operatorNotEqual(); @@ -66,6 +70,33 @@ void tst_QStorageInfo::defaultValues() QVERIFY(storage.bytesAvailable() == -1); } +static int qInfoPrinter(const char *format, ...) +{ + static char buf[1024]; + static size_t bufuse = 0; + + va_list ap; + va_start(ap, format); // use variable arg list + int n = qvsnprintf(buf + bufuse, sizeof(buf) - bufuse, format, ap); + va_end(ap); + + bufuse += n; + if (bufuse >= sizeof(buf) - 1 || format[strlen(format) - 1] == '\n') { + // flush + QtMessageHandler qt_message_print = qInstallMessageHandler(0); + qInstallMessageHandler(qt_message_print); // restore the handler + qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf)); + bufuse = 0; + } + + return 1; +} + +void tst_QStorageInfo::dump() +{ + printVolumes(QStorageInfo::mountedVolumes(), qInfoPrinter); +} + void tst_QStorageInfo::operatorEqual() { { -- cgit v1.2.3 From 474af0a61d6154006966a775d186687aa8881708 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Jan 2016 08:15:18 +0100 Subject: QWidget::mapTo/FromGlobal(): Rewrite using a QTransform. Introduce a function going up the widget hierarchy determining a QTransform for mapping the coordinates applying the transformations of any QGraphicsView instances found. In mapFromGlobal(), use the inverse of it. This fixes the case of widget hierarchies embedded into QGraphicsView with transformations. Increase fuzz in the tests due to float rounding errors. Task-number: QTBUG-41135 Task-number: QTBUG-50030 Task-number: QTBUG-50136 Task-number: QTBUG-52507 Change-Id: I507e0bccd546250fe9c2d1b74ef38657d61490b4 Reviewed-by: Marc Mutz --- .../qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index d8a8ed6b4b..ea2599fcf9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3682,16 +3682,19 @@ static QByteArray msgPointMismatch(const QPoint &actual, const QPoint &expected) void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 { const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); - const QSize size = availableGeometry.size() / 5; + const QSize size = availableGeometry.size() / 4; QGraphicsScene scene; QGraphicsView view(&scene); + view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setTransform(QTransform::fromScale(2, 2)); // QTBUG-50136, use transform. view.setWindowTitle(QTest::currentTestFunction()); view.resize(size); view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100)); - QWidget *embeddedWidget = new QWidget; - embeddedWidget->setFixedSize(size / 2); - QWidget *childWidget = new QWidget(embeddedWidget); + QWidget *embeddedWidget = new QGroupBox(QLatin1String("Embedded")); + embeddedWidget->setStyleSheet(QLatin1String("background-color: \"yellow\"; ")); + embeddedWidget->setFixedSize((size - QSize(10, 10)) / 2); + QWidget *childWidget = new QGroupBox(QLatin1String("Child"), embeddedWidget); childWidget->setStyleSheet(QLatin1String("background-color: \"red\"; ")); childWidget->resize(embeddedWidget->size() / 2); childWidget->move(embeddedWidget->width() / 4, embeddedWidget->height() / 4); // center in embeddedWidget @@ -3705,18 +3708,16 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 // This should be equivalent to the view center give or take rounding // errors due to odd window margins const QPoint viewCenter = view.geometry().center(); - QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2, + QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 3, msgPointMismatch(embeddedCenterGlobal, viewCenter).constData()); - // Same test with child centered on embeddedWidget. The correct - // mapping is not implemented yet, but at least make sure + // Same test with child centered on embeddedWidget. Also make sure // the roundtrip maptoGlobal()/mapFromGlobal() returns the same // point since that is important for mouse event handling (QTBUG-50030, // QTBUG-50136). const QPoint childCenter = childWidget->rect().center(); const QPoint childCenterGlobal = childWidget->mapToGlobal(childCenter); QCOMPARE(childWidget->mapFromGlobal(childCenterGlobal), childCenter); - QEXPECT_FAIL("", "Not implemented for child widgets of embedded widgets", Continue); QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= 4, msgPointMismatch(childCenterGlobal, viewCenter).constData()); } -- cgit v1.2.3 From 45eba73492c89157b8c353548a948d538748cd43 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 16 May 2016 14:22:03 +0200 Subject: Fix QVariant conversion to an enum type. QVariant::canConvert was returning true for everything can can be converted to integer, but not for integer itself. That's because in QVariant::canConvert we set the targetType to Int of it's an enum, but the Int->Int case was not on the conversion matrix. So this commits adds it to the conversion matrix and now QVariant::canConvert returns consistently true for int itself. But even tough canConvert returned true, it did not actualy do any conversion to the enum type itself. Fix that by handling the case properlt in 'convert' [ChangeLog][QtCore][QVariant] Fixed QVariant::canConvert and conversion from integer types to enumeration types. Task-number: QTBUG-53384 Change-Id: I6ac066f3900e31bfcea7af77836ddfc7730bd60b Reviewed-by: Thiago Macieira --- tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index f2f3baae6b..76230ccec8 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -4629,6 +4629,16 @@ template void testVariant(Enum value, bool *ok) QVERIFY(var2.convert(QMetaType::Int)); QCOMPARE(var2.value(), static_cast(value)); + if (static_cast(value) <= INT_MAX) { + int intValue = static_cast(value); + QVariant intVar = intValue; + QVERIFY(intVar.canConvert()); + QCOMPARE(intVar.value(), value); + } + qint64 longValue = static_cast(value); + QVERIFY(QVariant(longValue).canConvert()); + QCOMPARE(QVariant(longValue).value(), value); + *ok = true; } -- cgit v1.2.3 From 27425e62c071441fa8ef34775b6ad7d985e07fde Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 18 May 2016 08:50:53 +0200 Subject: Moc: fix crash when a file ends with \\\r MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make the 'cleaned' more robust by making sure we do not read past the buffer in some cases. We must also use resize and not reserve on the outpt buffer because reseve is meant as a hint and we are not supposed to write past the size of the QByteArray even if it is reserved. [ChangeLog][moc] Fixed crash on file ending with \\\r Task-number: QTBUG-53441 Change-Id: I901e6c0ffc7f8877de3d07fd08cf26495461d294 Reviewed-by: Jędrzej Nowacki Reviewed-by: Robert Loehning --- tests/auto/tools/moc/backslash-newlines.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/tools/moc/backslash-newlines.h b/tests/auto/tools/moc/backslash-newlines.h index fea3045eb1..764d8f87da 100644 --- a/tests/auto/tools/moc/backslash-newlines.h +++ b/tests/auto/tools/moc/backslash-newlines.h @@ -57,3 +57,5 @@ public slots: #undef value #endif // BACKSLASH_NEWLINES_H + +// ends with \\\r should not make moc crash (QTBUG-53441) (no new lines on purpose!!) \ \ No newline at end of file -- cgit v1.2.3 From b627dd2c24c5962c1e8f9d72bcbe9ebdfe6dfceb Mon Sep 17 00:00:00 2001 From: Felix Bourbonnais Date: Tue, 10 May 2016 10:06:53 -0400 Subject: QMenuBar: nested parenting fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMenuBar now receives a parent changed event for each of its parent, grand-parent, ... This fixes a crash caused by an invalid QWidget pointer and makes sure the keyboard shortcuts events are relayed to the menu bar in all parenting/re-parenting cases by installing an event filter on each parent Task-number: QTBUG-53205 Change-Id: I419e6cbc52e28a67fb08a848a7161b4cb8ae4ae5 Reviewed-by: Gabriel de Dietrich Reviewed-by: Błażej Szczygieł --- .../auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index f787d73a02..b2d15fffef 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -132,10 +132,12 @@ private slots: void closeOnSecondClickAndOpenOnThirdClick(); void cornerWidgets_data(); void cornerWidgets(); + void taskQTBUG53205_crashReparentNested(); protected slots: void onSimpleActivated( QAction*); void onComplexActionTriggered(); + void slotForTaskQTBUG53205(); private: TestMenu initSimpleMenuBar(QMenuBar *mb); @@ -148,6 +150,7 @@ private: QAction* m_lastSimpleAcceleratorId; int m_simpleActivatedCount; int m_complexTriggerCount[int('k')]; + QMenuBar* taskQTBUG53205MenuBar; }; // Testing get/set functions @@ -1438,5 +1441,61 @@ void tst_QMenuBar::cornerWidgets() delete cornerLabel; } + +void tst_QMenuBar::taskQTBUG53205_crashReparentNested() +{ + // This test was largely inspired by the test case submitted for the bug + QMainWindow mainWindow; + mainWindow.resize(300, 200); + centerOnScreen(&mainWindow); + const TestMenu testMenus = initWindowWithComplexMenuBar(mainWindow); + QApplication::setActiveWindow(&mainWindow); + + // they can't be windows + QWidget hiddenParent(&mainWindow, 0); + //this one is going to be moved around + QWidget movingParent(&hiddenParent, 0); + + //set up the container widget + QWidget containerWidget(&movingParent,0); + + //set the new parent, a window + QScopedPointer windowedParent; + windowedParent.reset(new QWidget(Q_NULLPTR, Qt::WindowFlags())); + windowedParent->setGeometry(400, 10, 300, 300); + + windowedParent->show(); + QVERIFY(QTest::qWaitForWindowExposed(windowedParent.data())); + + //set the "container", can't be a window + QWidget containedWidget(&containerWidget, 0); + + taskQTBUG53205MenuBar = new QMenuBar(&containedWidget); + + connect(testMenus.actions[0], &QAction::triggered, this, &tst_QMenuBar::slotForTaskQTBUG53205); + //now, move things around + //from : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar + //to windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar + movingParent.setParent(windowedParent.data(),0); + // this resets the parenting and the menu bar's window + taskQTBUG53205MenuBar->setParent(Q_NULLPTR); + taskQTBUG53205MenuBar->setParent(&containedWidget); + //from windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar + //to : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar + movingParent.setParent(&hiddenParent,0); + windowedParent.reset(); //make the old window invalid + // trigger the aciton, reset the menu bar's window, this used to crash here. + testMenus.actions[0]->trigger(); +} + +void tst_QMenuBar::slotForTaskQTBUG53205() +{ + QWidget *parent = taskQTBUG53205MenuBar->parentWidget(); + taskQTBUG53205MenuBar->setParent(Q_NULLPTR); + taskQTBUG53205MenuBar->setParent(parent); +} + + + QTEST_MAIN(tst_QMenuBar) #include "tst_qmenubar.moc" -- cgit v1.2.3