diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-03-29 12:54:24 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-30 05:53:48 +0200 |
commit | b8f6e3736cf5b73b695d4820a35663fa18708981 (patch) | |
tree | d5bce39364b4e24cb04a0af2831b36257e10f440 /tests/auto/quick/qquickflipable | |
parent | 200f783745b571725f899f08c34d1155be632523 (diff) |
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 <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickflipable')
-rw-r--r-- | tests/auto/quick/qquickflipable/data/flip-flipable.qml | 28 | ||||
-rw-r--r-- | tests/auto/quick/qquickflipable/tst_qquickflipable.cpp | 15 |
2 files changed, 43 insertions, 0 deletions
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<QQuickFlipable*>(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; |