summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp')
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index bdc32ba197..850bedd9cc 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -79,6 +79,7 @@ private slots:
void taskQTBUG_7103_minMaxWidthNotRespected();
void taskQTBUG_27420_takeAtShouldUnparentLayout();
+ void replaceWidget();
};
class CustomLayoutStyle : public QProxyStyle
@@ -328,7 +329,6 @@ void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
QVERIFY(!inner.isNull());
}
-
struct Descr
{
Descr(int min, int sh, int max = -1, bool exp= false, int _stretch = 0, bool _empty = false)
@@ -507,5 +507,24 @@ void tst_QBoxLayout::testLayoutEngine()
}
}
+void tst_QBoxLayout::replaceWidget()
+{
+ QWidget w;
+ QBoxLayout *boxLayout = new QVBoxLayout(&w);
+
+ QLineEdit *replaceFrom = new QLineEdit;
+ QLineEdit *replaceTo = new QLineEdit;
+ boxLayout->addWidget(new QLineEdit());
+ boxLayout->addWidget(replaceFrom);
+ boxLayout->addWidget(new QLineEdit());
+
+ QCOMPARE(boxLayout->indexOf(replaceFrom), 1);
+ QCOMPARE(boxLayout->indexOf(replaceTo), -1);
+ boxLayout->replaceWidget(replaceFrom, replaceTo);
+
+ QCOMPARE(boxLayout->indexOf(replaceFrom), -1);
+ QCOMPARE(boxLayout->indexOf(replaceTo), 1);
+}
+
QTEST_MAIN(tst_QBoxLayout)
#include "tst_qboxlayout.moc"