aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-02-26 11:04:02 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-02-26 14:39:23 +0000
commit18615b6216f0f6b1d5e8eef3ad2013fd87a3bc40 (patch)
treea81e1012e2f9847b64b996d34ca93601088601d8 /tests/auto/quick
parentdb15c3455971f47b86078a44a30e0f0a13b54204 (diff)
tst_qquickanimatedsprite: use QScopedPointer
Change-Id: Ib0e0cccef197fb8c5fa163c7a57f096e8fcb8c25 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
index 71659754b0..368779f52f 100644
--- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -31,6 +31,7 @@
#include <private/qabstractanimation_p.h>
#include <private/qquickanimatedsprite_p.h>
#include <private/qquickitem_p.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qpainter.h>
#include <QtGui/qopenglcontext.h>
#include <QtGui/qopenglfunctions.h>
@@ -62,11 +63,11 @@ void tst_qquickanimatedsprite::initTestCase()
void tst_qquickanimatedsprite::test_properties()
{
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("basic.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject());
QQuickAnimatedSprite* sprite = window->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
@@ -81,17 +82,15 @@ void tst_qquickanimatedsprite::test_properties()
QVERIFY(!sprite->running());
sprite->setInterpolate(false);
QVERIFY(!sprite->interpolate());
-
- delete window;
}
void tst_qquickanimatedsprite::test_runningChangedSignal()
{
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("runningChange.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject());
QQuickAnimatedSprite* sprite = window->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
@@ -104,8 +103,6 @@ void tst_qquickanimatedsprite::test_runningChangedSignal()
QTRY_COMPARE(runningChangedSpy.count(), 1);
QTRY_VERIFY(!sprite->running());
QTRY_COMPARE(runningChangedSpy.count(), 2);
-
- delete window;
}
template <typename T>
@@ -117,7 +114,7 @@ static bool isWithinRange(T min, T value, T max)
void tst_qquickanimatedsprite::test_frameChangedSignal()
{
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("frameChange.qml"));
window->show();
@@ -126,7 +123,7 @@ void tst_qquickanimatedsprite::test_frameChangedSignal()
QQuickAnimatedSprite* sprite = window->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
QSignalSpy frameChangedSpy(sprite, SIGNAL(currentFrameChanged(int)));
QVERIFY(sprite);
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(!sprite->running());
QVERIFY(!sprite->paused());
@@ -154,8 +151,6 @@ void tst_qquickanimatedsprite::test_frameChangedSignal()
prevFrame = frame;
}
QCOMPARE(loopCounter, 3);
-
- delete window;
}
void tst_qquickanimatedsprite::test_largeAnimation_data()
@@ -214,11 +209,11 @@ void tst_qquickanimatedsprite::test_largeAnimation()
{
QFETCH(bool, frameSync);
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView);
window->engine()->addImageProvider(QLatin1String("test"), new AnimationImageProvider);
window->setSource(testFileUrl("largeAnimation.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject());
QQuickAnimatedSprite* sprite = window->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
@@ -264,7 +259,6 @@ void tst_qquickanimatedsprite::test_largeAnimation()
maxTextureSize /= 512;
QVERIFY(maxFrame > maxTextureSize); // make sure we go beyond the texture width limitation
QCOMPARE(loopCounter, sprite->loops());
- delete window;
}
void tst_qquickanimatedsprite::test_reparenting()
@@ -313,7 +307,7 @@ void tst_qquickanimatedsprite::test_changeSourceToSmallerImgKeepingBigFrameSize(
QQmlProperty big(sprite, "big");
big.write(QVariant::fromValue(false));
- KillerThread *killer = new KillerThread;
+ QScopedPointer<KillerThread> killer(new KillerThread);
killer->start(); // will kill us in case the GUI or render thread enters an infinite loop
QTest::qWait(50); // let it draw with the new source.
@@ -322,7 +316,6 @@ void tst_qquickanimatedsprite::test_changeSourceToSmallerImgKeepingBigFrameSize(
killer->terminate();
killer->wait();
- delete killer;
}
QTEST_MAIN(tst_qquickanimatedsprite)