aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-04-07 10:33:03 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-04-07 08:57:54 +0000
commit5eef1ef32980df512a638b228a3ae48b30095dd8 (patch)
tree3a497f88f006631ae15c6f8fd5a972e2b08aa4b3
parent0b65974ba160680945836374407e80d542caeb44 (diff)
tst_qquicktext: Ensure windows are cleaned up on test failure.
Use a QScopedPointer to guard them. Task-number: QTBUG-51934 Change-Id: I622fe782e0bd232cb1cc6ffc16499830b94334f2 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp42
1 files changed, 17 insertions, 25 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index d163ee785e..0a79fe8de3 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -59,6 +59,7 @@ public:
tst_qquicktext();
private slots:
+ void cleanup();
void text();
void width();
void wrap();
@@ -167,6 +168,11 @@ private:
int numberOfNonWhitePixels(int fromX, int toX, const QImage &image);
};
+void tst_qquicktext::cleanup()
+{
+ QVERIFY(QGuiApplication::topLevelWindows().isEmpty());
+}
+
tst_qquicktext::tst_qquicktext()
{
standard << "the quick brown fox jumped over the lazy dog"
@@ -549,7 +555,7 @@ void tst_qquicktext::multilineElide_data()
void tst_qquicktext::multilineElide()
{
QFETCH(QQuickText::TextFormat, format);
- QQuickView *window = createView(testFile("multilineelide.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("multilineelide.qml")));
QQuickText *myText = qobject_cast<QQuickText*>(window->rootObject());
QVERIFY(myText != 0);
@@ -593,8 +599,6 @@ void tst_qquicktext::multilineElide()
// change line height
myText->setLineHeight(1.1);
QCOMPARE(myText->lineCount(), 1);
-
- delete window;
}
void tst_qquicktext::implicitElide_data()
@@ -756,7 +760,7 @@ void tst_qquicktext::horizontalAlignment_RightToLeft()
dummy.showFullScreen(); // so make test window a second window.
#endif
- QQuickView *window = createView(testFile("horizontalAlignment_RightToLeft.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("horizontalAlignment_RightToLeft.qml")));
QQuickText *text = window->rootObject()->findChild<QQuickText*>("text");
QVERIFY(text != 0);
window->showNormal();
@@ -859,7 +863,7 @@ void tst_qquicktext::horizontalAlignment_RightToLeft()
text->setHAlign(QQuickText::AlignRight);
QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- delete window;
+ window.reset();
// alignment of Text with no text set to it
QString componentStr = "import QtQuick 2.0\nText {}";
@@ -2098,7 +2102,7 @@ void tst_qquicktext::embeddedImages()
void tst_qquicktext::lineCount()
{
- QQuickView *window = createView(testFile("lineCount.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("lineCount.qml")));
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
@@ -2121,13 +2125,11 @@ void tst_qquicktext::lineCount()
QCOMPARE(myText->lineCount(), 2);
QCOMPARE(myText->truncated(), true);
QCOMPARE(myText->maximumLineCount(), 2);
-
- delete window;
}
void tst_qquicktext::lineHeight()
{
- QQuickView *window = createView(testFile("lineHeight.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("lineHeight.qml")));
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
@@ -2154,8 +2156,6 @@ void tst_qquicktext::lineHeight()
myText->setLineHeightMode(QQuickText::FixedHeight);
myText->setLineHeight(10);
QCOMPARE(myText->height(), myText->lineCount() * 10.0);
-
- delete window;
}
void tst_qquicktext::implicitSize_data()
@@ -2727,7 +2727,7 @@ void tst_qquicktext::clipRect()
void tst_qquicktext::lineLaidOut()
{
- QQuickView *window = createView(testFile("lineLayout.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("lineLayout.qml")));
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
@@ -2747,17 +2747,15 @@ void tst_qquicktext::lineLaidOut()
QCOMPARE(r.height(), qreal(20));
}
}
-
- delete window;
}
void tst_qquicktext::lineLaidOutRelayout()
{
- QQuickView *window = createView(testFile("lineLayoutRelayout.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("lineLayoutRelayout.qml")));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
@@ -2780,13 +2778,11 @@ void tst_qquicktext::lineLaidOutRelayout()
QCOMPARE(r.y(), i * h - maxH);
}
}
-
- delete window;
}
void tst_qquicktext::lineLaidOutHAlign()
{
- QQuickView *window = createView(testFile("lineLayoutHAlign.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("lineLayoutHAlign.qml")));
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
@@ -2797,8 +2793,6 @@ void tst_qquicktext::lineLaidOutHAlign()
QCOMPARE(textPrivate->layout.lineCount(), 1);
QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().x() < 0.0);
-
- delete window;
}
void tst_qquicktext::imgTagsBaseUrl_data()
@@ -2958,7 +2952,7 @@ void tst_qquicktext::imgTagsMultipleImages()
void tst_qquicktext::imgTagsElide()
{
- QQuickView *window = createView(testFile("imgTagsElide.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("imgTagsElide.qml")));
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
@@ -2969,12 +2963,11 @@ void tst_qquicktext::imgTagsElide()
QTRY_COMPARE(textPrivate->extra->visibleImgTags.count(), 1);
delete myText;
- delete window;
}
void tst_qquicktext::imgTagsUpdates()
{
- QQuickView *window = createView(testFile("imgTagsUpdates.qml"));
+ QScopedPointer<QQuickView> window(createView(testFile("imgTagsUpdates.qml")));
QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
@@ -2996,7 +2989,6 @@ void tst_qquicktext::imgTagsUpdates()
QCOMPARE(spy.count(), 3);
delete myText;
- delete window;
}
void tst_qquicktext::imgTagsError()