diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp | 32 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp | 24 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp | 32 | ||||
-rw-r--r-- | tests/manual/qlayout/gridwidget.cpp | 8 | ||||
-rw-r--r-- | tests/manual/qlayout/hbwidget.cpp | 8 | ||||
-rw-r--r-- | tests/manual/qlayout/vbwidget.cpp | 8 |
6 files changed, 112 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 850bedd9cc..4167d633b0 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -79,6 +79,8 @@ private slots: void taskQTBUG_7103_minMaxWidthNotRespected(); void taskQTBUG_27420_takeAtShouldUnparentLayout(); + void taskQTBUG_40609_addingWidgetToItsOwnLayout(); + void taskQTBUG_40609_addingLayoutToItself(); void replaceWidget(); }; @@ -329,6 +331,36 @@ void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout() QVERIFY(!inner.isNull()); } +void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){ + QWidget widget; + widget.setObjectName("347b469225a24a0ef05150a"); + QVBoxLayout layout(&widget); + layout.setObjectName("ef9e2b42298e0e6420105bb"); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null widget to QVBoxLayout/ef9e2b42298e0e6420105bb"); + layout.addWidget(Q_NULLPTR); + QCOMPARE(layout.count(), 0); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add parent widget QWidget/347b469225a24a0ef05150a to its child layout QVBoxLayout/ef9e2b42298e0e6420105bb"); + layout.addWidget(&widget); + QCOMPARE(layout.count(), 0); +} + +void tst_QBoxLayout::taskQTBUG_40609_addingLayoutToItself(){ + QWidget widget; + widget.setObjectName("fe44e5cb6c08006597126a"); + QVBoxLayout layout(&widget); + layout.setObjectName("cc751dd0f50f62b05a62da"); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null layout to QVBoxLayout/cc751dd0f50f62b05a62da"); + layout.addLayout(Q_NULLPTR); + QCOMPARE(layout.count(), 0); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add layout QVBoxLayout/cc751dd0f50f62b05a62da to itself"); + layout.addLayout(&layout); + QCOMPARE(layout.count(), 0); +} + struct Descr { Descr(int min, int sh, int max = -1, bool exp= false, int _stretch = 0, bool _empty = false) diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index 9df7e1662d..962e472606 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -135,6 +135,8 @@ private slots: */ void taskQTBUG_27420_takeAtShouldUnparentLayout(); + void taskQTBUG_40609_addingWidgetToItsOwnLayout(); + void taskQTBUG_40609_addingLayoutToItself(); }; @@ -949,6 +951,28 @@ void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout() QVERIFY(!inner.isNull()); } +void tst_QFormLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){ + QWidget widget; + widget.setObjectName("6435cbada60548b4522cbb6"); + QFormLayout layout(&widget); + layout.setObjectName("c03c0e22c0b6d019a93a248"); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add parent widget QWidget/6435cbada60548b4522cbb6 to its child layout QFormLayout/c03c0e22c0b6d019a93a248"); + layout.addRow(QLatin1String("48c81f39b7320082f8"), &widget); + QCOMPARE(layout.count(), 0); +} + +void tst_QFormLayout::taskQTBUG_40609_addingLayoutToItself(){ + QWidget widget; + widget.setObjectName("2bc425637d084c07ce65956"); + QFormLayout layout(&widget); + layout.setObjectName("60e31de0c8800eaba713a4f2"); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add layout QFormLayout/60e31de0c8800eaba713a4f2 to itself"); + layout.addRow(QLatin1String("9a2cd4f40c06b489f889"), &layout); + QCOMPARE(layout.count(), 0); +} + void tst_QFormLayout::replaceWidget() { QWidget w; diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 3b7c2ac14d..0dcae2fbcc 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -101,6 +101,8 @@ private slots: void distributeMultiCell(); void taskQTBUG_27420_takeAtShouldUnparentLayout(); + void taskQTBUG_40609_addingWidgetToItsOwnLayout(); + void taskQTBUG_40609_addingLayoutToItself(); void replaceWidget(); private: @@ -1660,6 +1662,36 @@ void tst_QGridLayout::taskQTBUG_27420_takeAtShouldUnparentLayout() QVERIFY(!inner.isNull()); } +void tst_QGridLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){ + QWidget widget; + widget.setObjectName("9bb37ca762aeb7269b8"); + QGridLayout layout(&widget); + layout.setObjectName("d631e91a35f2b66a6dff35"); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null widget to QGridLayout/d631e91a35f2b66a6dff35"); + layout.addWidget(Q_NULLPTR, 0, 0); + QCOMPARE(layout.count(), 0); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add parent widget QWidget/9bb37ca762aeb7269b8 to its child layout QGridLayout/d631e91a35f2b66a6dff35"); + layout.addWidget(&widget, 0, 0); + QCOMPARE(layout.count(), 0); +} + +void tst_QGridLayout::taskQTBUG_40609_addingLayoutToItself(){ + QWidget widget; + widget.setObjectName("0373d417fffe2c59c6fe543"); + QGridLayout layout(&widget); + layout.setObjectName("5d79e1b0aed83f100e3c2"); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null layout to QGridLayout/5d79e1b0aed83f100e3c2"); + layout.addLayout(Q_NULLPTR, 0, 0); + QCOMPARE(layout.count(), 0); + + QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add layout QGridLayout/5d79e1b0aed83f100e3c2 to itself"); + layout.addLayout(&layout, 0, 0); + QCOMPARE(layout.count(), 0); +} + void tst_QGridLayout::replaceWidget() { QWidget wdg; diff --git a/tests/manual/qlayout/gridwidget.cpp b/tests/manual/qlayout/gridwidget.cpp index 31f0094182..6d7de3c763 100644 --- a/tests/manual/qlayout/gridwidget.cpp +++ b/tests/manual/qlayout/gridwidget.cpp @@ -53,6 +53,7 @@ GridWidget::GridWidget(QWidget *parent) : QWidget(parent) { QGridLayout *hb = new QGridLayout(this); + hb->setObjectName("GridWidget"); QComboBox *combo = new QComboBox(); combo->addItem("123"); QComboBox *combo2 = new QComboBox(); @@ -71,4 +72,11 @@ GridWidget::GridWidget(QWidget *parent) : hb->addWidget(new QPushButton("123"), 1, 4); hb->addWidget(new QSpinBox(), 0, 5); hb->addWidget(new QSpinBox(), 1, 5); + + qDebug("There should be four warnings, but no crash or freeze:"); + hb->addWidget(this, 6, 6); ///< This command should print a warning, but should not add "this" + hb->addWidget(Q_NULLPTR, 6, 7); ///< This command should print a warning, but should not add "NULL" + hb->addLayout(hb, 7, 6); ///< This command should print a warning, but should not add "hb" + hb->addLayout(Q_NULLPTR, 7, 7); ///< This command should print a warning, but should not add "NULL" + qDebug("Neither crashed nor frozen"); } diff --git a/tests/manual/qlayout/hbwidget.cpp b/tests/manual/qlayout/hbwidget.cpp index e8bb07f4a4..743b420b0d 100644 --- a/tests/manual/qlayout/hbwidget.cpp +++ b/tests/manual/qlayout/hbwidget.cpp @@ -53,6 +53,7 @@ HbWidget::HbWidget(QWidget *parent) : QWidget(parent) { QHBoxLayout *hb = new QHBoxLayout(this); + hb->setObjectName("HbWidget"); QComboBox *combo = new QComboBox(this); combo->addItem("123"); QComboBox *combo2 = new QComboBox(); @@ -67,4 +68,11 @@ HbWidget::HbWidget(QWidget *parent) : hb->addWidget(new QDateTimeEdit()); hb->addWidget(new QPushButton("123")); hb->addWidget(new QSpinBox()); + + qDebug("There should be four warnings, but no crash or freeze:"); + hb->addWidget(this); ///< This command should print a warning, but should not add "this" + hb->addWidget(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL" + hb->addLayout(hb); ///< This command should print a warning, but should not add "hb" + hb->addLayout(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL" + qDebug("Neither crashed nor frozen"); } diff --git a/tests/manual/qlayout/vbwidget.cpp b/tests/manual/qlayout/vbwidget.cpp index 063176625d..ffd918b955 100644 --- a/tests/manual/qlayout/vbwidget.cpp +++ b/tests/manual/qlayout/vbwidget.cpp @@ -53,6 +53,7 @@ VbWidget::VbWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *hb = new QVBoxLayout(this); + hb->setObjectName("VbWidget"); QComboBox *combo = new QComboBox(this); combo->addItem("123"); QComboBox *combo2 = new QComboBox(); @@ -67,4 +68,11 @@ VbWidget::VbWidget(QWidget *parent) : hb->addWidget(new QDateTimeEdit()); hb->addWidget(new QPushButton("123")); hb->addWidget(new QSpinBox()); + + qDebug("There should be four warnings, but no crash or freeze:"); + hb->addWidget(this); ///< This command should print a warning, but should not add "this" + hb->addWidget(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL" + hb->addLayout(hb); ///< This command should print a warning, but should not add "hb" + hb->addLayout(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL" + qDebug("Neither crashed nor frozen"); } |