diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-11-04 01:57:42 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-11-04 01:57:42 (GMT) |
commit | f3cce7a770f25c42d5c85b012df338fc712f5b2e (patch) | |
tree | 7ad682b21b1cf55da6c7338f5400ee3cfccdb404 /tests/auto/declarative | |
parent | 4e8df537210736d8a723a409e5e01046efa44a39 (diff) | |
download | Qt-f3cce7a770f25c42d5c85b012df338fc712f5b2e.zip Qt-f3cce7a770f25c42d5c85b012df338fc712f5b2e.tar.gz Qt-f3cce7a770f25c42d5c85b012df338fc712f5b2e.tar.bz2 |
Add tests for the the positioner transitions.
Diffstat (limited to 'tests/auto/declarative')
5 files changed, 363 insertions, 0 deletions
diff --git a/tests/auto/declarative/layouts/data/grid-animated.qml b/tests/auto/declarative/layouts/data/grid-animated.qml new file mode 100644 index 0000000..9edccaf --- /dev/null +++ b/tests/auto/declarative/layouts/data/grid-animated.qml @@ -0,0 +1,55 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Grid { + columns: 3 + add: Transition { + NumberAnimation { + properties: "x,y"; from: -100 + } + } + remove: Transition { + NumberAnimation { + properties: "x,y"; to: -100 + } + } + move: Transition { + NumberAnimation { + properties: "x,y"; + } + } + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + opacity: 0 + color: "green" + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 50 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/declarative/layouts/data/horizontal-animated.qml b/tests/auto/declarative/layouts/data/horizontal-animated.qml new file mode 100644 index 0000000..f757d18 --- /dev/null +++ b/tests/auto/declarative/layouts/data/horizontal-animated.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Row { + add: Transition { + NumberAnimation { + properties: "x"; from: -100 + } + } + remove: Transition { + NumberAnimation { + properties: "x"; to: -100 + } + } + move: Transition { + NumberAnimation { + properties: "x"; + } + } + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "blue" + opacity: 0 + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + color: "red" + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/declarative/layouts/data/repeater.qml b/tests/auto/declarative/layouts/data/repeater.qml new file mode 100644 index 0000000..2bc5e94 --- /dev/null +++ b/tests/auto/declarative/layouts/data/repeater.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Row { + Repeater{ model: 3; + delegate: Component { + Rectangle { + color: "red" + width: 50 + height: 50 + z: {if(index == 0){2;}else if(index == 1){1;} else{3;}} + objectName: {if(index == 0){"one";}else if(index == 1){"two";} else{"three";}} + + } + } + } + } +} diff --git a/tests/auto/declarative/layouts/data/vertical-animated.qml b/tests/auto/declarative/layouts/data/vertical-animated.qml new file mode 100644 index 0000000..f52a78a --- /dev/null +++ b/tests/auto/declarative/layouts/data/vertical-animated.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Column { + add: Transition { + NumberAnimation { + properties: "y"; from: -100 + } + } + remove: Transition { + NumberAnimation { + properties: "y"; to: -100 + } + } + move: Transition { + NumberAnimation { + properties: "y"; + } + } + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "blue" + opacity: 0 + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + color: "red" + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index 96729a3..c0c067a 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -53,10 +53,13 @@ public: private slots: void test_horizontal(); void test_horizontal_spacing(); + void test_horizontal_animated(); void test_vertical(); void test_vertical_spacing(); + void test_vertical_animated(); void test_grid(); void test_grid_spacing(); + void test_grid_animated(); void test_repeater(); private: @@ -115,6 +118,57 @@ void tst_QmlGraphicsLayouts::test_horizontal_spacing() QCOMPARE(three->y(), 0.0); } +void tst_QmlGraphicsLayouts::test_horizontal_animated() +{ + QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml"); + + canvas->execute(); + qApp->processEvents(); + + QTest::qWait(0);//Let the animation start + //Note that one and three animate in + QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QVERIFY(one != 0); + QCOMPARE(one->x(), -100.0); + + QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QVERIFY(two != 0); + QCOMPARE(two->x(), 0.0); + + QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QVERIFY(three != 0); + QCOMPARE(three->x(), -100.0); + + QTest::qWait(300);//Let the animation complete + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->opacity(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 0.0); + + //Add 'two' + two->setOpacity(1.0); + QCOMPARE(two->opacity(), 1.0); + QTest::qWait(0);//Let the animation start + QCOMPARE(two->x(), -100.0); + QCOMPARE(three->x(), 50.0); + QTest::qWait(300);//Let the animation complete + QCOMPARE(two->x(), 50.0); + QCOMPARE(three->x(), 100.0); + + //Remove 'two' + two->setOpacity(0.0); + QCOMPARE(two->opacity(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(three->x(), 100.0); + QTest::qWait(300);//Let the animation complete + QCOMPARE(two->x(), 50.0); + QCOMPARE(three->x(), 50.0); +} + void tst_QmlGraphicsLayouts::test_vertical() { QmlView *canvas = createView(SRCDIR "/data/vertical.qml"); @@ -163,6 +217,57 @@ void tst_QmlGraphicsLayouts::test_vertical_spacing() QCOMPARE(three->y(), 80.0); } +void tst_QmlGraphicsLayouts::test_vertical_animated() +{ + QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml"); + + canvas->execute(); + qApp->processEvents(); + + QTest::qWait(0);//Let the animation start + //Note that one and three animate in + QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QVERIFY(one != 0); + QCOMPARE(one->y(), -100.0); + + QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QVERIFY(two != 0); + QCOMPARE(two->y(), 0.0); + + QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QVERIFY(three != 0); + QCOMPARE(three->y(), -100.0); + + QTest::qWait(300);//Let the animation complete + + QCOMPARE(one->y(), 0.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(two->opacity(), 0.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(three->y(), 50.0); + QCOMPARE(three->x(), 0.0); + + //Add 'two' + two->setOpacity(1.0); + QCOMPARE(two->opacity(), 1.0); + QTest::qWait(0);//Let the animation start + QCOMPARE(two->y(), -100.0); + QCOMPARE(three->y(), 50.0); + QTest::qWait(300);//Let the animation complete + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->y(), 100.0); + + //Remove 'two' + two->setOpacity(0.0); + QCOMPARE(two->opacity(), 0.0); + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->y(), 100.0); + QTest::qWait(300);//Let the animation complete + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->y(), 50.0); +} + void tst_QmlGraphicsLayouts::test_grid() { QmlView *canvas = createView("data/grid.qml"); @@ -223,6 +328,105 @@ void tst_QmlGraphicsLayouts::test_grid_spacing() QCOMPARE(five->y(), 54.0); } +void tst_QmlGraphicsLayouts::test_grid_animated() +{ + QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml"); + canvas->execute(); + qApp->processEvents(); + + QTest::qWait(0);//Let the animation start + //Note that all but two animate in + QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one"); + QVERIFY(one != 0); + QCOMPARE(one->x(), -100.0); + QCOMPARE(one->y(), -100.0); + + QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two"); + QVERIFY(two != 0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 0.0); + + QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three"); + QVERIFY(three != 0); + QCOMPARE(three->x(), -100.0); + QCOMPARE(three->y(), -100.0); + + QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four"); + QVERIFY(four != 0); + QCOMPARE(four->x(), -100.0); + QCOMPARE(four->y(), -100.0); + + QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five"); + QVERIFY(five != 0); + QCOMPARE(five->x(), -100.0); + QCOMPARE(five->y(), -100.0); + + QTest::qWait(300);//Let the animation complete + + QCOMPARE(one->y(), 0.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(two->opacity(), 0.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(four->x(), 100.0); + QCOMPARE(five->y(), 50.0); + QCOMPARE(five->x(), 0.0); + + //Add 'two' + two->setOpacity(1.0); + QCOMPARE(two->opacity(), 1.0); + QTest::qWait(0);//Let the animation start + QCOMPARE(two->x(), -100.0); + QCOMPARE(two->y(), -100.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 100.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 0.0); + QCOMPARE(five->y(), 50.0); + QTest::qWait(300);//Let the animation complete + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(three->x(), 100.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 50.0); + + //Remove 'two' + two->setOpacity(0.0); + QCOMPARE(two->opacity(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(three->x(), 100.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 50.0); + QTest::qWait(300);//Let the animation complete + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 100.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 0.0); + QCOMPARE(five->y(), 50.0); +} + void tst_QmlGraphicsLayouts::test_repeater() { QmlView *canvas = createView("data/repeater.qml"); |