From 097be87a64995bab43ba5b7d2a7aff5571a298b9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 19 Nov 2013 11:02:50 +0100 Subject: Stabilize tst_QGraphicsScene::isActive(). Position windows, use QTRY_VERIFY. Change-Id: I84349dd696a633840973e9db0c538830aaa96948 Reviewed-by: Frederik Gladhorn --- .../auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index fe1df6c8f0..15c92663ec 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -4072,6 +4072,7 @@ void tst_QGraphicsScene::isActive() { + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QWidget toplevel2; QHBoxLayout *layout = new QHBoxLayout; toplevel2.setLayout(layout); @@ -4085,12 +4086,13 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); + toplevel2.move(availableGeometry.topLeft() + QPoint(50, 50)); toplevel2.show(); QApplication::setActiveWindow(&toplevel2); QVERIFY(QTest::qWaitForWindowActive(&toplevel2)); QCOMPARE(QApplication::activeWindow(), &toplevel2); - QVERIFY(scene1.isActive()); + QTRY_VERIFY(scene1.isActive()); QVERIFY(!scene2.isActive()); QVERIFY(scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); @@ -4133,6 +4135,7 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene2.hasFocus()); QGraphicsView topLevelView; + topLevelView.move(availableGeometry.topLeft() + QPoint(500, 50)); topLevelView.show(); QApplication::setActiveWindow(&topLevelView); topLevelView.setFocus(); -- cgit v1.2.3 From 0787550f637b10317e06dea249a51c24f7e18b7e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 19 Nov 2013 11:04:15 +0100 Subject: Stabilize tst_QGraphicsView::hoverLeave(). Position windows, use QTRY_VERIFY. Change-Id: I0fab91c65b30e7028343c7e9b19a1b232fe72ebf Reviewed-by: Frederik Gladhorn --- .../graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 7a0ba50ff0..37cc6522a2 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4687,13 +4687,17 @@ public: void tst_QGraphicsView::hoverLeave() { + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(160, 160); + view.move(availableGeometry.center() - QPoint(80, 80)); GraphicsItemWithHover *item = new GraphicsItemWithHover; scene.addItem(item); // move the cursor out of the way - QCursor::setPos(1,1); + const QPoint outOfWindow = view.geometry().topRight() + QPoint(50, 0); + QCursor::setPos(outOfWindow); view.show(); qApp->setActiveWindow(&view); @@ -4701,16 +4705,14 @@ void tst_QGraphicsView::hoverLeave() QPoint pos = view.viewport()->mapToGlobal(view.mapFromScene(item->mapToScene(10, 10))); QCursor::setPos(pos); - QTest::qWait(200); - QVERIFY(item->receivedEnterEvent); + QTRY_VERIFY(item->receivedEnterEvent); QCOMPARE(item->enterWidget, view.viewport()); - QCursor::setPos(1,1); - QTest::qWait(200); + QCursor::setPos(outOfWindow); #ifdef Q_OS_MAC QEXPECT_FAIL("", "QTBUG-26274 - behaviour regression", Abort); #endif - QVERIFY(item->receivedLeaveEvent); + QTRY_VERIFY(item->receivedLeaveEvent); QCOMPARE(item->leaveWidget, view.viewport()); } -- cgit v1.2.3 From 054dfae39d093200fcce477b30a17bacf422be36 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 19 Nov 2013 11:05:23 +0100 Subject: Stabilize tst_QGraphicsWidget::updateFocusChainWhenChildDie(). Position windows, use QTRY_VERIFY. Change-Id: I185bcd91bcdffbc0460a4d24f685d3dde84338a7 Reviewed-by: Frederik Gladhorn --- .../graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 2dd2089f81..3271b31692 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include "../../../qtest-config.h" @@ -1780,8 +1781,11 @@ void tst_QGraphicsWidget::verifyFocusChain() void tst_QGraphicsWidget::updateFocusChainWhenChildDie() { + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(200, 150); + view.move(availableGeometry.topLeft() + QPoint(50, 50)); view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1801,6 +1805,9 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() QVERIFY(w1_1->hasFocus()); QWidget myWidget(0); QLineEdit edit(&myWidget); + (new QHBoxLayout(&myWidget))->addWidget(&edit); + edit.setMinimumWidth(160); // Windows + myWidget.move(availableGeometry.topLeft() + QPoint(350, 50)); myWidget.show(); edit.setFocus(); QTRY_VERIFY(edit.hasFocus()); @@ -1809,8 +1816,9 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() w->setParentItem(parent); //We don't crash perfect QVERIFY(w); - QTest::mouseMove(view.viewport()); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0); + const QPoint center(view.viewport()->width() / 2, view.viewport()->height() / 2); + QTest::mouseMove(view.viewport(), center); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, center); #ifdef Q_OS_MAC QEXPECT_FAIL("", "QTBUG-23699", Continue); #endif -- cgit v1.2.3 From 885bd1d0e57b9e0e5a7c4945866c2ef00ae30c92 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 16 Nov 2013 22:07:01 +0100 Subject: tst_QFileSystemModel: don't expect ~/Documents to exist For me, this test failed because I don't have a Documents folder in my home directory, even though that's what's returned from QStandardPaths as the first DocumentsLocation. Fix by falling back on the home directory if documentPaths.front() does not exist. Change-Id: I483f62f3b4b43d055c74774a7058a4aa420849b1 Reviewed-by: Friedemann Kleint --- .../widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 61a2abc084..9cb391d5f4 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -212,7 +212,14 @@ void tst_QFileSystemModel::rootPath() QString oldRootPath = model->rootPath(); const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); QVERIFY(!documentPaths.isEmpty()); - const QString documentPath = documentPaths.front(); + QString documentPath = documentPaths.front(); + // In particular on Linux, ~/Documents (the first + // DocumentsLocation) may not exist, so choose ~ in that case: + if (!QFile::exists(documentPath)) { + documentPath = QDir::homePath(); + qWarning("%s: first documentPath \"%s\" does not exist. Using ~ (\"%s\") instead.", + Q_FUNC_INFO, qPrintable(documentPaths.front()), qPrintable(documentPath)); + } root = model->setRootPath(documentPath); QTRY_VERIFY(model->rowCount(root) >= 0); -- cgit v1.2.3 From 6bf759b31040fb5d05044cd14d5889fbd19a8942 Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 11 Nov 2013 13:30:44 +0100 Subject: QTimeZone - Change Olsen ID to IANA ID The name Olson was misspelled as Olsen in the public api of QTimeZone which is needed to be fixed before first public release in 5.2 would freeze the api and prevent it being fixed. It has been decided that renaming as IANA ID would be more future-proof. Fixes to the private code will be done separately to keep this patch against release branch to the minimum required. Task-number: QTBUG-34735 Change-Id: I8ee90644862c907f6d1937b8536f0c02583ae736 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- .../auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index ed08bcefbf..ac8530bd54 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -371,7 +371,7 @@ void tst_QTimeZone::windowsId() { /* Current Windows zones for "Central Standard Time": - Region Olsen Id(s) + Region IANA Id(s) Default "America/Chicago" Canada "America/Winnipeg America/Rainy_River America/Rankin_Inlet America/Resolute" Mexico "America/Matamoros" @@ -380,24 +380,24 @@ void tst_QTimeZone::windowsId() "America/North_Dakota/New_Salem" AnyCountry "CST6CDT" */ - QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Chicago"), + QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Chicago"), QByteArray("Central Standard Time")); - QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Resolute"), + QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Resolute"), QByteArray("Central Standard Time")); // Partials shouldn't match - QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Chi"), QByteArray()); - QCOMPARE(QTimeZone::olsenIdToWindowsId("InvalidZone"), QByteArray()); - QCOMPARE(QTimeZone::olsenIdToWindowsId(QByteArray()), QByteArray()); + QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Chi"), QByteArray()); + QCOMPARE(QTimeZone::ianaIdToWindowsId("InvalidZone"), QByteArray()); + QCOMPARE(QTimeZone::ianaIdToWindowsId(QByteArray()), QByteArray()); // Check default value - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time"), + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time"), QByteArray("America/Chicago")); - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time", QLocale::Canada), + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::Canada), QByteArray("America/Winnipeg")); - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time", QLocale::AnyCountry), + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::AnyCountry), QByteArray("CST6CDT")); - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId(QByteArray()), QByteArray()); + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId(QByteArray()), QByteArray()); // No country is sorted list of all zones QList list; @@ -406,39 +406,39 @@ void tst_QTimeZone::windowsId() << "America/North_Dakota/Center" << "America/North_Dakota/New_Salem" << "America/Rainy_River" << "America/Rankin_Inlet" << "America/Resolute" << "America/Winnipeg" << "CST6CDT"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time"), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time"), list); // Check country with no match returns empty list list.clear(); - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::NewZealand), + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::NewZealand), list); // Check valid country returns list in preference order list.clear(); list << "America/Winnipeg" << "America/Rainy_River" << "America/Rankin_Inlet" << "America/Resolute"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::Canada), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Canada), list); list.clear(); list << "America/Matamoros"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::Mexico), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Mexico), list); list.clear(); list << "America/Chicago" << "America/Indiana/Knox" << "America/Indiana/Tell_City" << "America/Menominee" << "America/North_Dakota/Beulah" << "America/North_Dakota/Center" << "America/North_Dakota/New_Salem"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::UnitedStates), + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::UnitedStates), list); list.clear(); list << "CST6CDT"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::AnyCountry), + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::AnyCountry), list); // Check no windowsId return empty list.clear(); - QCOMPARE(QTimeZone::windowsIdToOlsenIds(QByteArray()), list); - QCOMPARE(QTimeZone::windowsIdToOlsenIds(QByteArray(), QLocale::AnyCountry), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray()), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyCountry), list); } void tst_QTimeZone::utcTest() -- cgit v1.2.3 From 8e6258f059140ce735391b6438d5976dc9469e95 Mon Sep 17 00:00:00 2001 From: John Layt Date: Fri, 20 Sep 2013 18:35:08 +0200 Subject: QTimeZone - Fix TZ file abbreviations Fix parsing of TZ file abbreviations, to correctly return cases where POSIX rule doesn't have separate DST rules, and where abbreviation is a sub-string of another abbreviation, otherwise any toString() call will crash. Add test to exercise all available time zones, especially useful for TZ file to confirm all file format variations dealt with. Fix parsing of Version 3 of TZ file, and ICU display name, to allow all files generated from release 2013f to pass, otherwise isValid() call will crash. Task-number: QTBUG-34061 Change-Id: Ie0b6abc218adff1c8967eb33fdb0762041d2305f Reviewed-by: Thiago Macieira --- .../auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 54 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index ac8530bd54..cfb20f51e4 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -57,6 +57,7 @@ private slots: void nullTest(); void dataStreamTest(); void availableTimeZoneIds(); + void stressTest(); void windowsId(); // Backend tests void utcTest(); @@ -75,7 +76,7 @@ private: tst_QTimeZone::tst_QTimeZone() { - // Set to true to print debug output + // Set to true to print debug output, test Display Names and run long stress tests debug = false; } @@ -367,6 +368,50 @@ void tst_QTimeZone::availableTimeZoneIds() } } +void tst_QTimeZone::stressTest() +{ + QList idList = QTimeZone::availableTimeZoneIds(); + foreach (const QByteArray &id, idList) { + QTimeZone testZone = QTimeZone(id); + QCOMPARE(testZone.isValid(), true); + QCOMPARE(testZone.id(), id); + QDateTime testDate = QDateTime(QDate(2015, 1, 1), QTime(0, 0, 0), Qt::UTC); + testZone.country(); + testZone.comment(); + testZone.displayName(testDate); + testZone.displayName(QTimeZone::DaylightTime); + testZone.displayName(QTimeZone::StandardTime); + testZone.abbreviation(testDate); + testZone.offsetFromUtc(testDate); + testZone.standardTimeOffset(testDate); + testZone.daylightTimeOffset(testDate); + testZone.hasDaylightTime(); + testZone.isDaylightTime(testDate); + testZone.offsetData(testDate); + testZone.hasTransitions(); + testZone.nextTransition(testDate); + testZone.previousTransition(testDate); + // Dates known to be outside possible tz file pre-calculated rules range + QDateTime lowDate1 = QDateTime(QDate(1800, 1, 1), QTime(0, 0, 0), Qt::UTC); + QDateTime lowDate2 = QDateTime(QDate(1800, 6, 1), QTime(0, 0, 0), Qt::UTC); + QDateTime highDate1 = QDateTime(QDate(2200, 1, 1), QTime(0, 0, 0), Qt::UTC); + QDateTime highDate2 = QDateTime(QDate(2200, 6, 1), QTime(0, 0, 0), Qt::UTC); + testZone.nextTransition(lowDate1); + testZone.nextTransition(lowDate2); + testZone.previousTransition(lowDate2); + testZone.previousTransition(lowDate2); + testZone.nextTransition(highDate1); + testZone.nextTransition(highDate2); + testZone.previousTransition(highDate1); + testZone.previousTransition(highDate2); + if (debug) { + // This could take a long time, depending on platform and database + qDebug() << "Stress test calculating transistions for" << testZone.id(); + testZone.transitions(lowDate1, highDate1); + } + } +} + void tst_QTimeZone::windowsId() { /* @@ -639,10 +684,11 @@ void tst_QTimeZone::tzTest() QCOMPARE(dat.standardTimeOffset, 3600); QCOMPARE(dat.daylightTimeOffset, 0); + // Test previous to low value is invalid dat = tzp.previousTransition(-9999999999999); - QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000); - QCOMPARE(dat.standardTimeOffset, 3600); - QCOMPARE(dat.daylightTimeOffset, 0); + QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits::min()); + QCOMPARE(dat.standardTimeOffset, std::numeric_limits::min()); + QCOMPARE(dat.daylightTimeOffset, std::numeric_limits::min()); dat = tzp.nextTransition(-9999999999999); QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000); -- cgit v1.2.3 From 6ad97bfa736c97b50019d0192f55959848e7067a Mon Sep 17 00:00:00 2001 From: John Layt Date: Sat, 2 Nov 2013 18:53:32 +0100 Subject: QTimeZone - Fix dateForLocalTime() to check validity of next transition The private method dateForLocalTime() was not checking that transitions were valid, resulting in infinite looping when a time zone didn't have any future transitions. Change-Id: I0e5d07063861778dd86056a80c36fdd9f9d36133 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 6 ++++++ tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 1e2b0ed649..6c80c5ff47 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2903,6 +2903,12 @@ void tst_QDateTime::timeZones() const // - Test 03:00:00 = 1 hour after tran hourAfterStd = QDateTime(QDate(2013, 10, 27), QTime(3, 0, 0), cet); QCOMPARE(hourAfterStd.toMSecsSinceEpoch(), dstToStdMSecs + 3600000); + + // Test Time Zone that has transitions but no future transitions afer a given date + QTimeZone sgt("Asia/Singapore"); + QDateTime future(QDate(2015, 1, 1), QTime(0, 0, 0), sgt); + QVERIFY(future.isValid()); + QCOMPARE(future.offsetFromUtc(), 28800); } void tst_QDateTime::invalid() const diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index cfb20f51e4..d7643ff55d 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -409,6 +409,10 @@ void tst_QTimeZone::stressTest() qDebug() << "Stress test calculating transistions for" << testZone.id(); testZone.transitions(lowDate1, highDate1); } + testDate.setTimeZone(testZone); + testDate.isValid(); + testDate.offsetFromUtc(); + testDate.timeZoneAbbreviation(); } } -- cgit v1.2.3 From 773610cc451bb2b4319da6567b21510022d08014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 21 Nov 2013 14:43:40 +0100 Subject: Revert "Ensure Qt::WA_Mapped is set in case of obscured native windows." Qt::WA_Mapped maps (sic) to windowHandle()->isExposed(), and we set/update it in QWidgetWindow::handleExposeEvent(). Setting it directly in show_sys shortcuts QPA and assumes showing a window is synchronous on all platforms, resulting in trying to flush the widget backingstore when the window was not exposed yet (due to discardSyncRequest starting to return false). This reverts commit 829b1d13b225e87b8a385397e2b53c7a9f8cda9e. Change-Id: I0bd700d4939bc69ba184d8586435b68ec3dd72fb Reviewed-by: Gunnar Sletta --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 4 ---- .../kernel/qwidget_window/tst_qwidget_window.cpp | 28 ---------------------- 2 files changed, 32 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 7bb5fd4614..03d6c1cdbd 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -7192,10 +7192,6 @@ void tst_QWidget::hideOpaqueChildWhileHidden() #if !defined(Q_OS_WINCE) void tst_QWidget::updateWhileMinimized() { -#ifdef Q_OS_UNIX - if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) - QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. -#endif // Q_OS_UNIX UpdateWidget widget; // Filter out activation change and focus events to avoid update() calls in QWidget. widget.updateOnActivationChangeAndFocusIn = false; diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index f5585c583a..1bbbfd610e 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -91,8 +91,6 @@ private slots: void tst_showWithoutActivating(); void tst_paintEventOnSecondShow(); - void obscuredNativeMapped(); - #ifndef QT_NO_DRAGANDDROP void tst_dnd(); #endif @@ -370,32 +368,6 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() QTRY_VERIFY(w.paintEventReceived); } -// QTBUG-33520, a toplevel fully obscured by native children should still receive Qt::WA_Mapped -void tst_QWidget_window::obscuredNativeMapped() -{ - enum { size = 200 }; - - QWidget topLevel; - topLevel.setWindowFlags(Qt::FramelessWindowHint); - QWidget *child = new QWidget(&topLevel); - child->resize(size, size); - topLevel.resize(size, size); - topLevel.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(size /2 , size / 2)); - child->winId(); - topLevel.show(); - QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); -#if defined(Q_OS_MAC) - QSKIP("This test fails on Mac."); // Minimized windows are not unmapped for some reason. -#elif defined(Q_OS_UNIX) - if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) - QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. -#endif // Q_OS_UNIX - topLevel.setWindowState(Qt::WindowMinimized); - QTRY_VERIFY(!topLevel.testAttribute(Qt::WA_Mapped)); - topLevel.setWindowState(Qt::WindowNoState); - QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); -} - #ifndef QT_NO_DRAGANDDROP /* DnD test for QWidgetWindow (handleDrag*Event() functions). -- cgit v1.2.3 From f805020410c8ccb0cd223988565bcabde1c5806b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 15 Nov 2013 09:46:02 +0100 Subject: Fix a race that occurred as we unlock the mutex to destroy the functor in ~QObject When we unlock the mutex, we need to take in account that the Connection pointed by 'node' may be destroyed in another thread while it is unlocked Doing 'node->prev = &node' will make sure that 'node' is actually updated when it is destroyed. Setting isSlotObject under the mutex is safer and ensure that no other thread will attempt to deref the object. The regression was introduced in 5885b8f775998c30d53f40b7f368c5f6364e6df4 tst_qobjectrace was updated to catch races arising when we are connecting with function pointers. Change-Id: Ia0d11ae8df563dad97eb86993a786b579b28cd03 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Lars Knoll --- tests/auto/other/qobjectrace/tst_qobjectrace.cpp | 76 ++++++++++++++++++------ 1 file changed, 57 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp index ab05c64fe5..71a90e83f7 100644 --- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp @@ -47,6 +47,12 @@ enum { OneMinute = 60 * 1000, TwoMinutes = OneMinute * 2 }; + +struct Functor +{ + void operator()() const {}; +}; + class tst_QObjectRace: public QObject { Q_OBJECT @@ -122,11 +128,7 @@ signals: private slots: void checkStopWatch() { -#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS) - if (stopWatch.elapsed() >= OneMinute / 2) -#else - if (stopWatch.elapsed() >= OneMinute) -#endif + if (stopWatch.elapsed() >= 5000) quit(); QObject o; @@ -188,16 +190,34 @@ class MyObject : public QObject void signal7(); }; +namespace { +const char *_slots[] = { SLOT(slot1()) , SLOT(slot2()) , SLOT(slot3()), + SLOT(slot4()) , SLOT(slot5()) , SLOT(slot6()), + SLOT(slot7()) }; + +const char *_signals[] = { SIGNAL(signal1()), SIGNAL(signal2()), SIGNAL(signal3()), + SIGNAL(signal4()), SIGNAL(signal5()), SIGNAL(signal6()), + SIGNAL(signal7()) }; +typedef void (MyObject::*PMFType)(); +const PMFType _slotsPMF[] = { &MyObject::slot1, &MyObject::slot2, &MyObject::slot3, + &MyObject::slot4, &MyObject::slot5, &MyObject::slot6, + &MyObject::slot7 }; + +const PMFType _signalsPMF[] = { &MyObject::signal1, &MyObject::signal2, &MyObject::signal3, + &MyObject::signal4, &MyObject::signal5, &MyObject::signal6, + &MyObject::signal7 }; + +} class DestroyThread : public QThread { Q_OBJECT - QObject **objects; + MyObject **objects; int number; public: - void setObjects(QObject **o, int n) + void setObjects(MyObject **o, int n) { objects = o; number = n; @@ -206,8 +226,29 @@ public: } void run() { - for(int i = 0; i < number; i++) + for (int i = number-1; i >= 0; --i) { + /* Do some more connection and disconnection between object in this thread that have not been destroyed yet */ + + const int nAlive = i+1; + connect (objects[((i+1)*31) % nAlive], _signals[(12*i)%7], objects[((i+2)*37) % nAlive], _slots[(15*i+2)%7] ); + disconnect(objects[((i+1)*31) % nAlive], _signals[(12*i)%7], objects[((i+2)*37) % nAlive], _slots[(15*i+2)%7] ); + + connect (objects[((i+4)*41) % nAlive], _signalsPMF[(18*i)%7], objects[((i+5)*43) % nAlive], _slotsPMF[(19*i+2)%7] ); + disconnect(objects[((i+4)*41) % nAlive], _signalsPMF[(18*i)%7], objects[((i+5)*43) % nAlive], _slotsPMF[(19*i+2)%7] ); + + QMetaObject::Connection c = connect(objects[((i+5)*43) % nAlive], _signalsPMF[(9*i+1)%7], Functor()); + disconnect(c); + + disconnect(objects[i], _signalsPMF[(10*i+5)%7], 0, 0); + disconnect(objects[i], _signals[(11*i+6)%7], 0, 0); + + disconnect(objects[i], 0, objects[(i*17+6) % nAlive], 0); + if (i%4 == 1) { + disconnect(objects[i], 0, 0, 0); + } + delete objects[i]; + } } }; @@ -216,27 +257,24 @@ public: void tst_QObjectRace::destroyRace() { - enum { ThreadCount = 10, ObjectCountPerThread = 733, + enum { ThreadCount = 10, ObjectCountPerThread = 2777, ObjectCount = ThreadCount * ObjectCountPerThread }; - const char *_slots[] = { SLOT(slot1()) , SLOT(slot2()) , SLOT(slot3()), - SLOT(slot4()) , SLOT(slot5()) , SLOT(slot6()), - SLOT(slot7()) }; - - const char *_signals[] = { SIGNAL(signal1()), SIGNAL(signal2()), SIGNAL(signal3()), - SIGNAL(signal4()), SIGNAL(signal5()), SIGNAL(signal6()), - SIGNAL(signal7()) }; - - QObject *objects[ObjectCount]; + MyObject *objects[ObjectCount]; for (int i = 0; i < ObjectCount; ++i) objects[i] = new MyObject; - for (int i = 0; i < ObjectCount * 11; ++i) { + for (int i = 0; i < ObjectCount * 17; ++i) { connect(objects[(i*13) % ObjectCount], _signals[(2*i)%7], objects[((i+2)*17) % ObjectCount], _slots[(3*i+2)%7] ); connect(objects[((i+6)*23) % ObjectCount], _signals[(5*i+4)%7], objects[((i+8)*41) % ObjectCount], _slots[(i+6)%7] ); + + connect(objects[(i*67) % ObjectCount], _signalsPMF[(2*i)%7], + objects[((i+1)*71) % ObjectCount], _slotsPMF[(3*i+2)%7] ); + connect(objects[((i+3)*73) % ObjectCount], _signalsPMF[(5*i+4)%7], + objects[((i+5)*79) % ObjectCount], Functor() ); } DestroyThread *threads[ThreadCount]; -- cgit v1.2.3