From b8f6e3736cf5b73b695d4820a35663fa18708981 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 29 Mar 2012 12:54:24 +1000 Subject: Improve Flipable element unit tests Ensure that the reported side is updated correctly due to a rotation transform triggered by a state change. Change-Id: I039c6bcba872c7731c810137551e760414fabc05 Reviewed-by: Michael Brasser --- .../quick/qquickflipable/data/flip-flipable.qml | 28 ++++++++++++++++++++++ .../quick/qquickflipable/tst_qquickflipable.cpp | 15 ++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/auto/quick/qquickflipable/data/flip-flipable.qml (limited to 'tests/auto/quick/qquickflipable') diff --git a/tests/auto/quick/qquickflipable/data/flip-flipable.qml b/tests/auto/quick/qquickflipable/data/flip-flipable.qml new file mode 100644 index 0000000000..4f22a0df6d --- /dev/null +++ b/tests/auto/quick/qquickflipable/data/flip-flipable.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Flipable { + id: flipable + width: 640; height: 480 + property bool flipped: false + + front: Rectangle { color: "red"; anchors.fill: flipable } + back: Rectangle { color: "blue"; anchors.fill: flipable } + + transform: Rotation { + id: rotation + origin.x: flipable.width/2 + origin.y: flipable.height/2 + axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis + angle: 0 // the default angle + } + + states: State { + name: "back" + PropertyChanges { target: rotation; angle: 540 } + when: flipable.flipped + } + + transitions: Transition { + NumberAnimation { target: rotation; property: "angle"; duration: 500 } + } +} diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp index 4fe155168a..8c1c248925 100644 --- a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp +++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp @@ -58,6 +58,7 @@ private slots: void create(); void checkFrontAndBack(); void setFrontAndBack(); + void flipFlipable(); // below here task issues void QTBUG_9161_crash(); @@ -109,6 +110,20 @@ void tst_qquickflipable::setFrontAndBack() delete obj; } +void tst_qquickflipable::flipFlipable() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("flip-flipable.qml")); + QQuickFlipable *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + QVERIFY(obj->side() == QQuickFlipable::Front); + obj->setProperty("flipped", QVariant(true)); + QTRY_VERIFY(obj->side() == QQuickFlipable::Back); + QTRY_VERIFY(obj->side() == QQuickFlipable::Front); + QTRY_VERIFY(obj->side() == QQuickFlipable::Back); + delete obj; +} + void tst_qquickflipable::QTBUG_9161_crash() { QQuickView *canvas = new QQuickView; -- cgit v1.2.3