summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2009-07-22 11:10:13 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2009-07-22 11:22:27 (GMT)
commite65c3ea459bac468024bbe08c5b841b36c82c547 (patch)
tree88baf270345dc900d032629a02081d2f6985a3e3 /tests
parent5d2ad577a42c8cbdd095ef336dd4275638901d59 (diff)
downloadQt-e65c3ea459bac468024bbe08c5b841b36c82c547.zip
Qt-e65c3ea459bac468024bbe08c5b841b36c82c547.tar.gz
Qt-e65c3ea459bac468024bbe08c5b841b36c82c547.tar.bz2
Implement qobjectProtoFuncFindChildren()
For matching the regular expression, the algorithm of JSCore is used instead of QRegExp, this is done to be consistent with the rest of ecmascript. Reviewed-by: Kent Hansen
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscriptqobject/tst_qscriptqobject.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
index 1f89022..c456f1c 100644
--- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
+++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
@@ -2276,7 +2276,7 @@ void tst_QScriptExtQObject::findChild()
QCOMPARE(result.isNull(), true);
}
- {
+ {
QScriptValue result = m_engine->evaluate("myObject.findChild('myChildObject')");
QCOMPARE(result.isQObject(), true);
QCOMPARE(result.toQObject(), child);
@@ -2287,7 +2287,6 @@ void tst_QScriptExtQObject::findChild()
void tst_QScriptExtQObject::findChildren()
{
- QSKIP("Not implemented", SkipAll);
QObject *child = new QObject(m_myObject);
child->setObjectName(QLatin1String("myChildObject"));
@@ -2353,6 +2352,35 @@ void tst_QScriptExtQObject::findChildren()
QVERIFY(count == 0);
}
+ // matchall regexp
+ {
+ QScriptValue result = m_engine->evaluate("myObject.findChildren(/.*/)");
+ QVERIFY(result.isArray());
+ int count = 3;
+ QCOMPARE(result.property("length").toInt32(), count);
+ for (int i = 0; i < 3; ++i) {
+ QObject *o = result.property(i).toQObject();
+ if (o == namelessChild || o == child || o == anotherChild)
+ --count;
+ }
+ QVERIFY(count == 0);
+ }
+
+ // matchall regexp my*
+ {
+ QScriptValue result = m_engine->evaluate("myObject.findChildren(new RegExp(\"^my.*\"))");
+ QCOMPARE(result.isArray(), true);
+ QCOMPARE(result.property(QLatin1String("length")).toNumber(), 2.0);
+ QObject *o1 = result.property(QLatin1String("0")).toQObject();
+ QObject *o2 = result.property(QLatin1String("1")).toQObject();
+ if (o1 != child) {
+ QCOMPARE(o1, anotherChild);
+ QCOMPARE(o2, child);
+ } else {
+ QCOMPARE(o1, child);
+ QCOMPARE(o2, anotherChild);
+ }
+ }
delete anotherChild;
delete namelessChild;
delete child;