diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-27 08:43:10 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-02-27 08:43:10 +0100 |
commit | bb7a5d0cb6e62fa411e8b66759bf6b798c3f68d9 (patch) | |
tree | 06c325dc386afd26281ba0ebdbf4fd3f56f892b0 /tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp | |
parent | 41edb3bd9f373a865d5698ac8c18bf341071eae9 (diff) | |
parent | e41d067227eb6225b05df88ab724708588fa5304 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4internalclass.cpp
src/qml/parser/qqmljslexer.cpp
src/qml/qml/v8/qv8engine.cpp
src/qml/util/qqmladaptormodel_p.h
src/quick/items/qquickanimatedsprite.cpp
tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
Change-Id: I16702b7a0da29c2a332afee47728d6a6ebf4fb3f
Diffstat (limited to 'tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp')
-rw-r--r-- | tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index fb5201946a..4ca31fd957 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> @@ -53,6 +54,7 @@ private slots: void test_reparenting(); void test_changeSourceToSmallerImgKeepingBigFrameSize(); void test_infiniteLoops(); + void test_implicitSize(); }; void tst_qquickanimatedsprite::initTestCase() @@ -63,11 +65,11 @@ void tst_qquickanimatedsprite::initTestCase() void tst_qquickanimatedsprite::test_properties() { - QQuickView *window = new QQuickView(0); + 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"); @@ -87,17 +89,15 @@ void tst_qquickanimatedsprite::test_properties() QCOMPARE(finishedSpy.count(), 0); sprite->setInterpolate(false); QVERIFY(!sprite->interpolate()); - - delete window; } void tst_qquickanimatedsprite::test_runningChangedSignal() { - QQuickView *window = new QQuickView(0); + 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"); @@ -115,8 +115,6 @@ void tst_qquickanimatedsprite::test_runningChangedSignal() QTRY_VERIFY(!sprite->running()); QTRY_COMPARE(runningChangedSpy.count(), 2); QCOMPARE(finishedSpy.count(), 1); - - delete window; } template <typename T> @@ -128,7 +126,7 @@ static bool isWithinRange(T min, T value, T max) void tst_qquickanimatedsprite::test_frameChangedSignal() { - QQuickView *window = new QQuickView(0); + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("frameChange.qml")); window->show(); @@ -137,7 +135,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()); @@ -165,8 +163,6 @@ void tst_qquickanimatedsprite::test_frameChangedSignal() prevFrame = frame; } QCOMPARE(loopCounter, 3); - - delete window; } void tst_qquickanimatedsprite::test_largeAnimation_data() @@ -225,11 +221,11 @@ void tst_qquickanimatedsprite::test_largeAnimation() { QFETCH(bool, frameSync); - QQuickView *window = new QQuickView(0); + 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"); @@ -275,7 +271,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() @@ -290,7 +285,7 @@ void tst_qquickanimatedsprite::test_reparenting() QVERIFY(sprite); QTRY_VERIFY(sprite->running()); - sprite->setParentItem(0); + sprite->setParentItem(nullptr); sprite->setParentItem(window.rootObject()); // don't crash (QTBUG-51162) @@ -324,7 +319,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. @@ -333,7 +328,44 @@ void tst_qquickanimatedsprite::test_changeSourceToSmallerImgKeepingBigFrameSize( killer->terminate(); killer->wait(); - delete killer; +} + +void tst_qquickanimatedsprite::test_implicitSize() +{ + QQuickView window; + window.setSource(testFileUrl("basic.qml")); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QVERIFY(window.rootObject()); + + QQuickAnimatedSprite* sprite = window.rootObject()->findChild<QQuickAnimatedSprite*>("sprite"); + QVERIFY(sprite); + QCOMPARE(sprite->frameWidth(), 31); + QCOMPARE(sprite->frameHeight(), 30); + QCOMPARE(sprite->implicitWidth(), 31); + QCOMPARE(sprite->implicitHeight(), 30); + + // Ensure that implicitWidth matches frameWidth. + QSignalSpy frameWidthChangedSpy(sprite, SIGNAL(frameWidthChanged(int))); + QVERIFY(frameWidthChangedSpy.isValid()); + + QSignalSpy frameImplicitWidthChangedSpy(sprite, SIGNAL(implicitWidthChanged())); + QVERIFY(frameImplicitWidthChangedSpy.isValid()); + + sprite->setFrameWidth(20); + QCOMPARE(frameWidthChangedSpy.count(), 1); + QCOMPARE(frameImplicitWidthChangedSpy.count(), 1); + + // Ensure that implicitHeight matches frameHeight. + QSignalSpy frameHeightChangedSpy(sprite, SIGNAL(frameHeightChanged(int))); + QVERIFY(frameHeightChangedSpy.isValid()); + + QSignalSpy frameImplicitHeightChangedSpy(sprite, SIGNAL(implicitHeightChanged())); + QVERIFY(frameImplicitHeightChangedSpy.isValid()); + + sprite->setFrameHeight(20); + QCOMPARE(frameHeightChangedSpy.count(), 1); + QCOMPARE(frameImplicitHeightChangedSpy.count(), 1); } void tst_qquickanimatedsprite::test_infiniteLoops() |