diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-03-25 22:09:36 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-03-25 22:09:36 (GMT) |
commit | 11b9190a182c5f3c1055c100145b02a3975509ed (patch) | |
tree | 2c664ad92363204c320e23f9d1e6ca29505eaf2e /tests/auto/qscriptextqobject | |
parent | 03686225036ebfc5cf78e3fcc66f5810a140c7d2 (diff) | |
parent | 3671dbf34940e166b747b6f8f3f5758fd486073c (diff) | |
download | Qt-11b9190a182c5f3c1055c100145b02a3975509ed.zip Qt-11b9190a182c5f3c1055c100145b02a3975509ed.tar.gz Qt-11b9190a182c5f3c1055c100145b02a3975509ed.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Conflicts:
src/declarative/graphicsitems/qdeclarativeitem.cpp
Diffstat (limited to 'tests/auto/qscriptextqobject')
-rw-r--r-- | tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index b4ce561..c1496f7 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -533,6 +533,7 @@ private slots: void objectDeleted(); void connectToDestroyedSignal(); void emitAfterReceiverDeleted(); + void inheritedSlots(); private: QScriptEngine *m_engine; @@ -2658,6 +2659,21 @@ void tst_QScriptExtQObject::enumerate_data() << "mySignal()" // slots << "mySlot()" << "myOtherSlot()"); + + QTest::newRow( "don't enumerate slots" ) + << int(QScriptEngine::ExcludeSlots) + << (QStringList() + // meta-object-defined properties: + // inherited + << "objectName" + // non-inherited + << "p1" << "p2" << "p4" << "p6" + // dynamic properties + << "dp1" << "dp2" << "dp3" + // inherited signals + << "destroyed(QObject*)" << "destroyed()" + // signals + << "mySignal()"); } void tst_QScriptExtQObject::enumerate() @@ -2850,6 +2866,28 @@ void tst_QScriptExtQObject::wrapOptions() QVERIFY(obj.property("intProperty").isValid()); QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember); } + // exclude slots + { + QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership, + QScriptEngine::ExcludeSlots); + QVERIFY(!obj.property("deleteLater").isValid()); + QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember)); + QVERIFY(!obj.property("mySlot").isValid()); + QVERIFY(!(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember)); + + QVERIFY(obj.property("myInvokable").isFunction()); + QVERIFY(obj.propertyFlags("myInvokable") & QScriptValue::QObjectMember); + + QVERIFY(obj.property("mySignal").isFunction()); + QVERIFY(obj.propertyFlags("mySignal") & QScriptValue::QObjectMember); + QVERIFY(obj.property("destroyed").isFunction()); + QVERIFY(obj.propertyFlags("destroyed") & QScriptValue::QObjectMember); + + QVERIFY(obj.property("objectName").isValid()); + QVERIFY(obj.propertyFlags("objectName") & QScriptValue::QObjectMember); + QVERIFY(obj.property("intProperty").isValid()); + QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember); + } // exclude all that we can { QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership, @@ -2871,6 +2909,33 @@ void tst_QScriptExtQObject::wrapOptions() QCOMPARE(obj.property("child") .strictlyEquals(QScriptValue(m_engine, 123)), true); } + // exclude absolutely all that we can + { + QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership, + QScriptEngine::ExcludeSuperClassMethods + | QScriptEngine::ExcludeSuperClassProperties + | QScriptEngine::ExcludeChildObjects + | QScriptEngine::ExcludeSlots); + QVERIFY(!obj.property("deleteLater").isValid()); + QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember)); + + QVERIFY(!obj.property("mySlot").isValid()); + QVERIFY(!(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember)); + + QVERIFY(obj.property("mySignal").isFunction()); + QVERIFY(obj.propertyFlags("mySignal") & QScriptValue::QObjectMember); + + QVERIFY(obj.property("myInvokable").isFunction()); + QVERIFY(obj.propertyFlags("myInvokable") & QScriptValue::QObjectMember); + + QVERIFY(!obj.property("objectName").isValid()); + QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember)); + + QVERIFY(obj.property("intProperty").isValid()); + QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember); + + QVERIFY(!obj.property("child").isValid()); + } delete child; } @@ -3043,5 +3108,27 @@ void tst_QScriptExtQObject::emitAfterReceiverDeleted() } } +void tst_QScriptExtQObject::inheritedSlots() +{ + QScriptEngine eng; + + QPushButton prototypeButton; + QScriptValue scriptPrototypeButton = eng.newQObject(&prototypeButton); + + QPushButton button; + QScriptValue scriptButton = eng.newQObject(&button, QScriptEngine::QtOwnership, + QScriptEngine::ExcludeSlots); + scriptButton.setPrototype(scriptPrototypeButton); + + QVERIFY(scriptButton.property("click").isFunction()); + QVERIFY(scriptButton.property("click").strictlyEquals(scriptPrototypeButton.property("click"))); + + QSignalSpy prototypeButtonClickedSpy(&prototypeButton, SIGNAL(clicked())); + QSignalSpy buttonClickedSpy(&button, SIGNAL(clicked())); + scriptButton.property("click").call(scriptButton); + QCOMPARE(buttonClickedSpy.count(), 1); + QCOMPARE(prototypeButtonClickedSpy.count(), 0); +} + QTEST_MAIN(tst_QScriptExtQObject) #include "tst_qscriptextqobject.moc" |