diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2012-05-11 12:01:41 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-24 12:52:43 +0200 |
commit | d2e557c2c2d7fcf3bf7c1676df3902e115986dc2 (patch) | |
tree | 65f47e443efa9635a2634880c01dc439817f9566 /tests/auto/qml | |
parent | 0a3ff88f851771e52d119fab90c0254de6950585 (diff) |
Lazily create QMetaObjects
For internal QML built types, creating a metaobject each time is
just wasteful. Additionally, as the property caches were always
created from the intermediate QMetaObject, it was difficult to pass
information directly from the compiler to the property cache.
Change-Id: I769526b0edaaf16a86883f3065b75618b94e4077
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests/auto/qml')
10 files changed, 53 insertions, 10 deletions
diff --git a/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro index 1c088860e5..847665b8f4 100644 --- a/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro +++ b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro @@ -6,4 +6,4 @@ SOURCES += tst_qqmlcpputils.cpp CONFIG += parallel_test -QT += core-private gui-private qml-private testlib +QT += core-private gui-private qml-private testlib v8-private diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp index 186b82a0a8..4189f441a2 100644 --- a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp +++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp @@ -73,7 +73,7 @@ void tst_qqmlcpputils::fastConnect() { { MyObject *obj = new MyObject; - FAST_CONNECT(obj, SIGNAL(signal1()), obj, SLOT(slot1())); + qmlobject_connect(obj, MyObject, SIGNAL(signal1()), obj, MyObject, SLOT(slot1())); obj->signal1(); QCOMPARE(obj->slotCount, 1); @@ -83,7 +83,7 @@ void tst_qqmlcpputils::fastConnect() { MyObject obj; - FAST_CONNECT(&obj, SIGNAL(signal1()), &obj, SLOT(slot1())) + qmlobject_connect(&obj, MyObject, SIGNAL(signal1()), &obj, MyObject, SLOT(slot1())) obj.signal1(); QCOMPARE(obj.slotCount, 1); @@ -92,7 +92,7 @@ void tst_qqmlcpputils::fastConnect() { MyObject *obj = new MyObject; QSignalSpy spy(obj, SIGNAL(signal2())); - FAST_CONNECT(obj, SIGNAL(signal1()), obj, SIGNAL(signal2())); + qmlobject_connect(obj, MyObject, SIGNAL(signal1()), obj, MyObject, SIGNAL(signal2())); obj->signal1(); QCOMPARE(spy.count(), 1); diff --git a/tests/auto/qml/qqmlecmascript/data/secondAlias.qml b/tests/auto/qml/qqmlecmascript/data/secondAlias.qml new file mode 100644 index 0000000000..d818be34b2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/secondAlias.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property int prop1: 100 + property int prop2: 100 + + property alias alias1: root.prop1 + property alias alias2: root.prop2 + + property int test: root.alias2 + + Component.onCompleted: root.prop2 = 200 +} diff --git a/tests/auto/qml/qqmlecmascript/data/varAlias.qml b/tests/auto/qml/qqmlecmascript/data/varAlias.qml new file mode 100644 index 0000000000..4d1aee2e6d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/varAlias.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property int test: root.aliasProperty.value + property alias aliasProperty: root.varProperty + property var varProperty: new Object({ value: 192 }); +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 30adb33739..f907a1cb21 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -266,6 +266,8 @@ private slots: void signalEmitted(); void threadSignal(); void qqmldataDestroyed(); + void secondAlias(); + void varAlias(); private: static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -6852,6 +6854,25 @@ void tst_qqmlecmascript::qqmldataDestroyed() } } +void tst_qqmlecmascript::secondAlias() +{ + QQmlComponent c(&engine, testFileUrl("secondAlias.qml")); + QObject *object = c.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toInt(), 200); + delete object; +} + +// An alias to a var property works +void tst_qqmlecmascript::varAlias() +{ + QQmlComponent c(&engine, testFileUrl("varAlias.qml")); + QObject *object = c.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toInt(), 192); + delete object; +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlglobal/qqmlglobal.pro b/tests/auto/qml/qqmlglobal/qqmlglobal.pro index b39c04500c..42ce3b5297 100644 --- a/tests/auto/qml/qqmlglobal/qqmlglobal.pro +++ b/tests/auto/qml/qqmlglobal/qqmlglobal.pro @@ -4,4 +4,4 @@ SOURCES += tst_qqmlglobal.cpp macx:CONFIG -= app_bundle CONFIG += parallel_test -QT += qml-private testlib +QT += qml-private testlib v8-private core-private diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index 5fe15a64fe..b4c83b35aa 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -119,7 +119,6 @@ void tst_qqmlinstruction::dump() { QQmlCompiledData::Instruction::StoreMetaObject i; - i.data = 3; i.aliasData = 6; i.propertyCache = 7; @@ -512,7 +511,7 @@ void tst_qqmlinstruction::dump() << "2\t\tSETID\t\t\t0\t\t\t\"testId\"" << "3\t\tSET_DEFAULT" << "4\t\tCREATE_COMPONENT\t3" - << "5\t\tSTORE_META\t\t3" + << "5\t\tSTORE_META\t\t" << "6\t\tSTORE_FLOAT\t\t3\t11.3" << "7\t\tSTORE_DOUBLE\t\t4\t14.8" << "8\t\tSTORE_INTEGER\t\t5\t9" diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp index bcb8ee8963..b4e77dd266 100644 --- a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp +++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp @@ -537,7 +537,7 @@ void tst_qqmllistreference::engineTypes() QVERIFY(o); QQmlProperty p1(o, QLatin1String("myList")); - QVERIFY(p1.propertyTypeCategory() == QQmlProperty::Normal); + QVERIFY(p1.propertyTypeCategory() == QQmlProperty::List); QQmlProperty p2(o, QLatin1String("myList"), engine.rootContext()); QVERIFY(p2.propertyTypeCategory() == QQmlProperty::List); diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp index 8e35c24b7d..d4f4fc0500 100644 --- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp +++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp @@ -388,7 +388,6 @@ void tst_QQmlMetaObject::method() for (int i = 0; i < parameterTypes.size(); ++i) QCOMPARE(method.parameterType(i), parameterTypes.at(i)); QCOMPARE(method.parameterTypes(), parameterTypeNames); - QCOMPARE(method.parameterNames(), parameterNames); QCOMPARE(method.tag(), ""); QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName); diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 12a8325f97..248cc0d803 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -1854,7 +1854,7 @@ void tst_qqmlproperty::warnOnInvalidBinding() QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); // V8 error message for invalid binding to anchor - expectedWarning = testUrl.toString() + QString::fromLatin1(":14: Unable to assign QQuickItem_QML_7 to QQuickAnchorLine"); + expectedWarning = testUrl.toString() + QString::fromLatin1(":14: Unable to assign QQuickItem_QML_6 to QQuickAnchorLine"); QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); QQmlComponent component(&engine, testUrl); |