summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptextqobject
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-25 15:54:51 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-25 15:54:51 (GMT)
commit3671dbf34940e166b747b6f8f3f5758fd486073c (patch)
tree73dfe3d7d5150f4f6cbeac8ead747eedfd323123 /tests/auto/qscriptextqobject
parent194013d9db1b3e4ba6f56a864f3b64f523202948 (diff)
parent3343298448da3f2546b0708670effb798f762c5c (diff)
downloadQt-3671dbf34940e166b747b6f8f3f5758fd486073c.zip
Qt-3671dbf34940e166b747b6f8f3f5758fd486073c.tar.gz
Qt-3671dbf34940e166b747b6f8f3f5758fd486073c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (153 commits) Use QTRY_COMPARE after QTest::qWaitForWindowShown() Use the new memory cost reporting API in QtScript Custom Class example QtScript: Add API for reporting additional memory costs Add experimental support for StaticContents in Mac OS X. Fix misspelling in function name. don't just return the first key here. Fix CI sytem build breakage. Fix crash. Compile with QT_NO_NETWORKINTERFACE defined. Don't emit signals in constructor. Remove unused code. fix multiple promps for keychain access when connecting to wifi network not all interfaces should be active Update changelog Fix qcombobox:flaggedItems autotest failure. Wrong value for PM_ScrollBarExtent on Windows XP. doc: Fixed all the remaining qdoc errors. For now. Do not move keyboard focus to invisible windows on X11. Do not use _NET_ACTIVE_WINDOW for nonmanaged windows. Revert "Revert "Make QWidget::activateWindow() NET window manager aware."" ...
Diffstat (limited to 'tests/auto/qscriptextqobject')
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp87
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"