summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@theqtcompany.com>2016-01-29 22:29:58 +0100
committerAndy Shaw <andy.shaw@theqtcompany.com>2016-02-02 07:43:13 +0000
commit0c019d7bd2fff4eba39afc3a4db63d71d13988da (patch)
tree4f01ecd125073eb17085ed8b4327fe47c60cea2d /tests/auto
parentb84c61b088feafaa2417b8920bb41f970adb79c8 (diff)
QDockWidget: Restore using setGeometry since the geometry is used for the state
This solves an instance where restoreState() was used when the dockwidget was already floating and the saved state was also for a floating dockwidget. Change-Id: I1fe764ae2a6b0351ae26e33ffec682ad37c944d7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 713dc6b9b8..61a9461a62 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -75,6 +75,7 @@ private slots:
void titleBarDoubleClick();
void restoreStateOfFloating();
void restoreDockWidget();
+ void restoreStateWhileStillFloating();
// task specific tests:
void task165177_deleteFocusWidget();
void task169808_setFloating();
@@ -757,6 +758,31 @@ void tst_QDockWidget::restoreStateOfFloating()
QVERIFY(!dock->isFloating());
}
+void tst_QDockWidget::restoreStateWhileStillFloating()
+{
+ // When the dock widget is already floating then it takes a different code path
+ // so this test covers the case where the restoreState() is effectively just
+ // moving it back and resizing it
+ const QRect availGeom = QApplication::desktop()->availableGeometry();
+ const QPoint startingDockPos = availGeom.center();
+ QMainWindow mw;
+ QDockWidget *dock = createTestDock(mw);
+ mw.addDockWidget(Qt::TopDockWidgetArea, dock);
+ dock->setFloating(true);
+ dock->move(startingDockPos);
+ mw.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&mw));
+ QVERIFY(dock->isFloating());
+ QByteArray ba = mw.saveState();
+ const QPoint dockPos = dock->pos();
+ dock->move(availGeom.topLeft() + QPoint(10, 10));
+ dock->resize(dock->size() + QSize(10, 10));
+ QVERIFY(mw.restoreState(ba));
+ QVERIFY(dock->isFloating());
+ if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive))
+ QTRY_COMPARE(dock->pos(), dockPos);
+}
+
void tst_QDockWidget::restoreDockWidget()
{
QByteArray geometry;