summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp16
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp21
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp17
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp36
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST16
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp115
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp59
9 files changed, 197 insertions, 90 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index b836cdf00b..7d4fe2d499 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -547,6 +547,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 53d7cae837..5f314cddc4 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -121,6 +121,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());
@@ -1106,6 +1108,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"
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 6b964bc776..a5aaf62855 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -188,11 +188,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());
}
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 4cf602a548..8908b83f11 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3667,16 +3667,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
@@ -3690,18 +3693,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());
}
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 445e5e7ac7..cf8ee310d3 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -188,6 +188,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();
@@ -4475,5 +4476,40 @@ void tst_QTableView::taskQTBUG_7232_AllowUserToControlSingleStep()
QCOMPARE(hStep1, t.horizontalScrollBar()->singleStep());
}
+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"
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 0a344cd52d..98a4caf49e 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
@@ -21,20 +19,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]
@@ -51,12 +41,6 @@ osx
osx
[render_systemClip]
osx
-[update]
-osx
-[doubleRepaint]
-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 fc6c66de2e..78fbae768a 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -221,7 +221,6 @@ private slots:
void widgetAt();
#ifdef Q_OS_OSX
- void sheetOpacity();
void setMask();
#endif
void optimizedResizeMove();
@@ -381,7 +380,6 @@ private slots:
void movedAndResizedAttributes();
void childAt();
#ifdef Q_OS_OSX
- void childAt_unifiedToolBar();
void taskQTBUG_11373();
#endif
void taskQTBUG_17333_ResizeInfiniteRecursion();
@@ -1750,6 +1748,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"))
@@ -1957,6 +1959,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;
@@ -2312,6 +2318,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);
QScopedPointer<QWidget> testWidget(new QWidget);
@@ -2374,6 +2384,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;
@@ -2721,8 +2735,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<QWidget> parent(new QWidget);
@@ -2784,12 +2796,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<QWidget> parent(new QWidget);
parent->setObjectName(QLatin1String("stackUnder"));
parent->setWindowTitle(parent->objectName());
@@ -2867,7 +2880,6 @@ void tst_QWidget::stackUnder()
child->reset();
}
}
-#endif
void drawPolygon(QPaintDevice *dev, int w, int h)
{
@@ -2956,6 +2968,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);
@@ -3181,6 +3197,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
@@ -3388,17 +3408,6 @@ void tst_QWidget::testDeletionInEventHandlers()
}
#ifdef Q_OS_OSX
-void tst_QWidget::sheetOpacity()
-{
- 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:
@@ -4036,6 +4045,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
@@ -5021,10 +5034,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);
@@ -5057,7 +5073,6 @@ void tst_QWidget::subtractOpaqueSiblings()
QRegion(medium->geometry().translated(large->pos()))
- tall->geometry());
}
-#endif
void tst_QWidget::deleteStyle()
{
@@ -5099,6 +5114,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;
@@ -7757,6 +7776,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");
@@ -9269,10 +9292,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();
@@ -9318,7 +9337,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()
@@ -9377,46 +9395,11 @@ 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<QWidget *>(toolBar));
- QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(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<QWidget *>(toolBar));
- QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(label));
-}
void tst_QWidget::taskQTBUG_11373()
{
+ QSKIP("QTBUG-52974");
+
QScopedPointer<QMainWindow> myWindow(new QMainWindow);
QWidget * center = new QWidget();
myWindow -> setCentralWidget(center);
@@ -9432,6 +9415,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()
@@ -10279,6 +10263,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);
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index a5a94f109a..2b8f3032bf 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -486,7 +486,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();
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 436a8331f0..e9f5175466 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -127,10 +127,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);
@@ -143,6 +145,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<QWidget> 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"