Commit 7cab011a authored by J-P Nurmi's avatar J-P Nurmi Committed by Qt by Nokia
Browse files

Fix tst_qquickanimatedimage::mirror_running()


Change-Id: I6916d90736144101b52449485b09335ac124e498
Reviewed-by: default avatarCaroline Chao <caroline.chao@nokia.com>
Reviewed-by: default avatarSergio Ahumada <sergio.ahumada@nokia.com>
parent e88f56af
No related merge requests found
Showing with 14 additions and 10 deletions
...@@ -151,41 +151,45 @@ void tst_qquickanimatedimage::mirror_running() ...@@ -151,41 +151,45 @@ void tst_qquickanimatedimage::mirror_running()
// test where mirror is set to true after animation has started // test where mirror is set to true after animation has started
QQuickView window; QQuickView window;
window.setSource(testFileUrl("hearts.qml"));
window.requestActivateWindow();
window.show(); window.show();
QTest::qWaitForWindowActive(&window);
window.setSource(testFileUrl("hearts.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(window.rootObject()); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(window.rootObject());
QVERIFY(anim); QVERIFY(anim);
int width = anim->property("width").toInt(); int width = anim->property("width").toInt();
QCOMPARE(anim->frameCount(), 2);
QCOMPARE(anim->currentFrame(), 0); QCOMPARE(anim->currentFrame(), 0);
QPixmap frame0 = QPixmap::fromImage(window.grabWindow()); QImage frame0 = window.grabWindow();
anim->setCurrentFrame(1); anim->setCurrentFrame(1);
QPixmap frame1 = QPixmap::fromImage(window.grabWindow()); QCOMPARE(anim->currentFrame(), 1);
QImage frame1 = window.grabWindow();
anim->setCurrentFrame(0); anim->setCurrentFrame(0);
QSignalSpy spy(anim, SIGNAL(frameChanged())); QSignalSpy spy(anim, SIGNAL(frameChanged()));
QVERIFY(spy.isValid());
anim->setPlaying(true); anim->setPlaying(true);
QTRY_VERIFY(spy.count() == 1); spy.clear(); QTRY_VERIFY(spy.count() == 1); spy.clear();
anim->setProperty("mirror", true); anim->setMirror(true);
QCOMPARE(anim->currentFrame(), 1); QCOMPARE(anim->currentFrame(), 1);
QPixmap frame1_flipped = QPixmap::fromImage(window.grabWindow()); QImage frame1_flipped = window.grabWindow();
QTRY_VERIFY(spy.count() == 1); spy.clear(); QTRY_VERIFY(spy.count() == 1); spy.clear();
QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
QPixmap frame0_flipped = QPixmap::fromImage(window.grabWindow()); QImage frame0_flipped = window.grabWindow();
QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
QTransform transform; QTransform transform;
transform.translate(width, 0).scale(-1, 1.0); transform.translate(width, 0).scale(-1, 1.0);
QPixmap frame0_expected = frame0.transformed(transform); QImage frame0_expected = frame0.transformed(transform);
QPixmap frame1_expected = frame1.transformed(transform); QImage frame1_expected = frame1.transformed(transform);
QCOMPARE(frame0_flipped, frame0_expected); QCOMPARE(frame0_flipped, frame0_expected);
QCOMPARE(frame1_flipped, frame1_expected); QCOMPARE(frame1_flipped, frame1_expected);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment