diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-08-20 16:38:05 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-21 16:13:38 +0200 |
commit | 82860b133c123d8136cf13e99f66c4b55badc5fa (patch) | |
tree | 0e00e3786aefcd1fac44ed4e555767e10d8c7291 /tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | |
parent | 8133af25031880b7d28e4e9d6124f48fb986b683 (diff) |
Propagate initial size constraints to QWidgetWindow.
Size constraints set on a widget before the creation of
the QWidgetWindow were lost (for example, Qt Creator's
preference page).
Task-number: QTBUG-26745
Change-Id: I7c2f5aed9c8817795603e5ad3c24418d66627bab
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp')
-rw-r--r-- | tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
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 4daeb6ceb6..bccd9a5951 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -46,6 +46,8 @@ #include <qlist.h> #include <qlistwidget.h> +#include <qpushbutton.h> +#include <qboxlayout.h> class tst_QWidget_window : public QWidget @@ -60,6 +62,8 @@ public slots: void cleanupTestCase(); private slots: + void tst_min_max_size(); + void tst_min_max_size_data(); void tst_move_show(); void tst_show_move(); void tst_show_move_hide_show(); @@ -85,6 +89,39 @@ void tst_QWidget_window::cleanupTestCase() { } +/* Test if the maximum/minimum size constraints + * are propagated from the widget to the QWidgetWindow + * independently of whether they were set before or after + * window creation (QTBUG-26745). */ + +void tst_QWidget_window::tst_min_max_size_data() +{ + QTest::addColumn<bool>("setMinMaxSizeBeforeShow"); + QTest::newRow("Set min/max size after show") << false; + QTest::newRow("Set min/max size before show") << true; +} + +void tst_QWidget_window::tst_min_max_size() +{ + QFETCH(bool, setMinMaxSizeBeforeShow); + const QSize minSize(300, 400); + const QSize maxSize(1000, 500); + QWidget w1; + (new QVBoxLayout(&w1))->addWidget(new QPushButton("Test")); + if (setMinMaxSizeBeforeShow) { + w1.setMinimumSize(minSize); + w1.setMaximumSize(maxSize); + } + w1.show(); + if (!setMinMaxSizeBeforeShow) { + w1.setMinimumSize(minSize); + w1.setMaximumSize(maxSize); + } + QVERIFY(QTest::qWaitForWindowExposed(&w1)); + QCOMPARE(w1.windowHandle()->minimumSize(),minSize); + QCOMPARE(w1.windowHandle()->maximumSize(), maxSize); +} + void tst_QWidget_window::tst_move_show() { QWidget w; |