aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qtquick1/qdeclarativepositioners
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtquick1/qdeclarativepositioners')
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml44
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml43
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml64
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml42
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml40
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml44
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml31
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml39
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml38
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro16
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp1355
19 files changed, 2006 insertions, 0 deletions
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml
new file mode 100644
index 0000000000..ee4e1048a2
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml
@@ -0,0 +1,19 @@
+import QtQuick 1.1
+
+Rectangle {
+ width: 300; height: 200;
+
+ property int flowLayout: 1
+
+ Flow {
+ objectName: "flow"
+ layoutDirection: (flowLayout == 2) ? Qt.RightToLeft : Qt.LeftToRight
+ flow: (flowLayout == 1) ? Flow.TopToBottom : Flow.LeftToRight;
+
+ spacing: 20
+ anchors.horizontalCenter: parent.horizontalCenter
+ Rectangle { color: "red"; width: 100; height: 50 }
+ Rectangle { color: "blue"; width: 100; height: 50 }
+ }
+}
+
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml
new file mode 100644
index 0000000000..ec1d6660c3
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml
@@ -0,0 +1,44 @@
+import QtQuick 1.1
+
+Item {
+ height: 90
+ width: 480
+ property bool testRightToLeft: false
+
+ Flow {
+ objectName: "flow"
+ height: parent.height
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ flow: Flow.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/qtquick1/qdeclarativepositioners/data/flowtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml
new file mode 100644
index 0000000000..7c124a3d44
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml
@@ -0,0 +1,43 @@
+import QtQuick 1.1
+
+Item {
+ width: 90
+ height: 480
+ property bool testRightToLeft: false
+
+ Flow {
+ objectName: "flow"
+ width: parent.width
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ 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/qtquick1/qdeclarativepositioners/data/grid-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml
new file mode 100644
index 0000000000..3dcbed1103
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml
@@ -0,0 +1,64 @@
+import QtQuick 1.1
+
+Item {
+ width: 640
+ height: 480
+ property bool testRightToLeft: true
+
+ Grid {
+ objectName: "grid"
+ columns: 3
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ add: Transition {
+ NumberAnimation {
+ properties: "x,y";
+ }
+ }
+ move: Transition {
+ NumberAnimation {
+ properties: "x,y";
+ }
+ }
+ Rectangle {
+ objectName: "one"
+ color: "red"
+ x: -100
+ y: -100
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "two"
+ x: -100
+ y: -100
+ opacity: 0
+ color: "green"
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "three"
+ color: "blue"
+ x: -100
+ y: -100
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "four"
+ color: "cyan"
+ x: -100
+ y: -100
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "five"
+ color: "magenta"
+ x: -100
+ y: -100
+ width: 50
+ height: 50
+ }
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml
new file mode 100644
index 0000000000..f03733001b
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml
@@ -0,0 +1,41 @@
+import QtQuick 1.0
+
+Item {
+ width: 640
+ height: 480
+ Grid {
+ objectName: "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/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml
new file mode 100644
index 0000000000..5d4c3373e5
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml
@@ -0,0 +1,41 @@
+import QtQuick 1.0
+
+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/qtquick1/qdeclarativepositioners/data/gridtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml
new file mode 100644
index 0000000000..929b7267cf
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml
@@ -0,0 +1,42 @@
+import QtQuick 1.1
+
+Item {
+ width: 640
+ height: 480
+ property bool testRightToLeft: false
+ Grid {
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ objectName: "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: 30
+ 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/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml
new file mode 100644
index 0000000000..169f974477
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml
@@ -0,0 +1,40 @@
+import QtQuick 1.0
+
+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/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml
new file mode 100644
index 0000000000..3c95f53fe7
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml
@@ -0,0 +1,44 @@
+import QtQuick 1.1
+
+Item {
+ width: 640
+ height: 480
+ property bool testRightToLeft: false
+
+ Row {
+ objectName: "row"
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ add: Transition {
+ NumberAnimation {
+ properties: "x";
+ }
+ }
+ move: Transition {
+ NumberAnimation {
+ properties: "x";
+ }
+ }
+ Rectangle {
+ objectName: "one"
+ color: "red"
+ x: -100;
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "two"
+ color: "blue"
+ x: -100;
+ opacity: 0
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "three"
+ x: -100;
+ color: "green"
+ width: 50
+ height: 50
+ }
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml
new file mode 100644
index 0000000000..64bedb02d3
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml
@@ -0,0 +1,31 @@
+import QtQuick 1.1
+
+Item {
+ width: 640
+ height: 480
+ property bool testRightToLeft: false
+
+ Row {
+ objectName: "row"
+ spacing: 10
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ 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/qtquick1/qdeclarativepositioners/data/horizontal.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml
new file mode 100644
index 0000000000..d35c02d538
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml
@@ -0,0 +1,29 @@
+import QtQuick 1.1
+
+Item {
+ width: 640
+ height: 480
+ property bool testRightToLeft: false
+ Row {
+ objectName: "row"
+ layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
+ 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/qtquick1/qdeclarativepositioners/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml
new file mode 100644
index 0000000000..3c95c4c279
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml
@@ -0,0 +1,39 @@
+import QtQuick 1.0
+
+Grid {
+ id: myGrid
+
+ width: 270
+ height: 270
+ x: 3
+ y: 3
+ columns: 4
+ spacing: 3
+
+ add: columnTransition
+ move: columnTransition
+
+ Repeater {
+ model: 20
+ Rectangle { color: "black"; width: 50; height: 50 }
+ }
+
+ data: [
+ Transition {
+ id: rowTransition
+ objectName: "rowTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing.type: "OutInCubic"
+ }
+ },
+ Transition {
+ id: columnTransition
+ objectName: "columnTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing.type: "OutInCubic"
+ }
+ }
+ ]
+}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml
new file mode 100644
index 0000000000..f93ce67da3
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml
@@ -0,0 +1,38 @@
+import QtQuick 1.0
+
+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";}}
+ }
+ }
+ }
+ }
+
+ //This crashed once (QTBUG-16959) because the repeater ended up on the end of the list
+ //If this grid just instantiates without crashing, then it has not regressed.
+ Grid {
+ id: grid
+ rows: 2
+ flow: Grid.TopToBottom
+
+ Repeater {
+ model: 13
+ Rectangle {
+ color: "goldenrod"
+ width: 100
+ height: 100
+ radius: 10
+ border.width: 1
+ }
+ }
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml
new file mode 100644
index 0000000000..8899ac83cc
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml
@@ -0,0 +1,41 @@
+import QtQuick 1.0
+
+Item {
+ width: 640
+ height: 480
+ Column {
+ objectName: "column"
+ add: Transition {
+ NumberAnimation {
+ properties: "y";
+ }
+ }
+ move: Transition {
+ NumberAnimation {
+ properties: "y";
+ }
+ }
+ Rectangle {
+ objectName: "one"
+ color: "red"
+ y: -100
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "two"
+ color: "blue"
+ y: -100
+ opacity: 0
+ width: 50
+ height: 50
+ }
+ Rectangle {
+ objectName: "three"
+ color: "red"
+ y: -100
+ width: 50
+ height: 50
+ }
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml
new file mode 100644
index 0000000000..557896115d
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml
@@ -0,0 +1,28 @@
+import QtQuick 1.0
+
+Item {
+ width: 640
+ height: 480
+ Column {
+ objectName: "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/qtquick1/qdeclarativepositioners/data/vertical.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml
new file mode 100644
index 0000000000..310d791d55
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml
@@ -0,0 +1,27 @@
+import QtQuick 1.0
+
+Item {
+ width: 640
+ height: 480
+ Column {
+ objectName: "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/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml
new file mode 100644
index 0000000000..c320714f15
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+Item {
+ width: 640
+ height: 480
+ Column {
+ objectName: "column"
+ QGraphicsWidget {
+ objectName: "one"
+ width: 50
+ height: 50
+ }
+ QGraphicsWidget {
+ objectName: "two"
+ width: 20
+ height: 10
+ }
+ QGraphicsWidget {
+ objectName: "three"
+ width: 40
+ height: 20
+ }
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro
new file mode 100644
index 0000000000..cf4ebfbf39
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro
@@ -0,0 +1,16 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative qtquick1
+SOURCES += tst_qdeclarativepositioners.cpp
+macx:CONFIG -= app_bundle
+
+symbian: {
+ importFiles.files = data
+ importFiles.path = .
+ DEPLOYMENT += importFiles
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
+
+CONFIG += parallel_test
+
+QT += core-private gui-private declarative-private qtquick1-private
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
new file mode 100644
index 0000000000..60ad1033fe
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -0,0 +1,1355 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtQuick1/qdeclarativeview.h>
+#include <qdeclarativeengine.h>
+#include <QtQuick1/private/qdeclarativerectangle_p.h>
+#include <QtQuick1/private/qdeclarativepositioners_p.h>
+#include <QtQuick1/private/qdeclarativetransition_p.h>
+#include <QtQuick1/private/qdeclarativeitem_p.h>
+#include <qdeclarativeexpression.h>
+#include <QtGui/qgraphicswidget.h>
+#include "../../../shared/util.h"
+
+#ifdef Q_OS_SYMBIAN
+// In Symbian OS test data is located in applications private dir
+#define SRCDIR "."
+#endif
+
+class tst_QDeclarativePositioners : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativePositioners();
+
+private slots:
+ void test_horizontal();
+ void test_horizontal_rtl();
+ void test_horizontal_spacing();
+ void test_horizontal_spacing_rightToLeft();
+ void test_horizontal_animated();
+ void test_horizontal_animated_rightToLeft();
+ void test_vertical();
+ void test_vertical_spacing();
+ void test_vertical_animated();
+ void test_grid();
+ void test_grid_topToBottom();
+ void test_grid_rightToLeft();
+ void test_grid_spacing();
+ void test_grid_animated();
+ void test_grid_animated_rightToLeft();
+ void test_grid_zero_columns();
+ void test_propertychanges();
+ void test_repeater();
+ void test_flow();
+ void test_flow_rightToLeft();
+ void test_flow_topToBottom();
+ void test_flow_resize();
+ void test_flow_resize_rightToLeft();
+ void test_flow_implicit_resize();
+ void test_conflictinganchors();
+ void test_vertical_qgraphicswidget();
+ void test_mirroring();
+ void testQtQuick11Attributes();
+ void testQtQuick11Attributes_data();
+private:
+ QDeclarativeView *createView(const QString &filename);
+};
+
+tst_QDeclarativePositioners::tst_QDeclarativePositioners()
+{
+}
+
+void tst_QDeclarativePositioners::test_horizontal()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
+ QCOMPARE(row->width(), 110.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_horizontal_rtl()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 60.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 40.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
+ QCOMPARE(row->width(), 110.0);
+ QCOMPARE(row->height(), 50.0);
+
+ // Change the width of the row and check that items stay to the right
+ row->setWidth(200);
+ QCOMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_horizontal_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
+ QCOMPARE(row->width(), 130.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_horizontal_spacing_rightToLeft()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 80.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 00.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
+ QCOMPARE(row->width(), 130.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_horizontal_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ 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
+
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(three->y(), 0.0);
+
+ //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);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_horizontal_animated_rightToLeft()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ 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
+
+ QTRY_COMPARE(one->x(), 50.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 0.0);
+ QTRY_COMPARE(three->y(), 0.0);
+
+ //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(one->x(), 50.0);
+ QCOMPARE(two->x(), -100.0);
+
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(two->x(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_vertical()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical.qml");
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_vertical_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
+ QCOMPARE(column->height(), 100.0);
+ QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_vertical_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
+
+ //Note that they animate in
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->y(), -100.0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->y(), -100.0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ 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
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->x(), 0.0);
+ QTRY_COMPARE(three->y(), 50.0);
+ QTRY_COMPARE(three->x(), 0.0);
+
+ //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);
+
+ QTRY_COMPARE(two->y(), 50.0);
+ QTRY_COMPARE(three->y(), 100.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_grid()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml");
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ QDeclarative1Grid *grid = canvas->rootObject()->findChild<QDeclarative1Grid*>("grid");
+ QCOMPARE(grid->flow(), QDeclarative1Grid::LeftToRight);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_grid_topToBottom()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-toptobottom.qml");
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ QDeclarative1Grid *grid = canvas->rootObject()->findChild<QDeclarative1Grid*>("grid");
+ QCOMPARE(grid->flow(), QDeclarative1Grid::TopToBottom);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 120.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_grid_rightToLeft()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 50.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 30.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 40.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QDeclarative1Grid *grid = canvas->rootObject()->findChild<QDeclarative1Grid*>("grid");
+ QCOMPARE(grid->layoutDirection(), Qt::RightToLeft);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ // Change the width of the grid and check that items stay to the right
+ grid->setWidth(200);
+ QCOMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 100.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 150.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 140.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_grid_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-spacing.qml");
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
+ QCOMPARE(grid->width(), 128.0);
+ QCOMPARE(grid->height(), 104.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_grid_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ //Note that all animate in
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
+ QVERIFY(five != 0);
+ 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
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 0.0);
+
+ //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);
+ 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);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_grid_animated_rightToLeft()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ //Note that all animate in
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
+ QVERIFY(five != 0);
+ 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
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 100.0);
+
+ //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);
+ QCOMPARE(one->x(), 100.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 100.0);
+ QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 0.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_grid_zero_columns()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/gridzerocolumns.qml");
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_propertychanges()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/propertychangestest.qml");
+
+ QDeclarative1Grid *grid = qobject_cast<QDeclarative1Grid*>(canvas->rootObject());
+ QVERIFY(grid != 0);
+ QDeclarative1Transition *rowTransition = canvas->rootObject()->findChild<QDeclarative1Transition*>("rowTransition");
+ QDeclarative1Transition *columnTransition = canvas->rootObject()->findChild<QDeclarative1Transition*>("columnTransition");
+
+ QSignalSpy addSpy(grid, SIGNAL(addChanged()));
+ QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
+ QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
+ QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
+
+ QVERIFY(grid);
+ QVERIFY(rowTransition);
+ QVERIFY(columnTransition);
+ QCOMPARE(grid->add(), columnTransition);
+ QCOMPARE(grid->move(), columnTransition);
+ QCOMPARE(grid->columns(), 4);
+ QCOMPARE(grid->rows(), -1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(grid->add(), rowTransition);
+ QCOMPARE(grid->move(), rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(0);
+ grid->setMove(0);
+ QCOMPARE(addSpy.count(),2);
+ QCOMPARE(moveSpy.count(),2);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(grid->columns(), -1);
+ QCOMPARE(grid->rows(), 3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(2);
+ grid->setRows(2);
+ QCOMPARE(columnsSpy.count(),2);
+ QCOMPARE(rowsSpy.count(),2);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_repeater()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/repeatertest.qml");
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_flow()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_flow_rightToLeft()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 40.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 20.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 40.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 40.0);
+ QCOMPARE(four->y(), 70.0);
+ QCOMPARE(five->x(), 30.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);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_flow_topToBottom()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest-toptobottom.qml");
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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(), 50.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 100.0);
+ QCOMPARE(four->y(), 00.0);
+ QCOMPARE(five->x(), 100.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QDeclarativeItem *flow = canvas->rootObject()->findChild<QDeclarativeItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->height(), 90.0);
+ QCOMPARE(flow->width(), 150.0);
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QVERIFY(flow);
+ QCOMPARE(flow->height(), 90.0);
+ QCOMPARE(flow->width(), 150.0);
+
+ QCOMPARE(one->x(), 100.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 80.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 40.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+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);
+ root->setProperty("testRightToLeft", false);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("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);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_flow_resize_rightToLeft()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml");
+
+ QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
+ QVERIFY(root);
+ root->setWidth(125);
+ root->setProperty("testRightToLeft", true);
+
+ QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 75.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 55.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 5.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 75.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 65.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_flow_implicit_resize()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/flow-testimplicitsize.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarative1Flow *flow = canvas->rootObject()->findChild<QDeclarative1Flow*>("flow");
+ QVERIFY(flow != 0);
+
+ QCOMPARE(flow->width(), 100.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 0);
+ QCOMPARE(flow->flow(), QDeclarative1Flow::LeftToRight);
+ QCOMPARE(flow->width(), 220.0);
+ QCOMPARE(flow->height(), 50.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 1);
+ QCOMPARE(flow->flow(), QDeclarative1Flow::TopToBottom);
+ QCOMPARE(flow->width(), 100.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 2);
+ QCOMPARE(flow->layoutDirection(), Qt::RightToLeft);
+ QCOMPARE(flow->width(), 220.0);
+ QCOMPARE(flow->height(), 50.0);
+
+ delete canvas;
+}
+
+QString warningMessage;
+
+void interceptWarnings(QtMsgType type, const char *msg)
+{
+ Q_UNUSED( type );
+ warningMessage = msg;
+}
+
+void tst_QDeclarativePositioners::test_conflictinganchors()
+{
+ QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings);
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+
+ component.setData("import QtQuick 1.0\nColumn { Item {} }", QUrl::fromLocalFile(""));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 1.0\nRow { Item {} }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 1.0\nGrid { Item {} }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 1.0\nFlow { Item {} }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 1.0\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nColumn { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row"));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nRow { Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row"));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nGrid { Item { anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid"));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nGrid { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid"));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 1.0\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
+ delete item;
+
+ component.setData("import QtQuick 1.0\nFlow { Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
+ qInstallMsgHandler(oldMsgHandler);
+ delete item;
+}
+
+void tst_QDeclarativePositioners::test_vertical_qgraphicswidget()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/verticalqgraphicswidget.qml");
+
+ QGraphicsWidget *one = canvas->rootObject()->findChild<QGraphicsWidget*>("one");
+ QVERIFY(one != 0);
+
+ QGraphicsWidget *two = canvas->rootObject()->findChild<QGraphicsWidget*>("two");
+ QVERIFY(two != 0);
+
+ QGraphicsWidget *three = canvas->rootObject()->findChild<QGraphicsWidget*>("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);
+
+ QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ two->resize(QSizeF(two->size().width(), 20.0));
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 70.0);
+
+ two->setOpacity(0.0);
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+
+ one->setVisible(false);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePositioners::test_mirroring()
+{
+ QList<QString> qmlFiles;
+ qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml";
+ QList<QString> objectNames;
+ objectNames << "one" << "two" << "three" << "four" << "five";
+
+ foreach(const QString qmlFile, qmlFiles) {
+ QDeclarativeView *canvasA = createView(QString(SRCDIR) + "/data/" + qmlFile);
+ QDeclarativeItem *rootA = qobject_cast<QDeclarativeItem*>(canvasA->rootObject());
+
+ QDeclarativeView *canvasB = createView(QString(SRCDIR) + "/data/" + qmlFile);
+ QDeclarativeItem *rootB = qobject_cast<QDeclarativeItem*>(canvasB->rootObject());
+
+ rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
+
+ // LTR != RTL
+ foreach(const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QDeclarativeItem *itemA = rootA->findChild<QDeclarativeItem*>(objectName);
+ QDeclarativeItem *itemB = rootB->findChild<QDeclarativeItem*>(objectName);
+ QVERIFY(itemA->x() != itemB->x());
+ }
+
+ QDeclarativeItemPrivate* rootPrivateB = QDeclarativeItemPrivate::get(rootB);
+
+ rootPrivateB->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
+ rootPrivateB->isMirrorImplicit = false;
+ rootPrivateB->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true
+ rootPrivateB->resolveLayoutMirror();
+
+ // RTL == mirror
+ foreach(const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QDeclarativeItem *itemA = rootA->findChild<QDeclarativeItem*>(objectName);
+ QDeclarativeItem *itemB = rootB->findChild<QDeclarativeItem*>(objectName);
+ QCOMPARE(itemA->x(), itemB->x());
+ }
+
+ rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight
+ rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
+
+ // LTR == RTL + mirror
+ foreach(const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QDeclarativeItem *itemA = rootA->findChild<QDeclarativeItem*>(objectName);
+ QDeclarativeItem *itemB = rootB->findChild<QDeclarativeItem*>(objectName);
+ QCOMPARE(itemA->x(), itemB->x());
+ }
+ delete canvasA;
+ delete canvasB;
+ }
+}
+
+void tst_QDeclarativePositioners::testQtQuick11Attributes()
+{
+ QFETCH(QString, code);
+ QFETCH(QString, warning);
+ QFETCH(QString, error);
+
+ QDeclarativeEngine engine;
+ QObject *obj;
+
+ QDeclarativeComponent valid(&engine);
+ valid.setData("import QtQuick 1.1; " + code.toUtf8(), QUrl(""));
+ obj = valid.create();
+ QVERIFY(obj);
+ QVERIFY(valid.errorString().isEmpty());
+ delete obj;
+
+ QDeclarativeComponent invalid(&engine);
+ invalid.setData("import QtQuick 1.0; " + code.toUtf8(), QUrl(""));
+ QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
+ obj = invalid.create();
+ QCOMPARE(invalid.errorString(), error);
+ delete obj;
+}
+
+void tst_QDeclarativePositioners::testQtQuick11Attributes_data()
+{
+ QTest::addColumn<QString>("code");
+ QTest::addColumn<QString>("warning");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("Flow.layoutDirection") << "Flow { layoutDirection: Qt.LeftToRight }"
+ << "QDeclarativeComponent: Component is not ready"
+ << ":1 \"Flow.layoutDirection\" is not available in QtQuick 1.0.\n";
+
+ QTest::newRow("Row.layoutDirection") << "Row { layoutDirection: Qt.LeftToRight }"
+ << "QDeclarativeComponent: Component is not ready"
+ << ":1 \"Row.layoutDirection\" is not available in QtQuick 1.0.\n";
+
+ QTest::newRow("Grid.layoutDirection") << "Grid { layoutDirection: Qt.LeftToRight }"
+ << "QDeclarativeComponent: Component is not ready"
+ << ":1 \"Grid.layoutDirection\" is not available in QtQuick 1.0.\n";
+}
+
+QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+
+QTEST_MAIN(tst_QDeclarativePositioners)
+
+#include "tst_qdeclarativepositioners.moc"