diff options
Diffstat (limited to 'tests/auto/quick/qquickanimatedimage')
-rw-r--r-- | tests/auto/quick/qquickanimatedimage/data/colors_nocache.qml | 6 | ||||
-rw-r--r-- | tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp | 34 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimatedimage/data/colors_nocache.qml b/tests/auto/quick/qquickanimatedimage/data/colors_nocache.qml new file mode 100644 index 0000000000..24adca68ec --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/colors_nocache.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +AnimatedImage { + source: "colors.gif" + cache: false +} diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index ee38a0e8ff..c42000d418 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -70,6 +70,7 @@ private slots: void qtbug_16520(); void progressAndStatusChanges(); void playingAndPausedChanges(); + void noCaching(); }; void tst_qquickanimatedimage::cleanup() @@ -528,6 +529,39 @@ void tst_qquickanimatedimage::playingAndPausedChanges() delete obj; } + +void tst_qquickanimatedimage::noCaching() +{ + QQuickView window, window_nocache; + window.setSource(testFileUrl("colors.qml")); + window_nocache.setSource(testFileUrl("colors_nocache.qml")); + window.show(); + window_nocache.show(); + QTest::qWaitForWindowExposed(&window); + QTest::qWaitForWindowExposed(&window_nocache); + + QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(window.rootObject()); + QVERIFY(anim); + + QQuickAnimatedImage *anim_nocache = qobject_cast<QQuickAnimatedImage *>(window_nocache.rootObject()); + QVERIFY(anim_nocache); + + QCOMPARE(anim->frameCount(), anim_nocache->frameCount()); + + // colors.gif only has 3 frames so this should be fast + for (int loops = 0; loops <= 2; ++loops) { + for (int frame = 0; frame < anim->frameCount(); ++frame) { + anim->setCurrentFrame(frame); + anim_nocache->setCurrentFrame(frame); + + QImage image_cache = window.grabWindow(); + QImage image_nocache = window_nocache.grabWindow(); + + QCOMPARE(image_cache, image_nocache); + } + } +} + QTEST_MAIN(tst_qquickanimatedimage) #include "tst_qquickanimatedimage.moc" |