mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42:55 +00:00
plug QBoxLayout test leaks
upstream commit:
e849e2c162
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
07a200860c
commit
802994db4f
1 changed files with 21 additions and 25 deletions
|
@ -122,7 +122,7 @@ void tst_QBoxLayout::cleanup()
|
||||||
|
|
||||||
void tst_QBoxLayout::insertSpacerItem()
|
void tst_QBoxLayout::insertSpacerItem()
|
||||||
{
|
{
|
||||||
QWidget *window = new QWidget;
|
QWidget window;
|
||||||
|
|
||||||
QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
@ -132,18 +132,18 @@ void tst_QBoxLayout::insertSpacerItem()
|
||||||
layout->addSpacerItem(spacer1);
|
layout->addSpacerItem(spacer1);
|
||||||
layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar"));
|
layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar"));
|
||||||
layout->insertSpacerItem(0, spacer2);
|
layout->insertSpacerItem(0, spacer2);
|
||||||
window->setLayout(layout);
|
window.setLayout(layout);
|
||||||
|
|
||||||
QVERIFY(layout->itemAt(0) == spacer2);
|
QVERIFY(layout->itemAt(0) == spacer2);
|
||||||
QVERIFY(layout->itemAt(2) == spacer1);
|
QVERIFY(layout->itemAt(2) == spacer1);
|
||||||
|
|
||||||
window->show();
|
window.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QBoxLayout::insertLayout()
|
void tst_QBoxLayout::insertLayout()
|
||||||
{
|
{
|
||||||
QWidget *window = new QWidget;
|
QWidget window;
|
||||||
QVBoxLayout *vbox = new QVBoxLayout(window);
|
QVBoxLayout *vbox = new QVBoxLayout(&window);
|
||||||
QVBoxLayout *dummyParentLayout = new QVBoxLayout;
|
QVBoxLayout *dummyParentLayout = new QVBoxLayout;
|
||||||
QHBoxLayout *subLayout = new QHBoxLayout;
|
QHBoxLayout *subLayout = new QHBoxLayout;
|
||||||
dummyParentLayout->addLayout(subLayout);
|
dummyParentLayout->addLayout(subLayout);
|
||||||
|
@ -156,20 +156,19 @@ void tst_QBoxLayout::insertLayout()
|
||||||
QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));
|
QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));
|
||||||
|
|
||||||
delete dummyParentLayout;
|
delete dummyParentLayout;
|
||||||
delete window;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tst_QBoxLayout::sizeHint()
|
void tst_QBoxLayout::sizeHint()
|
||||||
{
|
{
|
||||||
QWidget *window = new QWidget;
|
QWidget window;
|
||||||
QHBoxLayout *lay1 = new QHBoxLayout;
|
QHBoxLayout *lay1 = new QHBoxLayout;
|
||||||
QHBoxLayout *lay2 = new QHBoxLayout;
|
QHBoxLayout *lay2 = new QHBoxLayout;
|
||||||
QLabel *label = new QLabel("widget twooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
|
QLabel *label = new QLabel("widget twooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
|
||||||
lay2->addWidget(label);
|
lay2->addWidget(label);
|
||||||
lay1->addLayout(lay2);
|
lay1->addLayout(lay2);
|
||||||
window->setLayout(lay1);
|
window.setLayout(lay1);
|
||||||
window->show();
|
window.show();
|
||||||
label->setText("foooooooo baaaaaaar");
|
label->setText("foooooooo baaaaaaar");
|
||||||
QSize sh = lay1->sizeHint();
|
QSize sh = lay1->sizeHint();
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
@ -182,18 +181,18 @@ void tst_QBoxLayout::sizeHint()
|
||||||
|
|
||||||
void tst_QBoxLayout::sizeConstraints()
|
void tst_QBoxLayout::sizeConstraints()
|
||||||
{
|
{
|
||||||
QWidget *window = new QWidget;
|
QWidget window;
|
||||||
QHBoxLayout *lay = new QHBoxLayout;
|
QHBoxLayout *lay = new QHBoxLayout;
|
||||||
lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo"));
|
lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo"));
|
||||||
lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"));
|
lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"));
|
||||||
lay->setSizeConstraint(QLayout::SetFixedSize);
|
lay->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
window->setLayout(lay);
|
window.setLayout(lay);
|
||||||
window->show();
|
window.show();
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
QSize sh = window->sizeHint();
|
QSize sh = window.sizeHint();
|
||||||
lay->takeAt(1);
|
lay->takeAt(1);
|
||||||
QVERIFY(sh.width() >= window->sizeHint().width() &&
|
QVERIFY(sh.width() >= window.sizeHint().width() &&
|
||||||
sh.height() >= window->sizeHint().height());
|
sh.height() >= window.sizeHint().height());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,33 +224,30 @@ void tst_QBoxLayout::setGeometry()
|
||||||
void tst_QBoxLayout::setStyleShouldChangeSpacing()
|
void tst_QBoxLayout::setStyleShouldChangeSpacing()
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_STYLE_WINDOWS
|
#ifndef QT_NO_STYLE_WINDOWS
|
||||||
QWidget *window = new QWidget;
|
QWidget window;
|
||||||
QHBoxLayout *hbox = new QHBoxLayout(window);
|
QHBoxLayout *hbox = new QHBoxLayout(&window);
|
||||||
QPushButton *pb1 = new QPushButton(tr("The spacing between this"));
|
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"));;
|
QPushButton *pb2 = new QPushButton(tr("and this button should depend on the style of the parent widget"));;
|
||||||
pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||||
pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||||
hbox->addWidget(pb1);
|
hbox->addWidget(pb1);
|
||||||
hbox->addWidget(pb2);
|
hbox->addWidget(pb2);
|
||||||
CustomLayoutStyle *style1 = new CustomLayoutStyle;
|
QScopedPointer<CustomLayoutStyle> style1(new CustomLayoutStyle());
|
||||||
style1->hspacing = 6;
|
style1->hspacing = 6;
|
||||||
window->setStyle(style1);
|
window.setStyle(style1.data());
|
||||||
window->show();
|
window.show();
|
||||||
|
|
||||||
QTest::qWait(100);
|
QTest::qWait(100);
|
||||||
int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
|
int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
|
||||||
QCOMPARE(spacing, 6);
|
QCOMPARE(spacing, 6);
|
||||||
|
|
||||||
CustomLayoutStyle *style2 = new CustomLayoutStyle();
|
QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle());
|
||||||
style2->hspacing = 10;
|
style2->hspacing = 10;
|
||||||
window->setStyle(style2);
|
window.setStyle(style2.data());
|
||||||
QTest::qWait(100);
|
QTest::qWait(100);
|
||||||
spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
|
spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
|
||||||
QCOMPARE(spacing, 10);
|
QCOMPARE(spacing, 10);
|
||||||
|
|
||||||
delete window;
|
|
||||||
delete style1;
|
|
||||||
delete style2;
|
|
||||||
#else // QT_NO_STYLE_WINDOWS
|
#else // QT_NO_STYLE_WINDOWS
|
||||||
QSKIP("Katie compiled without windows style support (QT_NO_STYLE_WINDOWS)", SkipAll);
|
QSKIP("Katie compiled without windows style support (QT_NO_STYLE_WINDOWS)", SkipAll);
|
||||||
#endif // QT_NO_STYLE_WINDOWS
|
#endif // QT_NO_STYLE_WINDOWS
|
||||||
|
|
Loading…
Add table
Reference in a new issue