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.cpp103
1 files changed, 38 insertions, 65 deletions
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 35a8636f0b..aeaf1e7bf0 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -48,17 +48,8 @@ class tst_QBoxLayout : public QObject
{
Q_OBJECT
-public:
- tst_QBoxLayout();
- virtual ~tst_QBoxLayout();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+ void cleanup();
void insertSpacerItem();
void insertLayout();
void sizeHint();
@@ -120,34 +111,15 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
return QProxyStyle::pixelMetric(metric, option, widget);
}
-
-tst_QBoxLayout::tst_QBoxLayout()
-{
-}
-
-tst_QBoxLayout::~tst_QBoxLayout()
-{
-}
-
-void tst_QBoxLayout::initTestCase()
-{
-}
-
-void tst_QBoxLayout::cleanupTestCase()
-{
-}
-
-void tst_QBoxLayout::init()
-{
-}
-
void tst_QBoxLayout::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QBoxLayout::insertSpacerItem()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -157,44 +129,43 @@ void tst_QBoxLayout::insertSpacerItem()
layout->addSpacerItem(spacer1);
layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar"));
layout->insertSpacerItem(0, spacer2);
- window->setLayout(layout);
+ window.setLayout(layout);
- QVERIFY(layout->itemAt(0) == spacer2);
- QVERIFY(layout->itemAt(2) == spacer1);
+ QCOMPARE(layout->itemAt(0), spacer2);
+ QCOMPARE(layout->itemAt(2), spacer1);
- window->show();
+ window.show();
}
void tst_QBoxLayout::insertLayout()
{
- QWidget *window = new QWidget;
- QVBoxLayout *vbox = new QVBoxLayout(window);
- QVBoxLayout *dummyParentLayout = new QVBoxLayout;
+ QWidget window;
+ QVBoxLayout *vbox = new QVBoxLayout(&window);
+ QScopedPointer<QVBoxLayout> dummyParentLayout(new QVBoxLayout);
QHBoxLayout *subLayout = new QHBoxLayout;
dummyParentLayout->addLayout(subLayout);
- QCOMPARE(subLayout->parent(), dummyParentLayout);
+ QCOMPARE(subLayout->parent(), dummyParentLayout.data());
QCOMPARE(dummyParentLayout->count(), 1);
// add subLayout to another layout
QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent");
vbox->addLayout(subLayout);
QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));
-
- delete dummyParentLayout;
- delete window;
}
void tst_QBoxLayout::sizeHint()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay1 = new QHBoxLayout;
QHBoxLayout *lay2 = new QHBoxLayout;
QLabel *label = new QLabel("widget twooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
lay2->addWidget(label);
lay1->addLayout(lay2);
- window->setLayout(lay1);
- window->show();
+ window.setLayout(lay1);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
label->setText("foooooooo baaaaaaar");
QSize sh = lay1->sizeHint();
QApplication::processEvents();
@@ -207,24 +178,26 @@ void tst_QBoxLayout::sizeHint()
void tst_QBoxLayout::sizeConstraints()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay = new QHBoxLayout;
lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo"));
lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"));
lay->setSizeConstraint(QLayout::SetFixedSize);
- window->setLayout(lay);
- window->show();
- QApplication::processEvents();
- QSize sh = window->sizeHint();
+ window.setLayout(lay);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QSize sh = window.sizeHint();
lay->takeAt(1);
- QVERIFY(sh.width() >= window->sizeHint().width() &&
- sh.height() >= window->sizeHint().height());
+ QVERIFY(sh.width() >= window.sizeHint().width() &&
+ sh.height() >= window.sizeHint().height());
}
void tst_QBoxLayout::setGeometry()
{
QWidget toplevel;
+ toplevel.setWindowTitle(QTest::currentTestFunction());
setFrameless(&toplevel);
QWidget w(&toplevel);
QVBoxLayout *lay = new QVBoxLayout;
@@ -247,33 +220,30 @@ void tst_QBoxLayout::setGeometry()
void tst_QBoxLayout::setStyleShouldChangeSpacing()
{
- QWidget *window = new QWidget;
- QHBoxLayout *hbox = new QHBoxLayout(window);
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
+ QHBoxLayout *hbox = new QHBoxLayout(&window);
QPushButton *pb1 = new QPushButton(tr("The spacing between this"));
QPushButton *pb2 = new QPushButton(tr("and this button should depend on the style of the parent widget"));;
pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect);
pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect);
hbox->addWidget(pb1);
hbox->addWidget(pb2);
- CustomLayoutStyle *style1 = new CustomLayoutStyle;
+ QScopedPointer<CustomLayoutStyle> style1(new CustomLayoutStyle);
style1->hspacing = 6;
- window->setStyle(style1);
- window->show();
+ window.setStyle(style1.data());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
- QTest::qWait(100);
int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 6);
- CustomLayoutStyle *style2 = new CustomLayoutStyle();
+ QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle());
style2->hspacing = 10;
- window->setStyle(style2);
+ window.setStyle(style2.data());
QTest::qWait(100);
spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 10);
-
- delete window;
- delete style1;
- delete style2;
}
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
@@ -287,6 +257,7 @@ void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding));
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setLayout(layout);
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
@@ -325,6 +296,7 @@ void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("347b469225a24a0ef05150a");
QVBoxLayout layout(&widget);
layout.setObjectName("ef9e2b42298e0e6420105bb");
@@ -340,6 +312,7 @@ void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
void tst_QBoxLayout::taskQTBUG_40609_addingLayoutToItself(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("fe44e5cb6c08006597126a");
QVBoxLayout layout(&widget);
layout.setObjectName("cc751dd0f50f62b05a62da");