summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/layouts
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-11-09 03:27:49 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-11-09 03:27:49 (GMT)
commit1424d6be3691bafc980693c01532938dc4a640a6 (patch)
treeb3a94c161495fdf9e9a7ae82c2b34fb5bfad7d50 /tests/auto/declarative/layouts
parent3ceeb87db6b6f7beeffe9df0417bd076fa72eece (diff)
downloadQt-1424d6be3691bafc980693c01532938dc4a640a6.zip
Qt-1424d6be3691bafc980693c01532938dc4a640a6.tar.gz
Qt-1424d6be3691bafc980693c01532938dc4a640a6.tar.bz2
Split out layout and positioner tests
Includes actually adding some layout tests (which seem to expose bugs in the layouts).
Diffstat (limited to 'tests/auto/declarative/layouts')
-rw-r--r--tests/auto/declarative/layouts/data/grid-animated.qml55
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing.qml40
-rw-r--r--tests/auto/declarative/layouts/data/grid.qml39
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-animated.qml42
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing.qml27
-rw-r--r--tests/auto/declarative/layouts/data/horizontal.qml26
-rw-r--r--tests/auto/declarative/layouts/data/layouts.qml34
-rw-r--r--tests/auto/declarative/layouts/data/repeater.qml20
-rw-r--r--tests/auto/declarative/layouts/data/vertical-animated.qml42
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing.qml27
-rw-r--r--tests/auto/declarative/layouts/data/vertical.qml26
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp434
12 files changed, 85 insertions, 727 deletions
diff --git a/tests/auto/declarative/layouts/data/grid-animated.qml b/tests/auto/declarative/layouts/data/grid-animated.qml
deleted file mode 100644
index 6b128ce..0000000
--- a/tests/auto/declarative/layouts/data/grid-animated.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Grid {
- columns: 3
- add: Transition {
- NumberAnimation {
- matchProperties: "x,y"; from: -100
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties: "x,y"; to: -100
- }
- }
- move: Transition {
- NumberAnimation {
- matchProperties: "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/grid-spacing.qml b/tests/auto/declarative/layouts/data/grid-spacing.qml
deleted file mode 100644
index 5b4a30d..0000000
--- a/tests/auto/declarative/layouts/data/grid-spacing.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Grid {
- columns: 3
- spacing: 4
- 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/layouts/data/grid.qml b/tests/auto/declarative/layouts/data/grid.qml
deleted file mode 100644
index 830df6a..0000000
--- a/tests/auto/declarative/layouts/data/grid.qml
+++ /dev/null
@@ -1,39 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Grid {
- columns: 3
- 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/layouts/data/horizontal-animated.qml b/tests/auto/declarative/layouts/data/horizontal-animated.qml
deleted file mode 100644
index c29d6df..0000000
--- a/tests/auto/declarative/layouts/data/horizontal-animated.qml
+++ /dev/null
@@ -1,42 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Row {
- add: Transition {
- NumberAnimation {
- matchProperties: "x"; from: -100
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties: "x"; to: -100
- }
- }
- move: Transition {
- NumberAnimation {
- matchProperties: "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/horizontal-spacing.qml b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
deleted file mode 100644
index 32bf775..0000000
--- a/tests/auto/declarative/layouts/data/horizontal-spacing.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Row {
- spacing: 10
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/declarative/layouts/data/horizontal.qml b/tests/auto/declarative/layouts/data/horizontal.qml
deleted file mode 100644
index 06ae151..0000000
--- a/tests/auto/declarative/layouts/data/horizontal.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Row {
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/declarative/layouts/data/layouts.qml b/tests/auto/declarative/layouts/data/layouts.qml
new file mode 100644
index 0000000..ccc8cfe
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/layouts.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+
+Item {
+ id: resizable
+ width:300
+ height:300
+
+ GraphicsObjectContainer {
+ anchors.fill:parent
+
+ QGraphicsWidget {
+ size.width:parent.width
+ size.height:parent.height
+
+ layout: QGraphicsLinearLayout {
+ spacing: 0
+ LayoutItem {
+ objectName: "left"
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent }
+ }
+ LayoutItem {
+ objectName: "right"
+ minimumSize: "100x100"
+ maximumSize: "400x400"
+ preferredSize: "200x200"
+ Rectangle { objectName: "greenRect"; color: "green"; anchors.fill: parent }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/repeater.qml b/tests/auto/declarative/layouts/data/repeater.qml
deleted file mode 100644
index 2bc5e94..0000000
--- a/tests/auto/declarative/layouts/data/repeater.qml
+++ /dev/null
@@ -1,20 +0,0 @@
-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
deleted file mode 100644
index fcbc5f7..0000000
--- a/tests/auto/declarative/layouts/data/vertical-animated.qml
+++ /dev/null
@@ -1,42 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Column {
- add: Transition {
- NumberAnimation {
- matchProperties: "y"; from: -100
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties: "y"; to: -100
- }
- }
- move: Transition {
- NumberAnimation {
- matchProperties: "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/data/vertical-spacing.qml b/tests/auto/declarative/layouts/data/vertical-spacing.qml
deleted file mode 100644
index 69a8256..0000000
--- a/tests/auto/declarative/layouts/data/vertical-spacing.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Column {
- spacing: 10
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/declarative/layouts/data/vertical.qml b/tests/auto/declarative/layouts/data/vertical.qml
deleted file mode 100644
index 856c180..0000000
--- a/tests/auto/declarative/layouts/data/vertical.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import Qt 4.6
-
-Item {
- width: 640
- height: 480
- Column {
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index c0c067a..f619b57 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -41,7 +41,7 @@
#include <QtTest/QtTest>
#include <private/qlistmodelinterface_p.h>
#include <qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
+#include <private/qmlgraphicslayoutitem_p.h>
#include <qmlexpression.h>
class tst_QmlGraphicsLayouts : public QObject
@@ -51,17 +51,9 @@ public:
tst_QmlGraphicsLayouts();
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_qml();//GraphicsLayout set up in Qml
+ void test_cpp();//GraphicsLayout set up in C++
- void test_repeater();
private:
QmlView *createView(const QString &filename);
};
@@ -70,385 +62,61 @@ tst_QmlGraphicsLayouts::tst_QmlGraphicsLayouts()
{
}
-void tst_QmlGraphicsLayouts::test_horizontal()
+void tst_QmlGraphicsLayouts::test_qml()
{
- QmlView *canvas = createView(SRCDIR "/data/horizontal.qml");
+ QmlView *canvas = createView(SRCDIR "/data/layouts.qml");
canvas->execute();
qApp->processEvents();
-
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 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);
+ QmlGraphicsLayoutItem *left = qobject_cast<QmlGraphicsLayoutItem*>(canvas->root()->findChild<QmlGraphicsItem*>("left"));
+ QVERIFY(left != 0);
+
+ QmlGraphicsLayoutItem *right = qobject_cast<QmlGraphicsLayoutItem*>(canvas->root()->findChild<QmlGraphicsItem*>("right"));
+ QVERIFY(right != 0);
+
+ qreal gvMargin = 9.0;
+ //Preferred Size
+ canvas->root()->setWidth(300 + 2*gvMargin);
+ canvas->root()->setHeight(300 + 2*gvMargin);
+
+ QCOMPARE(left->x(), gvMargin);
+ QCOMPARE(left->y(), gvMargin);
+ QCOMPARE(left->width(), 100.0);
+ QCOMPARE(left->height(), 300.0);
+
+ QCOMPARE(right->x(), 100.0 + gvMargin);
+ QCOMPARE(right->y(), 0.0 + gvMargin);
+ QCOMPARE(right->width(), 200.0);
+ QCOMPARE(right->height(), 300.0);
+
+ //Minimum Size
+ canvas->root()->setWidth(10+2*gvMargin);
+ canvas->root()->setHeight(10+2*gvMargin);
+
+ QCOMPARE(left->x(), gvMargin);
+ QCOMPARE(left->width(), 100.0);
+ QCOMPARE(left->height(), 100.0);
+
+ QCOMPARE(right->x(), 100.0 + gvMargin);
+ QCOMPARE(right->width(), 100.0);
+ QCOMPARE(right->height(), 100.0);
+
+ //Maximum Size
+ canvas->root()->setWidth(1000 + 2*gvMargin);
+ canvas->root()->setHeight(1000 + 2*gvMargin);
+
+ QCOMPARE(left->x(), gvMargin);
+ QCOMPARE(left->width(), 300.0);
+ QCOMPARE(left->height(), 300.0);
+
+ QCOMPARE(right->x(), 300.0 + gvMargin);
+ QCOMPARE(right->width(), 400.0);
+ QCOMPARE(right->height(), 400.0);
}
-void tst_QmlGraphicsLayouts::test_horizontal_spacing()
+void tst_QmlGraphicsLayouts::test_cpp()
{
- QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 60.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- 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");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 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(), 60.0);
-}
-
-void tst_QmlGraphicsLayouts::test_vertical_spacing()
-{
- QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 60.0);
- QCOMPARE(three->x(), 0.0);
- 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");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-void tst_QmlGraphicsLayouts::test_grid_spacing()
-{
- QmlView *canvas = createView("data/grid-spacing.qml");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 54.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 78.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 54.0);
- QCOMPARE(five->x(), 54.0);
- 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");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
+ //TODO: Waiting on QT-2407 to write this test
}
QmlView *tst_QmlGraphicsLayouts::createView(const QString &filename)