tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp	Fri Sep 17 08:34:18 2010 +0300
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp	Mon Oct 04 01:19:32 2010 +0300
@@ -157,10 +157,15 @@
     void qtbug_10696();
     void qtbug_11606();
     void qtbug_11600();
+    void nonscriptable();
+    void deleteLater();
+    void in();
 
     void include();
 
     void callQtInvokables();
+    void invokableObjectArg();
+    void invokableObjectRet();
 private:
     QDeclarativeEngine engine;
 };
@@ -1730,6 +1735,31 @@
     QCOMPARE(o.actuals().at(0), QVariant(9));
 }
 
+// QTBUG-13047 (check that you can pass registered object types as args)
+void tst_qdeclarativeecmascript::invokableObjectArg()
+{
+    QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectArg.qml"));
+
+    QObject *o = component.create();
+    QVERIFY(o);
+    MyQmlObject *qmlobject = qobject_cast<MyQmlObject *>(o);
+    QVERIFY(qmlobject);
+    QCOMPARE(qmlobject->myinvokableObject, qmlobject);
+
+    delete o;
+}
+
+// QTBUG-13047 (check that you can return registered object types from methods)
+void tst_qdeclarativeecmascript::invokableObjectRet()
+{
+    QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectRet.qml"));
+
+    QObject *o = component.create();
+    QVERIFY(o);
+    QCOMPARE(o->property("test").toBool(), true);
+    delete o;
+}
+
 // QTBUG-5675
 void tst_qdeclarativeecmascript::listToVariant()
 {
@@ -2530,6 +2560,36 @@
     delete o;
 }
 
+// Reading and writing non-scriptable properties should fail
+void tst_qdeclarativeecmascript::nonscriptable()
+{
+    QDeclarativeComponent component(&engine, TEST_FILE("nonscriptable.qml"));
+    QObject *o = component.create();
+    QVERIFY(o != 0);
+    QCOMPARE(o->property("readOk").toBool(), true);
+    QCOMPARE(o->property("writeOk").toBool(), true);
+    delete o;
+}
+
+// deleteLater() should not be callable from QML
+void tst_qdeclarativeecmascript::deleteLater()
+{
+    QDeclarativeComponent component(&engine, TEST_FILE("deleteLater.qml"));
+    QObject *o = component.create();
+    QVERIFY(o != 0);
+    QCOMPARE(o->property("test").toBool(), true);
+    delete o;
+}
+
+void tst_qdeclarativeecmascript::in()
+{
+    QDeclarativeComponent component(&engine, TEST_FILE("in.qml"));
+    QObject *o = component.create();
+    QVERIFY(o != 0);
+    QCOMPARE(o->property("test1").toBool(), true);
+    QCOMPARE(o->property("test2").toBool(), true);
+    delete o;
+}
 
 QTEST_MAIN(tst_qdeclarativeecmascript)