From 0bfcb67886df2c446b38c4ca0ec8309a32493d00 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 7 Apr 2010 13:26:59 +1000 Subject: Make sure tests cleanup after themselves. --- .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 18 ++++++++-- .../tst_qdeclarativerepeater.cpp | 10 ++++++ .../tst_qdeclarativetextinput.cpp | 42 ++++++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 05d968c..abdd210 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -133,7 +133,7 @@ void tst_QDeclarativeLoader::component() QVERIFY(c); QCOMPARE(loader->sourceComponent(), c); - delete loader; + delete item; } void tst_QDeclarativeLoader::invalidUrl() @@ -196,7 +196,7 @@ void tst_QDeclarativeLoader::clear() QCOMPARE(loader->status(), QDeclarativeLoader::Null); QCOMPARE(static_cast(loader)->children().count(), 0); - delete loader; + delete item; } } @@ -242,7 +242,7 @@ void tst_QDeclarativeLoader::componentToUrl() QCOMPARE(loader->width(), 120.0); QCOMPARE(loader->height(), 60.0); - delete loader; + delete item; } void tst_QDeclarativeLoader::sizeLoaderToItem() @@ -275,6 +275,8 @@ void tst_QDeclarativeLoader::sizeLoaderToItem() QCOMPARE(spy.count(),1); loader->setResizeMode(QDeclarativeLoader::NoResize); QCOMPARE(spy.count(),1); + + delete loader; } void tst_QDeclarativeLoader::sizeItemToLoader() @@ -303,6 +305,8 @@ void tst_QDeclarativeLoader::sizeItemToLoader() rect->setHeight(45); QCOMPARE(loader->width(), 160.0); QCOMPARE(loader->height(), 45.0); + + delete loader; } void tst_QDeclarativeLoader::noResize() @@ -317,6 +321,8 @@ void tst_QDeclarativeLoader::noResize() QVERIFY(rect); QCOMPARE(rect->width(), 120.0); QCOMPARE(rect->height(), 60.0); + + delete loader; } void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() @@ -344,6 +350,8 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() loader->setHeight(30); QCOMPARE(widget->size().width(), 180.0); QCOMPARE(widget->size().height(), 30.0); + + delete loader; } void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() @@ -374,6 +382,8 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() widget->resize(QSizeF(160,45)); QCOMPARE(loader->width(), 160.0); QCOMPARE(loader->height(), 45.0); + + delete loader; } void tst_QDeclarativeLoader::noResizeGraphicsWidget() @@ -391,6 +401,8 @@ void tst_QDeclarativeLoader::noResizeGraphicsWidget() QVERIFY(widget); QCOMPARE(widget->size().width(), 250.0); QCOMPARE(widget->size().height(), 250.0); + + delete loader; } void tst_QDeclarativeLoader::networkRequestUrl() diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 09c4879..419f5ea 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -181,6 +181,7 @@ void tst_QDeclarativeRepeater::numberModel() QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); + delete testObject; delete canvas; } @@ -204,6 +205,9 @@ void tst_QDeclarativeRepeater::objectList() QVERIFY(repeater != 0); QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data QCOMPARE(repeater->property("instantiated").toInt(), 100); + + qDeleteAll(data); + delete canvas; } /* @@ -293,6 +297,9 @@ void tst_QDeclarativeRepeater::dataModel() testModel.removeItem(2); QCOMPARE(container->childItems().count(), 4); + + delete testObject; + delete canvas; } void tst_QDeclarativeRepeater::itemModel() @@ -323,6 +330,7 @@ void tst_QDeclarativeRepeater::itemModel() QVERIFY(qobject_cast(container->childItems().at(2))->objectName() == "item3"); QVERIFY(container->childItems().at(3) == repeater); + delete testObject; delete canvas; } @@ -352,6 +360,8 @@ void tst_QDeclarativeRepeater::properties() QCOMPARE(delegateSpy.count(),1); repeater->setDelegate(&rectComponent); QCOMPARE(delegateSpy.count(),1); + + delete rootObject; } QDeclarativeView *tst_QDeclarativeRepeater::createView() diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index b6f55dd..2b0b151 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -112,6 +112,8 @@ void tst_qdeclarativetextinput::text() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), QString("")); + + delete textinputObject; } for (int i = 0; i < standard.size(); i++) @@ -123,6 +125,8 @@ void tst_qdeclarativetextinput::text() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), standard.at(i)); + + delete textinputObject; } } @@ -137,6 +141,8 @@ void tst_qdeclarativetextinput::width() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->width(), 1.);//1 for the cursor + + delete textinputObject; } for (int i = 0; i < standard.size(); i++) @@ -152,6 +158,8 @@ void tst_qdeclarativetextinput::width() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor + + delete textinputObject; } } @@ -168,6 +176,8 @@ void tst_qdeclarativetextinput::font() QCOMPARE(textinputObject->font().pointSize(), 40); QCOMPARE(textinputObject->font().bold(), false); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -179,6 +189,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().bold(), true); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -190,6 +202,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().italic(), true); QCOMPARE(textinputObject->font().bold(), false); + + delete textinputObject; } { @@ -202,6 +216,8 @@ void tst_qdeclarativetextinput::font() QCOMPARE(textinputObject->font().family(), QString("Helvetica")); QCOMPARE(textinputObject->font().bold(), false); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -212,6 +228,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().family(), QString("")); + + delete textinputObject; } } @@ -226,6 +244,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); + + delete textinputObject; } //test selection color @@ -237,6 +257,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); + + delete textinputObject; } //test selected text color @@ -248,6 +270,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); + + delete textinputObject; } { @@ -262,6 +286,8 @@ void tst_qdeclarativetextinput::color() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), testColor); + + delete textinputObject; } } @@ -344,6 +370,8 @@ void tst_qdeclarativetextinput::selection() QVERIFY(textinputObject->selectedText().size() == 10); textinputObject->setSelectionEnd(100); QVERIFY(textinputObject->selectedText().size() == 10); + + delete textinputObject; } void tst_qdeclarativetextinput::maxLength() @@ -371,6 +399,8 @@ void tst_qdeclarativetextinput::maxLength() QTest::keyPress(canvas, Qt::Key_A); QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); } + + delete canvas; } void tst_qdeclarativetextinput::masks() @@ -393,6 +423,8 @@ void tst_qdeclarativetextinput::masks() QTest::keyPress(canvas, Qt::Key_A); QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); } + + delete canvas; } void tst_qdeclarativetextinput::validators() @@ -485,6 +517,8 @@ void tst_qdeclarativetextinput::validators() QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); QCOMPARE(strInput->text(), QLatin1String("aaaa")); QCOMPARE(strInput->hasAcceptableInput(), true); + + delete canvas; } void tst_qdeclarativetextinput::inputMethodHints() @@ -499,6 +533,8 @@ void tst_qdeclarativetextinput::inputMethodHints() QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly); + + delete canvas; } /* @@ -536,6 +572,8 @@ void tst_qdeclarativetextinput::navigation() QVERIFY(input->hasFocus() == false); simulateKey(canvas, Qt::Key_Left); QVERIFY(input->hasFocus() == true); + + delete canvas; } void tst_qdeclarativetextinput::cursorDelegate() @@ -563,6 +601,8 @@ void tst_qdeclarativetextinput::cursorDelegate() //Test Delegate gets deleted textInputObject->setCursorDelegate(0); QVERIFY(!textInputObject->findChild("cursorInstance")); + + delete view; } void tst_qdeclarativetextinput::readOnly() @@ -585,6 +625,8 @@ void tst_qdeclarativetextinput::readOnly() simulateKey(canvas, Qt::Key_Space); simulateKey(canvas, Qt::Key_Escape); QCOMPARE(input->text(), initial); + + delete canvas; } void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key) -- cgit v0.12