summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-04-20 05:15:44 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-04-20 05:15:44 (GMT)
commit3f37769fffe250fc9ec65c725e05fefe9c85c08a (patch)
treef6e872581ddbef8f647ec2131b915cd5ea15a788 /tests
parent2801cc86b442e3a1256e48ffdf6dd92ffeb74a17 (diff)
parent78c78085449149b5c48bbecd49424974cdf79bee (diff)
downloadQt-3f37769fffe250fc9ec65c725e05fefe9c85c08a.zip
Qt-3f37769fffe250fc9ec65c725e05fefe9c85c08a.tar.gz
Qt-3f37769fffe250fc9ec65c725e05fefe9c85c08a.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp30
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp39
4 files changed, 69 insertions, 20 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml
new file mode 100644
index 0000000..3fd9131
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml
@@ -0,0 +1,9 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property bool runTest: false
+
+ property variant a: MyQmlObject {}
+
+ objectProperty: (runTest == false)?a:null
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml
new file mode 100644
index 0000000..19b0c42
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml
@@ -0,0 +1,11 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ objectProperty: MyQmlObject {}
+
+ Component.onCompleted: {
+ objectProperty = null;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index a2ecf74..6939290 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -141,6 +141,7 @@ private slots:
void variantsAssignedUndefined();
void qtbug_9792();
void noSpuriousWarningsAtShutdown();
+ void canAssignNullToQObject();
void callQtInvokables();
private:
@@ -2190,6 +2191,35 @@ void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown()
}
}
+void tst_qdeclarativeecmascript::canAssignNullToQObject()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.1.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() != 0);
+
+ o->setProperty("runTest", true);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.2.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index bd3186a..a016fa7 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -566,10 +566,10 @@ void tst_qdeclarativestates::anchorChanges()
rect->setState("right");
QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->anchors()->right().item, rect->right().item);
- QCOMPARE(aChanges->anchors()->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(aChanges->object()->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item);
+ QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine);
rect->setState("");
QCOMPARE(innerRect->x(), qreal(5));
@@ -589,7 +589,6 @@ void tst_qdeclarativestates::anchorChanges2()
QVERIFY(innerRect != 0);
rect->setState("right");
- QEXPECT_FAIL("", "QTBUG-5338", Continue);
QCOMPARE(innerRect->x(), qreal(150));
rect->setState("");
@@ -625,14 +624,14 @@ void tst_qdeclarativestates::anchorChanges3()
rect->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->anchors()->left().item, leftGuideline->left().item);
- QCOMPARE(aChanges->anchors()->left().anchorLine, leftGuideline->left().anchorLine);
- QCOMPARE(aChanges->anchors()->right().item, rect->right().item);
- QCOMPARE(aChanges->anchors()->right().anchorLine, rect->right().anchorLine);
- QCOMPARE(aChanges->anchors()->top().item, rect->top().item);
- QCOMPARE(aChanges->anchors()->top().anchorLine, rect->top().anchorLine);
- QCOMPARE(aChanges->anchors()->bottom().item, bottomGuideline->bottom().item);
- QCOMPARE(aChanges->anchors()->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
+ QCOMPARE(aChanges->object()->anchors()->left().item, leftGuideline->left().item);
+ QCOMPARE(aChanges->object()->anchors()->left().anchorLine, leftGuideline->left().anchorLine);
+ QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item);
+ QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(aChanges->object()->anchors()->top().item, rect->top().item);
+ QCOMPARE(aChanges->object()->anchors()->top().anchorLine, rect->top().anchorLine);
+ QCOMPARE(aChanges->object()->anchors()->bottom().item, bottomGuideline->bottom().item);
+ QCOMPARE(aChanges->object()->anchors()->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
QCOMPARE(innerRect->x(), qreal(10));
QCOMPARE(innerRect->y(), qreal(0));
@@ -675,10 +674,10 @@ void tst_qdeclarativestates::anchorChanges4()
rect->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->anchors()->verticalCenter().item, leftGuideline->verticalCenter().item);
- QCOMPARE(aChanges->anchors()->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
+ QCOMPARE(aChanges->object()->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->object()->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->object()->anchors()->verticalCenter().item, leftGuideline->verticalCenter().item);
+ QCOMPARE(aChanges->object()->anchors()->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
delete rect;
}
@@ -710,10 +709,10 @@ void tst_qdeclarativestates::anchorChanges5()
rect->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item);
- QCOMPARE(aChanges->anchors()->baseline().anchorLine, leftGuideline->baseline().anchorLine);
+ //QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ //QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ //QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item);
+ //QCOMPARE(aChanges->anchors()->baseline().anchorLine, leftGuideline->baseline().anchorLine);
delete rect;
}