summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-09-23 04:50:05 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-09-23 04:50:05 (GMT)
commita9257dfbd53dd8ac156b5f88cd3852bb141e9298 (patch)
tree83ccecba1572dd467597b77c325a31b67e99787d /tests
parent8eef6f3acc895a2f72a8c353714b67832744bd08 (diff)
parent8302f03e137a73543ab52ff451781617ce8a8760 (diff)
downloadQt-a9257dfbd53dd8ac156b5f88cd3852bb141e9298.zip
Qt-a9257dfbd53dd8ac156b5f88cd3852bb141e9298.tar.gz
Qt-a9257dfbd53dd8ac156b5f88cd3852bb141e9298.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml6
-rw-r--r--tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml8
-rw-r--r--tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml11
-rw-r--r--tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml7
-rw-r--r--tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml14
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp80
-rw-r--r--tests/auto/declarative/repeater/data/repeater.qml6
-rw-r--r--tests/auto/declarative/repeater/repeater.pro1
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp30
9 files changed, 158 insertions, 5 deletions
diff --git a/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml b/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml
new file mode 100644
index 0000000..b4a702b
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int c1: 0
+ property int c2: c1
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml
new file mode 100644
index 0000000..13c5ae5
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml
@@ -0,0 +1,8 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int c1: 0
+ property int c2: c1
+
+ onBasicSignal: c2 = 13
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml
new file mode 100644
index 0000000..d205526
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml
@@ -0,0 +1,11 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property alias c1: MyConstants.c1
+ property alias c2: MyConstants.c2
+
+ objectProperty: ConstantsOverrideBindings {
+ id: MyConstants
+ c2: 10
+ }
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml
new file mode 100644
index 0000000..ca9d1d8
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml
@@ -0,0 +1,7 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int c1: 0
+ property int c2: c1
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml
new file mode 100644
index 0000000..49ada1f
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml
@@ -0,0 +1,14 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property alias c1: MyConstants.c1
+ property alias c2: MyConstants.c2
+ property int c3: 0
+
+ objectProperty: ConstantsOverrideBindings {
+ id: MyConstants
+ c2: c3
+ }
+
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 40e4fff..f01e9d4 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -46,6 +46,8 @@ private slots:
void extensionObjects();
void enums();
void valueTypeFunctions();
+ void constantsOverrideBindings();
+ void outerBindingOverridesInnerBinding();
private:
QmlEngine engine;
@@ -401,6 +403,84 @@ void tst_qmlecmascript::valueTypeFunctions()
QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
}
+/*
+Tests that writing a constant to a property with a binding on it disables the
+binding.
+*/
+void tst_qmlecmascript::constantsOverrideBindings()
+{
+ // From ECMAScript
+ {
+ QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(8));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ }
+
+ // During construction
+ {
+ QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ }
+
+ // From C++
+ {
+ QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ object->setProperty("c2", QVariant(13));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(7));
+ QCOMPARE(object->property("c1").toInt(), 7);
+ QCOMPARE(object->property("c2").toInt(), 13);
+ }
+}
+
+/*
+Tests that assigning a binding to a property that already has a binding causes
+the original binding to be disabled.
+*/
+void tst_qmlecmascript::outerBindingOverridesInnerBinding()
+{
+ QmlComponent component(&engine, TEST_FILE("outerBindingOverridesInnerBinding.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c3", QVariant(8));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 8);
+ QCOMPARE(object->property("c3").toInt(), 8);
+}
QTEST_MAIN(tst_qmlecmascript)
diff --git a/tests/auto/declarative/repeater/data/repeater.qml b/tests/auto/declarative/repeater/data/repeater.qml
index 57ba9dc..7d83230 100644
--- a/tests/auto/declarative/repeater/data/repeater.qml
+++ b/tests/auto/declarative/repeater/data/repeater.qml
@@ -6,6 +6,9 @@ Rectangle {
width: 240
height: 320
color: "white"
+ Text {
+ text: "Zero"
+ }
Repeater {
id: repeater
objectName: "repeater"
@@ -19,4 +22,7 @@ Rectangle {
}
}
}
+ Text {
+ text: "Last"
+ }
}
diff --git a/tests/auto/declarative/repeater/repeater.pro b/tests/auto/declarative/repeater/repeater.pro
index 0ecd7ee..1d30b7b 100644
--- a/tests/auto/declarative/repeater/repeater.pro
+++ b/tests/auto/declarative/repeater/repeater.pro
@@ -1,6 +1,7 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
SOURCES += tst_repeater.cpp
+macx:CONFIG -= app_bundle
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
index 5fce70e..1bb746b 100644
--- a/tests/auto/declarative/repeater/tst_repeater.cpp
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -24,6 +24,11 @@ tst_QFxRepeater::tst_QFxRepeater()
{
}
+/*
+The Repeater element creates children at its own position in its parent's
+stacking order. In this test we insert a repeater between two other Text
+elements to test this.
+*/
void tst_QFxRepeater::stringList()
{
QmlView *canvas = createView(SRCDIR "/data/repeater.qml");
@@ -46,12 +51,27 @@ void tst_QFxRepeater::stringList()
QFxItem *container = findItem<QFxItem>(canvas->root(), "container");
QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), data.count() + 1);
+ QCOMPARE(container->childItems().count(), data.count() + 3);
+
+ for (int i = 0; i < container->childItems().count(); ++i) {
+
+ if (i == 0) {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Zero"));
+ } else if (i == 1) {
+ // The repeater itself
+ continue;
+ } else if (i == container->childItems().count() - 1) {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Last"));
+ } else {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), data.at(i-2));
+ }
- for (int i = 1; i < container->childItems().count(); ++i) {
- QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), data.at(i-1));
}
delete canvas;