summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMikko Knuutila <mikko.knuutila@digia.com>2012-02-20 15:10:22 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-16 03:51:36 +0200
commit8de28b65bd18bea49fa57682d7ec3c3cd3cc4e7a (patch)
tree06b0f8a43e9154f3f0f5c69d94da9b216f5c4b44 /tests
parent0c95d019c64c3cf3c5bd6e150846033b5a96e794 (diff)
Fix for restoring dockwidget's size when it gets dragged.
When user drags a dockwidget out of the docking area, restore widget's previous floating size and center it's titlebar under the mouse. Task-number: QTBUG-2940 Change-Id: I004de36d649abc4c32420bdd46bb6c810ef98c64 Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdockwidget/tst_qdockwidget.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp
index b3e3b31bce..6ac386fad4 100644
--- a/tests/auto/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp
@@ -97,6 +97,7 @@ private slots:
void task258459_visibilityChanged();
void taskQTBUG_1665_closableChanged();
void taskQTBUG_9758_undockedGeometry();
+ void taskQTBUG_2940_resizeAfterUndocking();
};
// Testing get/set functions
@@ -899,6 +900,32 @@ void tst_QDockWidget::taskQTBUG_9758_undockedGeometry()
QVERIFY(dock1.y() >= 0);
}
+void tst_QDockWidget::taskQTBUG_2940_resizeAfterUndocking()
+{
+ QMainWindow window;
+ QDockWidget dw("dw", &window);
+ window.setGeometry(window.x(), window.y(), 400, 400);
+ window.addDockWidget(Qt::TopDockWidgetArea, &dw);
+ window.show();
+ dw.setFloating(true);
+ dw.setGeometry(dw.x(), dw.y(), 100, 100);
+
+ // When docked, width should be the same than window's width
+ dw.setFloating(false);
+ QCOMPARE(dw.width(), window.width());
+
+ // Drag the dock widget out of the window
+ qApp->postEvent(&dw, new QMouseEvent(QEvent::MouseButtonPress,
+ QPoint(10, 10), Qt::LeftButton, 0, 0));
+ qApp->postEvent(&dw, new QMouseEvent(QEvent::MouseMove,
+ QPoint(100, 100), Qt::LeftButton,Qt::LeftButton, 0));
+ qApp->postEvent(&dw, new QMouseEvent(QEvent::MouseButtonRelease,
+ QPoint(100, 100), Qt::LeftButton, 0, 0));
+ qApp->processEvents();
+
+ // When undocked, size should be the restored
+ QCOMPARE(dw.size(), QSize(100, 100));
+}
QTEST_MAIN(tst_QDockWidget)