diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-12-15 10:49:47 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-12-15 12:05:26 +0000 |
commit | bece6fa0b9409918ce9c57c59d61537b304c9812 (patch) | |
tree | 3f45a8bf1dd30b63ee115ee29eb99a5b5ea0745b /tests | |
parent | 482165057dfb1cc6ef4281e693dd8127aa0d6f6e (diff) |
QDockAreaLayout/QPlaceHolderItem: Store geometry excluding frame.
Previously, the geometry stored for floating dock widgets
in QPlaceHolderItem::topLevelRect and QDockAreaLayoutInfo::saveState()
included the window frame (frame position/content area size).
This does not work in the case where a floating dock widget is deleted
since the geometry is determined after reparenting the widget when the
frame geometry is no longer available. Change the behavior to store
the geometry excluding frame to avoid such problems and adapt
QDockWidgetPrivate::setWindowState() accordingly.
Task-number: QTBUG-49832
Task-number: QTBUG-45780
Change-Id: I84b5c80df6e1c9e738bbb1407b9047cc84719ce0
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 70df31ed69..713dc6b9b8 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -761,6 +761,9 @@ void tst_QDockWidget::restoreDockWidget() { QByteArray geometry; QByteArray state; + + const bool isXcb = !QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive); + const QString name = QStringLiteral("main"); const QRect availableGeometry = QApplication::desktop()->availableGeometry(); const QSize size = availableGeometry.size() / 5; @@ -785,11 +788,22 @@ void tst_QDockWidget::restoreDockWidget() QVERIFY(dock->isFloating()); state = saveWindow.saveState(); geometry = saveWindow.saveGeometry(); + + // QTBUG-49832: Delete and recreate the dock; it should be restored to the same position. + delete dock; + dock = createTestDock(saveWindow); + QVERIFY(saveWindow.restoreDockWidget(dock)); + dock->show(); + QVERIFY(QTest::qWaitForWindowExposed(dock)); + QTRY_VERIFY(dock->isFloating()); + if (!isXcb) // Avoid Window manager positioning issues + QTRY_COMPARE(dock->pos(), dockPos); } QVERIFY(!geometry.isEmpty()); QVERIFY(!state.isEmpty()); + // QTBUG-45780: Completely recreate the dock widget from the saved state. { QMainWindow restoreWindow; restoreWindow.setObjectName(name); @@ -804,7 +818,7 @@ void tst_QDockWidget::restoreDockWidget() restoreWindow.show(); QVERIFY(QTest::qWaitForWindowExposed(&restoreWindow)); QTRY_VERIFY(dock->isFloating()); - if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) + if (isXcb) QSKIP("Skip due to Window manager positioning issues", Abort); QTRY_COMPARE(dock->pos(), dockPos); } |