summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-04 23:34:16 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-04 23:34:16 (GMT)
commit8fe5ffc002f6ce3c8d7b688ddb2a7f2f7fd45dda (patch)
treee8ed4f7df795fb8c5a393a3472788283d88d33d3
parentcb48b1bd67e094446cf73d8a0940d25dc8334708 (diff)
parente68a0dafbff345eebb15cf6f1a5d88df37f0269a (diff)
downloadQt-8fe5ffc002f6ce3c8d7b688ddb2a7f2f7fd45dda.zip
Qt-8fe5ffc002f6ce3c8d7b688ddb2a7f2f7fd45dda.tar.gz
Qt-8fe5ffc002f6ce3c8d7b688ddb2a7f2f7fd45dda.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--.gitignore1
-rwxr-xr-xconfigure.exebin2170880 -> 1204224 bytes
-rw-r--r--src/declarative/qml/qmlcompiler.cpp33
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp112
-rw-r--r--src/declarative/qml/qmlmetaproperty.h6
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h5
-rw-r--r--src/declarative/qml/qmlvme.cpp6
-rw-r--r--tests/auto/declarative/declarative.pro69
-rw-r--r--tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml5
-rw-r--r--tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml2
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.1.qml4
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.2.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.3.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.4.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.4.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.5.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.6.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.6.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/defaultGrouped.qml10
-rw-r--r--tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/doubleSignal.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/emptySignal.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt2
-rw-r--r--tests/auto/declarative/qmllanguage/data/nestedErrors.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.1.qml4
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.10.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.10.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.11.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.11.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.2.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.3.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.4.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.4.qml8
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.5.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.6.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.6.qml11
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.7.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.7.qml11
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.8.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.8.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.9.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.9.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/test.js0
-rw-r--r--tests/auto/declarative/qmllanguage/data/test2.js0
-rw-r--r--tests/auto/declarative/qmllanguage/qmllanguage.pro1
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.h19
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp32
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp820
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/data/model2.qml11
59 files changed, 1157 insertions, 145 deletions
diff --git a/.gitignore b/.gitignore
index 926de5b..f75cc75 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@ Makefile*
*.prl
*.app
*.pro.user
+*.gcov
bin/Qt*.dll
bin/assistant*
bin/designer*
diff --git a/configure.exe b/configure.exe
index dabf10c..30e881e 100755
--- a/configure.exe
+++ b/configure.exe
Binary files differ
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 3253e72..240f16c 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -814,8 +814,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj)
create.create.type = obj->type;
if (!output->types.at(create.create.type).type &&
!obj->bindingBitmask.isEmpty()) {
- while (obj->bindingBitmask.size() % 4)
- obj->bindingBitmask.append(char(0));
+ Q_ASSERT(obj->bindingBitmask.size() % 4 == 0);
create.create.bindingBits =
output->indexForByteArray(obj->bindingBitmask);
} else {
@@ -1044,20 +1043,23 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
// Find, check and set the "id" property (if any)
Property *idProp = 0;
if (obj->properties.count() > 1 ||
- (obj->properties.count() == 1 && obj->properties.begin().key() != "id") ||
- !obj->scriptBlockObjects.isEmpty())
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component specification"));
+ (obj->properties.count() == 1 && obj->properties.begin().key() != "id"))
+ COMPILE_EXCEPTION(*obj->properties.begin(), qApp->translate("QmlCompiler","Invalid component specification"));
+
+ if (!obj->scriptBlockObjects.isEmpty())
+ COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), qApp->translate("QmlCompiler","Invalid component specification"));
if (obj->properties.count())
idProp = *obj->properties.begin();
+
if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component id specification"));
+ COMPILE_EXCEPTION(idProp, qApp->translate("QmlCompiler","Invalid component id specification"));
if (idProp) {
QString idVal = idProp->values.first()->primitive();
if (compileState.ids.contains(idVal))
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","id is not unique"));
+ COMPILE_EXCEPTION(idProp, qApp->translate("QmlCompiler","id is not unique"));
obj->id = idVal;
addId(idVal, obj);
@@ -1093,7 +1095,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script)
Property *source = *script->properties.begin();
if (script->defaultProperty)
- COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script."));
+ COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script"));
if (source->value || source->values.count() != 1 ||
source->values.at(0)->object || !source->values.at(0)->value.isString())
@@ -1180,12 +1182,10 @@ bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
bool QmlCompiler::buildSubObject(Object *obj, const BindingContext &ctxt)
{
Q_ASSERT(obj->metatype);
+ Q_ASSERT(!obj->defaultProperty);
Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
// sub-context
- if (obj->defaultProperty)
- COMPILE_CHECK(buildProperty(obj->defaultProperty, obj, ctxt));
-
foreach(Property *prop, obj->properties) {
if (isSignalPropertyName(prop->name)) {
COMPILE_CHECK(buildSignal(prop, obj, ctxt));
@@ -1230,9 +1230,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
const BindingContext &ctxt)
{
Q_ASSERT(obj->metaObject());
-
- if (prop->isEmpty())
- COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty property assignment"));
+ Q_ASSERT(!prop->isEmpty());
QByteArray name = prop->name;
Q_ASSERT(name.startsWith("on"));
@@ -1261,6 +1259,10 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
prop->values.at(0)->type = Value::SignalObject;
} else {
prop->values.at(0)->type = Value::SignalExpression;
+
+ QString script = prop->values.at(0)->value.asScript().trimmed();
+ if (script.isEmpty())
+ COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty signal assignment"));
}
}
@@ -1701,6 +1703,9 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
Q_ASSERT(prop->type != 0);
Q_ASSERT(prop->index != -1);
+ if (prop->values.count())
+ COMPILE_EXCEPTION(prop->values.first(), qApp->translate("QmlCompiler", "Invalid value in grouped property"));
+
if (prop->type < (int)QVariant::UserType) {
QmlEnginePrivate *ep =
static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index f340612..4ad9aac 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -111,27 +111,12 @@ void QmlMetaPropertyPrivate::initDefault(QObject *obj)
if (!obj)
return;
- object = obj;
QMetaProperty p = QmlMetaType::defaultProperty(obj);
core.load(p);
- if (core.isValid())
+ if (core.isValid()) {
isDefaultProperty = true;
-}
-
-/*!
- \internal
-
- Creates a QmlMetaProperty for the property at index \a idx of \a obj.
- */
-QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt)
-: d(new QmlMetaPropertyPrivate)
-{
- Q_ASSERT(obj);
-
- d->q = this;
- d->context = ctxt;
- d->object = obj;
- d->core.load(obj->metaObject()->property(idx));
+ object = obj;
+ }
}
/*!
@@ -142,6 +127,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name)
{
d->q = this;
d->initProperty(obj, name);
+ if (!isValid()) d->object = 0;
}
/*!
@@ -154,6 +140,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *
d->q = this;
d->context = ctxt;
d->initProperty(obj, name);
+ if (!isValid()) { d->object = 0; d->context = 0; }
}
void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
@@ -425,12 +412,14 @@ bool QmlMetaProperty::isWritable() const
{
QmlMetaProperty::PropertyCategory category = propertyCategory();
+ if (!d->object)
+ return false;
if (category == List || category == QmlList)
return true;
else if (type() & SignalProperty)
- return true;
+ return false;
else if (d->core.isValid() && d->object)
- return d->object->metaObject()->property(d->core.coreIndex).isWritable();
+ return d->core.flags & QmlPropertyCache::Data::IsWritable;
else
return false;
}
@@ -456,25 +445,6 @@ bool QmlMetaProperty::isValid() const
}
/*!
- Returns all of \a obj's Qt properties.
-*/
-QStringList QmlMetaProperty::properties(QObject *obj)
-{
- // ### What is this used for?
- if (!obj)
- return QStringList();
-
- QStringList rv;
- const QMetaObject *mo = obj->metaObject();
- for (int ii = 0; ii < mo->propertyCount(); ++ii) {
- QMetaProperty prop = mo->property(ii);
- rv << QString::fromUtf8(prop.name());
- }
-
- return rv;
-}
-
-/*!
Return the name of this QML property.
*/
QString QmlMetaProperty::name() const
@@ -494,7 +464,13 @@ QString QmlMetaProperty::name() const
return rv;
} else {
- return d->core.name;
+ if (type() & SignalProperty) {
+ QString name = QLatin1String("on") + d->core.name;
+ name[2] = name.at(2).toUpper();
+ return name;
+ } else {
+ return d->core.name;
+ }
}
}
@@ -565,8 +541,10 @@ QmlAbstractBinding *QmlMetaProperty::binding() const
QmlAbstractBinding *
QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding, QmlMetaProperty::WriteFlags flags) const
{
- if (!isProperty() || (type() & Attached) || !d->object)
+ if (!isProperty() || (type() & Attached) || !d->object) {
+ delete newBinding;
return 0;
+ }
return d->setBinding(d->object, d->core, newBinding, flags);
}
@@ -630,8 +608,10 @@ QmlExpression *QmlMetaProperty::signalExpression() const
*/
QmlExpression *QmlMetaProperty::setSignalExpression(QmlExpression *expr) const
{
- if (!(type() & SignalProperty))
+ if (!(type() & SignalProperty)) {
+ delete expr;
return 0;
+ }
const QObjectList &children = d->object->children();
@@ -686,13 +666,7 @@ QVariant QmlMetaProperty::read() const
if (type() & SignalProperty) {
- const QObjectList &children = object()->children();
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QmlBoundSignal *sig = QmlBoundSignal::cast(children.at(ii));
- if (sig && sig->index() == d->core.coreIndex)
- return sig->expression()->expression();
- }
+ return QVariant();
} else if (type() & Property) {
@@ -857,7 +831,7 @@ bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data
return false;
if (context && u.isRelative() && !u.isEmpty())
- u = context->baseUrl().resolved(u);
+ u = context->resolvedUrl(u);
int status = -1;
void *argv[] = { &u, 0, &status, &flags };
QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
@@ -990,7 +964,7 @@ bool QmlMetaProperty::write(const QVariant &value) const
bool QmlMetaProperty::write(const QVariant &value, QmlMetaProperty::WriteFlags flags) const
{
- if (d->object && type() & Property && d->core.isValid())
+ if (d->object && type() & Property && d->core.isValid() && isWritable())
return d->writeValueProperty(value, flags);
else
return false;
@@ -1083,27 +1057,6 @@ Q_GLOBAL_STATIC(QmlValueTypeFactory, qmlValueTypes);
Returns the property information serialized into a single integer.
QmlMetaProperty uses the bottom 24 bits only.
*/
-quint32 QmlMetaProperty::save() const
-{
- quint32 rv = 0;
- if (type() & Attached) {
- rv = d->attachedFunc;
- } else if (type() != Invalid) {
- rv = d->core.coreIndex;
- }
-
- Q_ASSERT(rv <= 0x7FF);
- Q_ASSERT(type() <= 0x3F);
- Q_ASSERT(d->valueTypeCoreIdx <= 0x7F);
-
- rv |= (type() << 18);
-
- if (type() & ValueTypeProperty)
- rv |= (d->valueTypeCoreIdx << 11);
-
- return rv;
-}
-
quint32 QmlMetaPropertyPrivate::saveValueType(int core, int valueType)
{
Q_ASSERT(core <= 0x7FF);
@@ -1130,8 +1083,11 @@ quint32 QmlMetaPropertyPrivate::saveProperty(int core)
to QmlMetaProperty::save(). Only the bottom 24-bits are
used, the high bits can be set to any value.
*/
-void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt)
+void QmlMetaPropertyPrivate::restore(QmlMetaProperty &prop, quint32 id,
+ QObject *obj, QmlContext *ctxt)
{
+ QmlMetaPropertyPrivate *d = prop.d;
+
QmlEnginePrivate *enginePrivate = 0;
if (ctxt && ctxt->engine())
enginePrivate = QmlEnginePrivate::get(ctxt->engine());
@@ -1143,9 +1099,9 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt)
uint type = id >> 18;
id &= 0xFFFF;
- if (type & Attached) {
+ if (type & QmlMetaProperty::Attached) {
d->attachedFunc = id;
- } else if (type & ValueTypeProperty) {
+ } else if (type & QmlMetaProperty::ValueTypeProperty) {
int coreIdx = id & 0x7FF;
int valueTypeIdx = id >> 11;
@@ -1159,7 +1115,7 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt)
d->core.load(p);
d->valueTypeCoreIdx = valueTypeIdx;
d->valueTypePropType = p2.userType();
- } else if (type & Property) {
+ } else if (type & QmlMetaProperty::Property) {
QmlPropertyCache *cache = enginePrivate?enginePrivate->cache(obj):0;
@@ -1171,12 +1127,12 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt)
d->core.load(p);
}
- } else if (type & SignalProperty) {
+ } else if (type & QmlMetaProperty::SignalProperty) {
QMetaMethod method = obj->metaObject()->method(id);
d->core.load(method);
} else {
- *this = QmlMetaProperty();
+ prop = QmlMetaProperty();
}
}
diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h
index ce4ac1e..6db99c6 100644
--- a/src/declarative/qml/qmlmetaproperty.h
+++ b/src/declarative/qml/qmlmetaproperty.h
@@ -79,10 +79,8 @@ public:
QmlMetaProperty(QObject *, const QString &, QmlContext *);
QmlMetaProperty(const QmlMetaProperty &);
QmlMetaProperty &operator=(const QmlMetaProperty &);
- QmlMetaProperty(QObject *, int, QmlContext * = 0);
~QmlMetaProperty();
- static QStringList properties(QObject *);
QString name() const;
QVariant read() const;
@@ -96,9 +94,6 @@ public:
bool connectNotifier(QObject *dest, const char *slot) const;
bool connectNotifier(QObject *dest, int method) const;
- quint32 save() const;
- void restore(quint32, QObject *, QmlContext * = 0);
-
QMetaMethod method() const;
enum Type { Invalid = 0x00,
@@ -138,6 +133,7 @@ public:
int valueTypeCoreIndex() const;
private:
friend class QmlEnginePrivate;
+ friend class QmlMetaPropertyPrivate;;
QmlMetaPropertyPrivate *d;
};
typedef QList<QmlMetaProperty> QmlMetaProperties;
diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h
index 925f1ea..d225afa 100644
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ b/src/declarative/qml/qmlmetaproperty_p.h
@@ -104,8 +104,9 @@ public:
static QmlAbstractBinding *setBinding(QObject *, const QmlPropertyCache::Data &, QmlAbstractBinding *,
QmlMetaProperty::WriteFlags flags = QmlMetaProperty::DontRemoveBinding);
- static quint32 saveValueType(int, int);
- static quint32 saveProperty(int);
+ static void Q_AUTOTEST_EXPORT restore(QmlMetaProperty &prop, quint32, QObject *, QmlContext * = 0);
+ static quint32 Q_AUTOTEST_EXPORT saveValueType(int, int);
+ static quint32 Q_AUTOTEST_EXPORT saveProperty(int);
static bool equal(const QMetaObject *, const QMetaObject *);
static bool canConvert(const QMetaObject *from, const QMetaObject *to);
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 62ec025..f3d0f65 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -591,7 +591,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt,
stack.at(stack.count() - 1 - instr.assignBinding.context);
QmlMetaProperty mp;
- mp.restore(instr.assignBinding.property, target, ctxt);
+ QmlMetaPropertyPrivate::restore(mp, instr.assignBinding.property, target, ctxt);
int coreIndex = mp.coreIndex();
@@ -648,7 +648,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt,
QmlPropertyValueSource *vs = reinterpret_cast<QmlPropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.assignValueSource.castValue);
QObject *target = stack.at(stack.count() - 1 - instr.assignValueSource.owner);
QmlMetaProperty prop;
- prop.restore(instr.assignValueSource.property, target, ctxt);
+ QmlMetaPropertyPrivate::restore(prop, instr.assignValueSource.property, target, ctxt);
obj->setParent(target);
vs->setTarget(prop);
}
@@ -660,7 +660,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt,
QmlPropertyValueInterceptor *vi = reinterpret_cast<QmlPropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.assignValueInterceptor.castValue);
QObject *target = stack.at(stack.count() - 1 - instr.assignValueInterceptor.owner);
QmlMetaProperty prop;
- prop.restore(instr.assignValueInterceptor.property, target, ctxt);
+ QmlMetaPropertyPrivate::restore(prop, instr.assignValueInterceptor.property, target, ctxt);
obj->setParent(target);
vi->setTarget(prop);
QmlVMEMetaObject *mo = static_cast<QmlVMEMetaObject *>((QMetaObject*)target->metaObject());
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index f09d6cf..1be38a8 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -1,38 +1,41 @@
TEMPLATE = subdirs
-SUBDIRS += anchors \
- animatedimage \
- animations \
- behaviors \
- datetimeformatter \
+SUBDIRS += \
+ anchors \ # Cover
+ animatedimage \ # Cover
+ animations \ # Cover
+ behaviors \ # Cover
+ datetimeformatter \ # Cover
examples \
- layouts \
- listview \
- numberformatter \
- pathview \
- qfxloader \
- qmlpixmapcache \
- qfxtextedit \
- qfxtextinput \
- qfxwebview \
- qmetaobjectbuilder \
- qmlcontext \
- qmldom \
- qmlecmascript \
- qmlgraphicstext \
- qmlgraphicsborderimage \
- qmlfontloader \
- qmllanguage \
- qmllist \
- qmllistaccessor \
- qmlmetaproperty \
- qmlmetatype \
- qmlpropertymap \
- qmltimer \
- qmlxmllistmodel \
- repeater \
- sql \
- states \
- visual
+ layouts \ # Cover
+ listview \ # Cover
+ numberformatter \ # Cover
+ pathview \ # Cover
+ qfxloader \ # Cover
+ qfxtextedit \ # Cover
+ qfxtextinput \ # Cover
+ qfxwebview \ # Cover
+ qmetaobjectbuilder \ # Cover
+ qmlcontext \ # Cover
+ qmldom \ # Cover
+ qmlecmascript \ # Cover
+ qmlfontloader \ # Cover
+ qmlgraphicsborderimage \ # Cover
+ qmlgraphicsparticles \ # Cover
+ qmlgraphicstext \ # Cover
+ qmllanguage \ # Cover
+ qmllist \ # Cover
+ qmllistaccessor \ # Cover
+ qmlmetaproperty \ # Cover
+ qmlmetatype \ # Cover
+ qmlpixmapcache \ # Cover
+ qmlpropertymap \ # Cover
+ qmlqt \ # Cover
+ qmltimer \ # Cover
+ qmlxmllistmodel \ # Cover
+ repeater \ # Cover
+ sql \ # Cover
+ states \ # Cover
+ visual # Cover
# Tests which should run in Pulse
PULSE_TESTS = $$SUBDIRS
diff --git a/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml b/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml
new file mode 100644
index 0000000..5cc8d20
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+Item {
+ x: "You can't assign a string to a real!"
+}
diff --git a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
index cef9f8d..50723a3 100644
--- a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
+++ b/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
@@ -7,6 +7,7 @@ MyTypeObject {
intProperty: -19
realProperty: 23.2
doubleProperty: -19.7
+ floatProperty: 8.5
colorProperty: "red"
dateProperty: "1982-11-25"
timeProperty: "11:11:31"
@@ -21,6 +22,7 @@ MyTypeObject {
rectFProperty: "1000.1,-10.9,400x90.99"
boolProperty: true
variantProperty: "Hello World!"
+ vectorProperty: "10,1,2.2"
objectProperty: MyTypeObject { intProperty: 8 }
}
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.errors.txt b/tests/auto/declarative/qmllanguage/data/component.1.errors.txt
new file mode 100644
index 0000000..091aad6
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.1.errors.txt
@@ -0,0 +1 @@
+3:1:Cannot create empty component specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.qml b/tests/auto/declarative/qmllanguage/data/component.1.qml
new file mode 100644
index 0000000..07e463a
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.1.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Component {
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.errors.txt b/tests/auto/declarative/qmllanguage/data/component.2.errors.txt
new file mode 100644
index 0000000..76e7656
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.2.errors.txt
@@ -0,0 +1 @@
+6:9:id is not unique
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.qml b/tests/auto/declarative/qmllanguage/data/component.2.qml
new file mode 100644
index 0000000..74a4f89
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.2.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ id: myId
+ Component {
+ id: myId
+ Object {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.errors.txt b/tests/auto/declarative/qmllanguage/data/component.3.errors.txt
new file mode 100644
index 0000000..9a13142
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.3.errors.txt
@@ -0,0 +1 @@
+6:9:Invalid component id specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.qml b/tests/auto/declarative/qmllanguage/data/component.3.qml
new file mode 100644
index 0000000..043cb6b
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.3.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ Component {
+ id: myId
+ id: myId2
+ Object {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.errors.txt b/tests/auto/declarative/qmllanguage/data/component.4.errors.txt
new file mode 100644
index 0000000..2ab18685
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.4.errors.txt
@@ -0,0 +1 @@
+3:1:Invalid component body specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.qml b/tests/auto/declarative/qmllanguage/data/component.4.qml
new file mode 100644
index 0000000..3d115ba
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.4.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Component {
+ Object {}
+ Object {}
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.errors.txt b/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
new file mode 100644
index 0000000..5e88900
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
@@ -0,0 +1 @@
+4:5:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.qml b/tests/auto/declarative/qmllanguage/data/component.5.qml
new file mode 100644
index 0000000..ab57622
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.5.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Component {
+ x: 10
+ Object {}
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.errors.txt b/tests/auto/declarative/qmllanguage/data/component.6.errors.txt
new file mode 100644
index 0000000..2b1c6ca
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.6.errors.txt
@@ -0,0 +1 @@
+4:5:Invalid component id specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.qml b/tests/auto/declarative/qmllanguage/data/component.6.qml
new file mode 100644
index 0000000..6adaf0d
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.6.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Component {
+ id: Object {}
+ Object {}
+}
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt b/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt
new file mode 100644
index 0000000..945d51b
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt
@@ -0,0 +1 @@
+7:9:Invalid value in grouped property
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml
new file mode 100644
index 0000000..39ac5e0
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ grouped {
+ script: print(1921)
+ Object {}
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt b/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt
new file mode 100644
index 0000000..2aea251
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt
@@ -0,0 +1 @@
+5:5:Incorrectly specified signal
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml
new file mode 100644
index 0000000..ec813c9
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyQmlObject {
+ onBasicSignal: print(1921)
+ onBasicSignal: print(1921)
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt b/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt
new file mode 100644
index 0000000..353bbf5
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt
@@ -0,0 +1 @@
+4:5:Empty signal assignment
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.qml b/tests/auto/declarative/qmllanguage/data/emptySignal.qml
new file mode 100644
index 0000000..4c5a122
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/emptySignal.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyQmlObject {
+ onBasicSignal: " "
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt
new file mode 100644
index 0000000..886da55
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt
@@ -0,0 +1,2 @@
+4:5:Unable to create type NestedErrorsType
+4:8:Invalid property assignment: double expected
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.qml b/tests/auto/declarative/qmllanguage/data/nestedErrors.qml
new file mode 100644
index 0000000..c0d755a
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/nestedErrors.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Item {
+ NestedErrorsType {}
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.errors.txt b/tests/auto/declarative/qmllanguage/data/script.1.errors.txt
new file mode 100644
index 0000000..50518cc
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.1.errors.txt
@@ -0,0 +1 @@
+3:1:Invalid use of Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.qml b/tests/auto/declarative/qmllanguage/data/script.1.qml
new file mode 100644
index 0000000..8dac8b7
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.1.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Script {
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.errors.txt b/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
new file mode 100644
index 0000000..8299d23
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
@@ -0,0 +1 @@
+6:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.qml b/tests/auto/declarative/qmllanguage/data/script.10.qml
new file mode 100644
index 0000000..516e878
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.10.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ Component {
+ Item {}
+ Script {}
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.errors.txt b/tests/auto/declarative/qmllanguage/data/script.11.errors.txt
new file mode 100644
index 0000000..a664203
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.11.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.qml b/tests/auto/declarative/qmllanguage/data/script.11.qml
new file mode 100644
index 0000000..d8313a3
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.11.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Object {
+ Script {
+ Object {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.errors.txt b/tests/auto/declarative/qmllanguage/data/script.2.errors.txt
new file mode 100644
index 0000000..8fb3bbd
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.2.errors.txt
@@ -0,0 +1 @@
+5:9:Properties cannot be set on Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.qml b/tests/auto/declarative/qmllanguage/data/script.2.qml
new file mode 100644
index 0000000..18bb7c8
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.2.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Object {
+ Script {
+ id: myScript
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.errors.txt b/tests/auto/declarative/qmllanguage/data/script.3.errors.txt
new file mode 100644
index 0000000..8fb3bbd
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.3.errors.txt
@@ -0,0 +1 @@
+5:9:Properties cannot be set on Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.qml b/tests/auto/declarative/qmllanguage/data/script.3.qml
new file mode 100644
index 0000000..c2296ff
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.3.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Object {
+ Script {
+ hello: world
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.errors.txt b/tests/auto/declarative/qmllanguage/data/script.4.errors.txt
new file mode 100644
index 0000000..49a507f
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.4.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script source value
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.qml b/tests/auto/declarative/qmllanguage/data/script.4.qml
new file mode 100644
index 0000000..08115c2
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.4.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: 10
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.errors.txt b/tests/auto/declarative/qmllanguage/data/script.5.errors.txt
new file mode 100644
index 0000000..49a507f
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.5.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script source value
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.qml b/tests/auto/declarative/qmllanguage/data/script.5.qml
new file mode 100644
index 0000000..a3b1a15
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.5.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: "hello" + ".js"
+ }
+}
+
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.errors.txt b/tests/auto/declarative/qmllanguage/data/script.6.errors.txt
new file mode 100644
index 0000000..4e53b6b
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.6.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script block. Specify either the source property or inline script
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.qml b/tests/auto/declarative/qmllanguage/data/script.6.qml
new file mode 100644
index 0000000..e578629
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.6.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: "test.js"
+ function helloWorld() {}
+ }
+}
+
+
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.errors.txt b/tests/auto/declarative/qmllanguage/data/script.7.errors.txt
new file mode 100644
index 0000000..dc15ddf
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.7.errors.txt
@@ -0,0 +1 @@
+5:9:Variable declarations not allow in inline Script blocks
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.qml b/tests/auto/declarative/qmllanguage/data/script.7.qml
new file mode 100644
index 0000000..6bee3f9
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.7.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+Object {
+ Script {
+ var a = 10;
+ }
+}
+
+
+
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.errors.txt b/tests/auto/declarative/qmllanguage/data/script.8.errors.txt
new file mode 100644
index 0000000..b5bf1a8
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.8.errors.txt
@@ -0,0 +1 @@
+6:9:Invalid Script source value
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.qml b/tests/auto/declarative/qmllanguage/data/script.8.qml
new file mode 100644
index 0000000..55bc05c
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.8.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: "test.js"
+ source: "test2.js"
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.errors.txt b/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
new file mode 100644
index 0000000..dc1eb53
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.qml b/tests/auto/declarative/qmllanguage/data/script.9.qml
new file mode 100644
index 0000000..79aa504
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.9.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Item {
+ Component {
+ Script {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/test.js b/tests/auto/declarative/qmllanguage/data/test.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/test.js
diff --git a/tests/auto/declarative/qmllanguage/data/test2.js b/tests/auto/declarative/qmllanguage/data/test2.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/test2.js
diff --git a/tests/auto/declarative/qmllanguage/qmllanguage.pro b/tests/auto/declarative/qmllanguage/qmllanguage.pro
index 80228a9..e45d73a 100644
--- a/tests/auto/declarative/qmllanguage/qmllanguage.pro
+++ b/tests/auto/declarative/qmllanguage/qmllanguage.pro
@@ -1,5 +1,6 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
+QT += script
macx:CONFIG -= app_bundle
SOURCES += tst_qmllanguage.cpp \
diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h
index 91c6e2e..e654faa 100644
--- a/tests/auto/declarative/qmllanguage/testtypes.h
+++ b/tests/auto/declarative/qmllanguage/testtypes.h
@@ -46,6 +46,7 @@
#include <QtCore/qdatetime.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlparserstatus.h>
@@ -185,6 +186,7 @@ class MyTypeObject : public QObject
Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty);
Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty);
Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty);
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty);
Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty);
Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty);
Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty);
@@ -198,6 +200,7 @@ class MyTypeObject : public QObject
Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty);
Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty);
Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty);
Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty);
Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT);
@@ -289,6 +292,14 @@ public:
doublePropertyValue = v;
}
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
QColor colorPropertyValue;
QColor colorProperty() const {
return colorPropertyValue;
@@ -394,6 +405,14 @@ public:
variantPropertyValue = v;
}
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
QmlScriptString scriptPropertyValue;
QmlScriptString scriptProperty() const {
return scriptPropertyValue;
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index da586d9..c82aa4d 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -45,6 +45,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
+#include <private/qmlmetaproperty_p.h>
#include "testtypes.h"
#include "../../../shared/util.h"
@@ -246,8 +247,29 @@ void tst_qmllanguage::errors_data()
QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
-
-
+ QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false;
+ QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false;
+ QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false;
+ QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false;
+ QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false;
+ QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false;
+ QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false;
+ QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false;
+ QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false;
+ QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false;
+ QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false;
+
+ QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
+ QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
+ QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
+ QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
+ QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
+ QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
+
+ QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
+ QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
+ QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
+ QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
}
void tst_qmllanguage::errors()
@@ -371,6 +393,7 @@ void tst_qmllanguage::assignBasicTypes()
QCOMPARE(object->intProperty(), -19);
QCOMPARE((float)object->realProperty(), float(23.2));
QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
QCOMPARE(object->colorProperty(), QColor("red"));
QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
@@ -383,6 +406,7 @@ void tst_qmllanguage::assignBasicTypes()
QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)90.99));
QCOMPARE(object->boolProperty(), true);
QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
QVERIFY(object->objectProperty() != 0);
MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
QVERIFY(child != 0);
@@ -615,9 +639,9 @@ void tst_qmllanguage::valueTypes()
p.write(13);
QCOMPARE(p.read(), QVariant(13));
- quint32 r = p.save();
+ quint32 r = QmlMetaPropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
QmlMetaProperty p2;
- p2.restore(r, object);
+ QmlMetaPropertyPrivate::restore(p2, r, object);
QCOMPARE(p2.read(), QVariant(13));
}
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
index 52c673f..7fbffdb 100644
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -42,6 +42,8 @@
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlmetaproperty.h>
+#include <private/qguard_p.h>
+#include <QtDeclarative/qmlbinding.h>
#include <QtGui/QLineEdit>
class MyQmlObject : public QObject
@@ -73,13 +75,27 @@ private:
QML_DECLARE_TYPE(MyContainer);
QML_DEFINE_TYPE(Test,1,0,0,MyContainer,MyContainer);
-class tst_QmlMetaProperty : public QObject
+class tst_qmlmetaproperty : public QObject
{
Q_OBJECT
public:
- tst_QmlMetaProperty() {}
+ tst_qmlmetaproperty() {}
private slots:
+
+ // Constructors
+ void qmlmetaproperty();
+ void qmlmetaproperty_object();
+ void qmlmetaproperty_object_string();
+ void qmlmetaproperty_object_context();
+ void qmlmetaproperty_object_string_context();
+
+ // Methods
+ void name();
+ void read();
+ void write();
+
+ // Functionality
void writeObjectToList();
void writeListToList();
void writeObjectToQmlList();
@@ -90,7 +106,799 @@ private:
QmlEngine engine;
};
-void tst_QmlMetaProperty::writeObjectToList()
+void tst_qmlmetaproperty::qmlmetaproperty()
+{
+ QmlMetaProperty prop;
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), false);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(prop.binding() == 0);
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), -1);
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+}
+
+class PropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int defaultProperty READ defaultProperty);
+ Q_PROPERTY(QRect rectProperty READ rectProperty);
+ Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty);
+ Q_PROPERTY(QUrl url READ url WRITE setUrl);
+
+ Q_CLASSINFO("DefaultProperty", "defaultProperty");
+public:
+ int defaultProperty() { return 10; }
+ QRect rectProperty() { return QRect(10, 10, 1, 209); }
+
+ QRect wrectProperty() { return m_rect; }
+ void setWRectProperty(const QRect &r) { m_rect = r; }
+
+ QUrl url() { return m_url; }
+ void setUrl(const QUrl &u) { m_url = u; }
+
+signals:
+ void clicked();
+
+private:
+ QRect m_rect;
+ QUrl m_url;
+};
+
+void tst_qmlmetaproperty::qmlmetaproperty_object()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QmlMetaProperty prop(&object);
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), false);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(prop.binding() == 0);
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), -1);
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+
+ {
+ QmlMetaProperty prop(&dobject);
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), true);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), (QmlMetaProperty::Type)(QmlMetaProperty::Property | QmlMetaProperty::Default));
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isDefault(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(prop.binding() == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(prop.binding() == binding);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qmlmetaproperty::qmlmetaproperty_object_string()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QmlMetaProperty prop(&object, QString("defaultProperty"));
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), false);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(prop.binding() == 0);
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), -1);
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+
+ {
+ QmlMetaProperty prop(&dobject, QString("defaultProperty"));
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), true);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QmlMetaProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(prop.binding() == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(prop.binding() == binding);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+
+ {
+ QmlMetaProperty prop(&dobject, QString("onClicked"));
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), false);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QmlMetaProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(prop.binding() == 0);
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(prop.signalExpression() == expression);
+ QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qmlmetaproperty::qmlmetaproperty_object_context()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QmlMetaProperty prop(&object, engine.rootContext());
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), false);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(prop.binding() == 0);
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), -1);
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+
+ {
+ QmlMetaProperty prop(&dobject, engine.rootContext());
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), true);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), (QmlMetaProperty::Type)(QmlMetaProperty::Property | QmlMetaProperty::Default));
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isDefault(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(prop.binding() == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(prop.binding() == binding);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qmlmetaproperty::qmlmetaproperty_object_string_context()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QmlMetaProperty prop(&object, QString("defaultProperty"), engine.rootContext());
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), false);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(prop.binding() == 0);
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), -1);
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+
+ {
+ QmlMetaProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), true);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QmlMetaProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(prop.binding() == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(prop.binding() == binding);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+
+ {
+ QmlMetaProperty prop(&dobject, QString("onClicked"), engine.rootContext());
+
+ QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QmlExpression> expression(new QmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasChangedNotifier(), false);
+ QCOMPARE(prop.needsChangedNotifier(), false);
+ QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifier(obj, 0), false);
+ QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifier(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QmlMetaProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isDefault(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(prop.binding() == 0);
+ QVERIFY(prop.setBinding(binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(prop.signalExpression() == 0);
+ QVERIFY(prop.setSignalExpression(expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(prop.signalExpression() == expression);
+ QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(prop.valueTypeCoreIndex(), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qmlmetaproperty::name()
+{
+ {
+ QmlMetaProperty p;
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o);
+ QCOMPARE(p.name(), QString("defaultProperty"));
+ }
+
+ {
+ QObject o;
+ QmlMetaProperty p(&o, QString("objectName"));
+ QCOMPARE(p.name(), QString("objectName"));
+ }
+
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString("onClicked"));
+ }
+
+ {
+ QObject o;
+ QmlMetaProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QObject o;
+ QmlMetaProperty p(&o, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QmlMetaProperty p(0, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty");
+ QCOMPARE(p.name(), QString("rectProperty"));
+ }
+
+ {
+ PropertyObject o;
+ QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.x");
+ QCOMPARE(p.name(), QString("rectProperty.x"));
+ }
+
+ {
+ PropertyObject o;
+ QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.foo");
+ QCOMPARE(p.name(), QString());
+ }
+}
+
+void tst_qmlmetaproperty::read()
+{
+ // Invalid
+ {
+ QmlMetaProperty p;
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Default prop
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o);
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QmlMetaProperty p(&o);
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Value prop by name
+ {
+ QObject o;
+
+ QmlMetaProperty p(&o, "objectName");
+ QCOMPARE(p.read(), QVariant(QString()));
+
+ o.setObjectName("myName");
+
+ QCOMPARE(p.read(), QVariant("myName"));
+ }
+
+ // Value-type prop
+ {
+ PropertyObject o;
+ QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid value-type prop
+ {
+ PropertyObject o;
+ QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.foo");
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o, "onClicked");
+ QCOMPARE(p.read(), QVariant());
+
+ QVERIFY(0 == p.setSignalExpression(new QmlExpression()));
+ QVERIFY(0 != p.signalExpression());
+
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QmlMetaProperty p = QmlMetaProperty::createProperty(o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ delete o;
+ QCOMPARE(p.read(), QVariant());
+ }
+}
+
+void tst_qmlmetaproperty::write()
+{
+ // Invalid
+ {
+ QmlMetaProperty p;
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only default prop
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QmlMetaProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only prop by name
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o, QString("defaultProperty"));
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Writable prop by name
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o, QString("objectName"));
+ QCOMPARE(o.objectName(), QString());
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o.objectName(), QString("myName"));
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QmlMetaProperty p(o, QString("objectName"));
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o->objectName(), QString("myName"));
+
+ delete o;
+
+ QCOMPARE(p.write(QVariant(QString("myName"))), false);
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o, "onClicked");
+ QCOMPARE(p.write(QVariant("print(1921)")), false);
+
+ QVERIFY(0 == p.setSignalExpression(new QmlExpression()));
+ QVERIFY(0 != p.signalExpression());
+
+ QCOMPARE(p.write(QVariant("print(1921)")), false);
+
+ QVERIFY(0 != p.signalExpression());
+ }
+
+ // Value-type property
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o, "wrectProperty");
+
+ QCOMPARE(o.wrectProperty(), QRect());
+ QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
+ QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
+
+ QmlMetaProperty p2 = QmlMetaProperty::createProperty(&o, "wrectProperty.x");
+ QCOMPARE(p2.read(), QVariant(1));
+ QCOMPARE(p2.write(QVariant(6)), true);
+ QCOMPARE(p2.read(), QVariant(6));
+ QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8));
+ }
+
+ // URL-property
+ {
+ PropertyObject o;
+ QmlMetaProperty p(&o, "url");
+
+ QCOMPARE(p.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), QUrl("main.qml"));
+
+ QmlMetaProperty p2(&o, "url", engine.rootContext());
+
+ QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
+ QVERIFY(result != QUrl("main.qml"));
+
+ QCOMPARE(p2.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), result);
+ }
+}
+
+void tst_qmlmetaproperty::writeObjectToList()
{
QmlComponent containerComponent(&engine, "import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
@@ -105,7 +913,7 @@ void tst_QmlMetaProperty::writeObjectToList()
}
Q_DECLARE_METATYPE(QList<QObject *>);
-void tst_QmlMetaProperty::writeListToList()
+void tst_qmlmetaproperty::writeListToList()
{
QmlComponent containerComponent(&engine, "import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
@@ -125,7 +933,7 @@ void tst_QmlMetaProperty::writeListToList()
QCOMPARE(container->children()->size(), 1);*/
}
-void tst_QmlMetaProperty::writeObjectToQmlList()
+void tst_qmlmetaproperty::writeObjectToQmlList()
{
QmlComponent containerComponent(&engine, "import Test 1.0\nMyContainer { qmlChildren: MyQmlObject {} }", QUrl());
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
@@ -139,6 +947,6 @@ void tst_QmlMetaProperty::writeObjectToQmlList()
QCOMPARE(container->qmlChildren()->at(1), object);
}
-QTEST_MAIN(tst_QmlMetaProperty)
+QTEST_MAIN(tst_qmlmetaproperty)
#include "tst_qmlmetaproperty.moc"
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model2.qml b/tests/auto/declarative/qmlxmllistmodel/data/model2.qml
new file mode 100644
index 0000000..140e0ad
--- /dev/null
+++ b/tests/auto/declarative/qmlxmllistmodel/data/model2.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+XmlListModel {
+ source: "model.xml"
+ query: "/Pets/Pet"
+ XmlRole { name: "name"; query: "name/string()" }
+ XmlRole { name: "type"; query: "type/string()" }
+ XmlRole { name: "age"; query: "age/number()" }
+ XmlRole { name: "size"; query: "size/string()" }
+ XmlRole { name: "tricks"; query: "tricks/string()" }
+}