summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-30 14:10:56 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-30 14:10:56 (GMT)
commit7a04df50d6ea4c2d7ee1c8fdea7a7c259636db17 (patch)
tree98b77946ae2b98c7e28f444b56d60c358c28af84 /tests/auto
parentfcca6e40558e7b146d69ad82b3da2ff19ed5cf76 (diff)
downloadQt-7a04df50d6ea4c2d7ee1c8fdea7a7c259636db17.zip
Qt-7a04df50d6ea4c2d7ee1c8fdea7a7c259636db17.tar.gz
Qt-7a04df50d6ea4c2d7ee1c8fdea7a7c259636db17.tar.bz2
implement name-based connection, make more tests work
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qscriptqobject/tst_qscriptqobject.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
index 969e80f..9fd4eae 100644
--- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
+++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
@@ -494,6 +494,7 @@ private slots:
void getSetChildren();
void callQtInvokable();
void connectAndDisconnect();
+ void connectAndDisconnectWithBadArgs();
void cppConnectAndDisconnect();
void classEnums();
void classConstructor();
@@ -741,6 +742,8 @@ void tst_QScriptExtQObject::getSetStaticProperty()
// test that we do value conversion if necessary when setting properties
{
QScriptValue br = m_engine->evaluate("myObject.brushProperty");
+ QVERIFY(br.isVariant());
+ QVERIFY(!br.strictlyEquals(m_engine->evaluate("myObject.brushProperty")));
QCOMPARE(qscriptvalue_cast<QBrush>(br), m_myObject->brushProperty());
QCOMPARE(qscriptvalue_cast<QColor>(br), m_myObject->brushProperty().color());
@@ -848,6 +851,15 @@ void tst_QScriptExtQObject::getSetStaticProperty()
mobj.setProperty("intProperty", m_engine->newFunction(getSetProperty),
QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
}
+
+ // method properties are persistent
+ {
+ QScriptValue slot = m_engine->evaluate("myObject.mySlot");
+ QVERIFY(slot.isFunction());
+ QScriptValue sameSlot = m_engine->evaluate("myObject.mySlot");
+ QEXPECT_FAIL("", "Slot wrappers aren't persistent yet", Continue);
+ QVERIFY(sameSlot.strictlyEquals(slot));
+ }
}
void tst_QScriptExtQObject::getSetDynamicProperty()
@@ -1644,6 +1656,7 @@ void tst_QScriptExtQObject::connectAndDisconnect()
QVERIFY(m_engine->evaluate("myObject.mySignal.connect(yetAnotherObject, 'func')").isUndefined());
QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject, 'mySlot')").isUndefined());
QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(yetAnotherObject, 'func')").isUndefined());
+ QEXPECT_FAIL("", "Slot wrappers aren't persistent yet", Continue);
QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myObject, 'mySlot')").isUndefined());
// check that emitting signals from script works
@@ -1653,6 +1666,7 @@ void tst_QScriptExtQObject::connectAndDisconnect()
m_myObject->resetQtFunctionInvoked();
QCOMPARE(m_engine->evaluate("myObject.mySignal()").isUndefined(), true);
QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+ QEXPECT_FAIL("", "Slot wrappers aren't persistent yet", Continue);
QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myObject.mySlot)").isUndefined());
// one argument
@@ -1697,7 +1711,20 @@ void tst_QScriptExtQObject::connectAndDisconnect()
QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456);
QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject['myOverloadedSlot(int)'])").isUndefined());
- // erroneous input
+ // when the wrapper dies, the connection stays alive
+ QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined());
+ m_myObject->resetQtFunctionInvoked();
+ m_myObject->emitMySignal();
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+ m_engine->evaluate("myObject = null");
+ m_engine->collectGarbage();
+ m_myObject->resetQtFunctionInvoked();
+ m_myObject->emitMySignal();
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+}
+
+void tst_QScriptExtQObject::connectAndDisconnectWithBadArgs()
+{
{
QScriptValue ret = m_engine->evaluate("(function() { }).connect()");
QVERIFY(ret.isError());
@@ -1781,17 +1808,6 @@ void tst_QScriptExtQObject::connectAndDisconnect()
QVERIFY(ret.isError());
QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: failed to disconnect from MyQObject::mySignal()"));
}
-
- // when the wrapper dies, the connection stays alive
- QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined());
- m_myObject->resetQtFunctionInvoked();
- m_myObject->emitMySignal();
- QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
- m_engine->evaluate("myObject = null");
- m_engine->collectGarbage();
- m_myObject->resetQtFunctionInvoked();
- m_myObject->emitMySignal();
- QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
}
void tst_QScriptExtQObject::cppConnectAndDisconnect()