diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativepositioners')
16 files changed, 316 insertions, 3 deletions
diff --git a/tests/auto/declarative/qdeclarativepositioners/data/flowtest.qml b/tests/auto/declarative/qdeclarativepositioners/data/flowtest.qml new file mode 100644 index 0000000..6c1c823 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/flowtest.qml @@ -0,0 +1,40 @@ +import Qt 4.6 + +Item { + width: 90 + height: 480 + Flow { + objectName: "flow" + width: parent.width + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml index f6376a1..9741ba9 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Grid { + objectName: "grid" columns: 3 add: Transition { NumberAnimation { diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml index 5b4a30d..e335932 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Grid { + objectName: "grid" columns: 3 spacing: 4 Rectangle { diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml new file mode 100644 index 0000000..34a84bf --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml @@ -0,0 +1,41 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + rows: 3 + flow: Grid.TopToBottom + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid.qml b/tests/auto/declarative/qdeclarativepositioners/data/gridtest.qml index 830df6a..1d6f44e 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/grid.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/gridtest.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Grid { + objectName: "grid" columns: 3 Rectangle { objectName: "one" diff --git a/tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml b/tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml new file mode 100644 index 0000000..052d96b --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml @@ -0,0 +1,40 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + columns: 0 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml index c113a36..a1c05a8 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Row { + objectName: "row" add: Transition { NumberAnimation { properties: "x"; diff --git a/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml index 32bf775..fb9fdd1 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Row { + objectName: "row" spacing: 10 Rectangle { objectName: "one" diff --git a/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml index 06ae151..3a7a3b1 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Row { + objectName: "row" Rectangle { objectName: "one" color: "red" diff --git a/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepositioners/data/propertychangestest.qml index 4370a18..4370a18 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/propertychangestest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml b/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml index 2bc5e94..2bc5e94 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml index 10f6cbb..31faa54 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Column { + objectName: "column" add: Transition { NumberAnimation { properties: "y"; diff --git a/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml index 69a8256..1c5696b 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Column { + objectName: "column" spacing: 10 Rectangle { objectName: "one" diff --git a/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml index 856c180..cd777e2 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml @@ -4,6 +4,7 @@ Item { width: 640 height: 480 Column { + objectName: "column" Rectangle { objectName: "one" color: "red" diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro index 5edfa55..dbe2cbee 100644 --- a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro +++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro @@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 3a8a892..b4ac0e1 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -61,10 +61,14 @@ private slots: void test_vertical_spacing(); void test_vertical_animated(); void test_grid(); + void test_grid_topToBottom(); void test_grid_spacing(); void test_grid_animated(); + void test_grid_zero_columns(); void test_propertychanges(); void test_repeater(); + void test_flow(); + void test_flow_resize(); private: QDeclarativeView *createView(const QString &filename); }; @@ -92,6 +96,10 @@ void tst_QDeclarativePositioners::test_horizontal() QCOMPARE(two->y(), 0.0); QCOMPARE(three->x(), 70.0); QCOMPARE(three->y(), 0.0); + + QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row"); + QCOMPARE(row->width(), 110.0); + QCOMPARE(row->height(), 50.0); } void tst_QDeclarativePositioners::test_horizontal_spacing() @@ -113,6 +121,10 @@ void tst_QDeclarativePositioners::test_horizontal_spacing() QCOMPARE(two->y(), 0.0); QCOMPARE(three->x(), 90.0); QCOMPARE(three->y(), 0.0); + + QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row"); + QCOMPARE(row->width(), 130.0); + QCOMPARE(row->height(), 50.0); } void tst_QDeclarativePositioners::test_horizontal_animated() @@ -133,6 +145,11 @@ void tst_QDeclarativePositioners::test_horizontal_animated() QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), -100.0); + QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row"); + QVERIFY(row); + QCOMPARE(row->width(), 100.0); + QCOMPARE(row->height(), 50.0); + //QTRY_COMPARE used instead of waiting for the expected time of animation completion //Note that this means the duration of the animation is NOT tested @@ -147,6 +164,11 @@ void tst_QDeclarativePositioners::test_horizontal_animated() //Add 'two' two->setOpacity(1.0); QCOMPARE(two->opacity(), 1.0); + + // New size should be immediate + QCOMPARE(row->width(), 150.0); + QCOMPARE(row->height(), 50.0); + QTest::qWait(0);//Let the animation start QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), 50.0); @@ -174,6 +196,11 @@ void tst_QDeclarativePositioners::test_vertical() QCOMPARE(two->y(), 50.0); QCOMPARE(three->x(), 0.0); QCOMPARE(three->y(), 60.0); + + QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column"); + QVERIFY(column); + QCOMPARE(column->height(), 80.0); + QCOMPARE(column->width(), 50.0); } void tst_QDeclarativePositioners::test_vertical_spacing() @@ -195,6 +222,10 @@ void tst_QDeclarativePositioners::test_vertical_spacing() QCOMPARE(two->y(), 60.0); QCOMPARE(three->x(), 0.0); QCOMPARE(three->y(), 80.0); + + QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column"); + QCOMPARE(column->height(), 100.0); + QCOMPARE(column->width(), 50.0); } void tst_QDeclarativePositioners::test_vertical_animated() @@ -214,6 +245,11 @@ void tst_QDeclarativePositioners::test_vertical_animated() QVERIFY(three != 0); QCOMPARE(three->y(), -100.0); + QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column"); + QVERIFY(column); + QCOMPARE(column->height(), 100.0); + QCOMPARE(column->width(), 50.0); + //QTRY_COMPARE used instead of waiting for the expected time of animation completion //Note that this means the duration of the animation is NOT tested @@ -228,6 +264,8 @@ void tst_QDeclarativePositioners::test_vertical_animated() //Add 'two' two->setOpacity(1.0); QTRY_COMPARE(two->opacity(), 1.0); + QCOMPARE(column->height(), 150.0); + QCOMPARE(column->width(), 50.0); QTest::qWait(0);//Let the animation start QCOMPARE(two->y(), -100.0); QCOMPARE(three->y(), 50.0); @@ -239,7 +277,7 @@ void tst_QDeclarativePositioners::test_vertical_animated() void tst_QDeclarativePositioners::test_grid() { - QDeclarativeView *canvas = createView(SRCDIR "/data/grid.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml"); QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); QVERIFY(one != 0); @@ -262,6 +300,41 @@ void tst_QDeclarativePositioners::test_grid() QCOMPARE(four->y(), 50.0); QCOMPARE(five->x(), 50.0); QCOMPARE(five->y(), 50.0); + + QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); + QCOMPARE(grid->width(), 120.0); + QCOMPARE(grid->height(), 100.0); +} + +void tst_QDeclarativePositioners::test_grid_topToBottom() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/grid-toptobottom.qml"); + + QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); + QVERIFY(one != 0); + QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two"); + QVERIFY(two != 0); + QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three"); + QVERIFY(three != 0); + QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four"); + QVERIFY(four != 0); + QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 100.0); + QCOMPARE(four->x(), 50.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 50.0); + + QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 120.0); } void tst_QDeclarativePositioners::test_grid_spacing() @@ -289,6 +362,10 @@ void tst_QDeclarativePositioners::test_grid_spacing() QCOMPARE(four->y(), 54.0); QCOMPARE(five->x(), 54.0); QCOMPARE(five->y(), 54.0); + + QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); + QCOMPARE(grid->width(), 128.0); + QCOMPARE(grid->height(), 104.0); } void tst_QDeclarativePositioners::test_grid_animated() @@ -321,6 +398,11 @@ void tst_QDeclarativePositioners::test_grid_animated() QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); + QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); + QVERIFY(grid); + QCOMPARE(grid->width(), 150.0); + QCOMPARE(grid->height(), 100.0); + //QTRY_COMPARE used instead of waiting for the expected time of animation completion //Note that this means the duration of the animation is NOT tested @@ -339,6 +421,8 @@ void tst_QDeclarativePositioners::test_grid_animated() //Add 'two' two->setOpacity(1.0); QCOMPARE(two->opacity(), 1.0); + QCOMPARE(grid->width(), 150.0); + QCOMPARE(grid->height(), 100.0); QTest::qWait(0);//Let the animation start QCOMPARE(two->x(), -100.0); QCOMPARE(two->y(), -100.0); @@ -363,11 +447,44 @@ void tst_QDeclarativePositioners::test_grid_animated() QTRY_COMPARE(five->y(), 50.0); } + +void tst_QDeclarativePositioners::test_grid_zero_columns() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/gridzerocolumns.qml"); + + QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); + QVERIFY(one != 0); + QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two"); + QVERIFY(two != 0); + QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three"); + QVERIFY(three != 0); + QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four"); + QVERIFY(four != 0); + QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 120.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 0.0); + QCOMPARE(five->y(), 50.0); + + QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); + QCOMPARE(grid->width(), 170.0); + QCOMPARE(grid->height(), 60.0); +} + void tst_QDeclarativePositioners::test_propertychanges() { - QDeclarativeView *canvas = createView("data/propertychanges.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/propertychangestest.qml"); QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(canvas->rootObject()); + QVERIFY(grid != 0); QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("rowTransition"); QDeclarativeTransition *columnTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("columnTransition"); @@ -421,7 +538,7 @@ void tst_QDeclarativePositioners::test_propertychanges() void tst_QDeclarativePositioners::test_repeater() { - QDeclarativeView *canvas = createView(SRCDIR "/data/repeater.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/repeatertest.qml"); QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); QVERIFY(one != 0); @@ -440,6 +557,69 @@ void tst_QDeclarativePositioners::test_repeater() QCOMPARE(three->y(), 0.0); } +void tst_QDeclarativePositioners::test_flow() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml"); + + QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); + QVERIFY(one != 0); + QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two"); + QVERIFY(two != 0); + QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three"); + QVERIFY(three != 0); + QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four"); + QVERIFY(four != 0); + QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 50.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 70.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 70.0); + + QDeclarativeItem *flow = canvas->rootObject()->findChild<QDeclarativeItem*>("flow"); + QVERIFY(flow); + QCOMPARE(flow->width(), 90.0); + QCOMPARE(flow->height(), 120.0); +} + +void tst_QDeclarativePositioners::test_flow_resize() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml"); + + QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject()); + QVERIFY(root); + root->setWidth(125); + + QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); + QVERIFY(one != 0); + QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two"); + QVERIFY(two != 0); + QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three"); + QVERIFY(three != 0); + QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four"); + QVERIFY(four != 0); + QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.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); +} + QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename) { QDeclarativeView *canvas = new QDeclarativeView(0); |