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/layouts/tst_layouts.cpp | |
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/layouts/tst_layouts.cpp')
-rw-r--r-- | tests/auto/declarative/layouts/tst_layouts.cpp | 204 |
1 files changed, 204 insertions, 0 deletions
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"); |