diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-02-25 23:35:43 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-02-25 23:35:43 (GMT) |
commit | 31c8459d65aaca9131a8aa32e29e0591ed7892cb (patch) | |
tree | 5339f4b4291c17a9a765a70990ec3c12f4055de7 /tests | |
parent | 5c82031a7357f4f3d100be30c0bfe4e878712829 (diff) | |
parent | 61811d9b43828c1cc53c773fd66b78313f4fb942 (diff) | |
download | Qt-31c8459d65aaca9131a8aa32e29e0591ed7892cb.zip Qt-31c8459d65aaca9131a8aa32e29e0591ed7892cb.tar.gz Qt-31c8459d65aaca9131a8aa32e29e0591ed7892cb.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Conflicts:
src/declarative/qml/qdeclarativeproperty.cpp
Diffstat (limited to 'tests')
22 files changed, 459 insertions, 267 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 669213c..42ff523 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -41,7 +41,7 @@ SUBDIRS += \ qdeclarativelanguage \ # Cover qdeclarativelistreference \ # Cover qdeclarativelistmodel \ # Cover - qdeclarativemetaproperty \ # Cover + qdeclarativeproperty \ # Cover qdeclarativemetatype \ # Cover qdeclarativemoduleplugin \ # Cover qdeclarativenumberformatter \ # Cover diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index 8d5a1f6..0c3ca76 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -49,7 +49,7 @@ #include <QtDeclarative/qdeclarativecontext.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QtDeclarative/qdeclarativeexpression.h> -#include <QtDeclarative/qdeclarativemetaproperty.h> +#include <QtDeclarative/qdeclarativeproperty.h> #include <private/qdeclarativebinding_p.h> #include <private/qdeclarativedebug_p.h> @@ -58,7 +58,7 @@ #include <private/qdeclarativedebugservice_p.h> #include <private/qdeclarativerectangle_p.h> #include <private/qdeclarativemetatype_p.h> -#include <private/qdeclarativemetaproperty_p.h> +#include <private/qdeclarativeproperty_p.h> #include "../shared/debugutil_p.h" @@ -218,7 +218,7 @@ void tst_QDeclarativeDebug::recursiveObjectTest(QObject *o, const QDeclarativeDe QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName())); QDeclarativeAbstractBinding *binding = - QDeclarativeMetaPropertyPrivate::binding(QDeclarativeMetaProperty(o, p.name())); + QDeclarativePropertyPrivate::binding(QDeclarativeProperty(o, p.name())); if (binding) QCOMPARE(binding->expression(), p.binding()); diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index fc1ede7..8ac7aa6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -52,7 +52,7 @@ #include <QtDeclarative/qdeclarativeparserstatus.h> #include <QtDeclarative/qdeclarativepropertyvaluesource.h> #include <QtDeclarative/qdeclarativescriptstring.h> -#include <QtDeclarative/qdeclarativemetaproperty.h> +#include <QtDeclarative/qdeclarativeproperty.h> QVariant myCustomVariantTypeConverter(const QString &data); @@ -480,8 +480,8 @@ public: MyPropertyValueSource() : QDeclarativePropertyValueSource() {} - QDeclarativeMetaProperty prop; - virtual void setTarget(const QDeclarativeMetaProperty &p) + QDeclarativeProperty prop; + virtual void setTarget(const QDeclarativeProperty &p) { prop = p; } diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 2907757..1ba4454 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -46,7 +46,7 @@ #include <QtCore/qfileinfo.h> #include <QtCore/qdir.h> -#include <private/qdeclarativemetaproperty_p.h> +#include <private/qdeclarativeproperty_p.h> #include <private/qdeclarativemetatype_p.h> #include "testtypes.h" @@ -747,14 +747,14 @@ void tst_qdeclarativelanguage::valueTypes() // ### #if 0 - QDeclarativeMetaProperty p(object, "rectProperty.x"); + QDeclarativeProperty p(object, "rectProperty.x"); QCOMPARE(p.read(), QVariant(12)); p.write(13); QCOMPARE(p.read(), QVariant(13)); - quint32 r = QDeclarativeMetaPropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex()); - QDeclarativeMetaProperty p2; - QDeclarativeMetaPropertyPrivate::restore(p2, r, object); + quint32 r = QDeclarativePropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex()); + QDeclarativeProperty p2; + QDeclarativePropertyPrivate::restore(p2, r, object); QCOMPARE(p2.read(), QVariant(13)); #endif } diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp index fdcb98a..1b7af19 100644 --- a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp +++ b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp @@ -47,7 +47,7 @@ #include <QDeclarativeComponent> #include <QtDeclarative/qdeclarative.h> #include <QtDeclarative/qdeclarativeprivate.h> -#include <QtDeclarative/qdeclarativemetaproperty.h> +#include <QtDeclarative/qdeclarativeproperty.h> #include <QDebug> inline QUrl TEST_FILE(const QString &filename) @@ -530,7 +530,7 @@ void tst_qdeclarativelistreference::qmlmetaproperty() tt.data.append(0); tt.data.append(&tt); - QDeclarativeMetaProperty prop(&tt, QLatin1String("data")); + QDeclarativeProperty prop(&tt, QLatin1String("data")); QVariant v = prop.read(); QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>()); QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v); @@ -546,11 +546,11 @@ void tst_qdeclarativelistreference::engineTypes() QObject *o = component.create(); QVERIFY(o); - QDeclarativeMetaProperty p1(o, QLatin1String("myList")); - QVERIFY(p1.propertyTypeCategory() == QDeclarativeMetaProperty::Normal); + QDeclarativeProperty p1(o, QLatin1String("myList")); + QVERIFY(p1.propertyTypeCategory() == QDeclarativeProperty::Normal); - QDeclarativeMetaProperty p2(o, QLatin1String("myList"), engine.rootContext()); - QVERIFY(p2.propertyTypeCategory() == QDeclarativeMetaProperty::List); + QDeclarativeProperty p2(o, QLatin1String("myList"), engine.rootContext()); + QVERIFY(p2.propertyTypeCategory() == QDeclarativeProperty::List); QVariant v = p2.read(); QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>()); QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v); diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index 4333e02..818f108 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -97,7 +97,7 @@ class ValueSourceTestType : public QObject, public QDeclarativePropertyValueSour Q_OBJECT Q_INTERFACES(QDeclarativePropertyValueSource) public: - virtual void setTarget(const QDeclarativeMetaProperty &) {} + virtual void setTarget(const QDeclarativeProperty &) {} }; QML_DECLARE_TYPE(ValueSourceTestType); @@ -106,7 +106,7 @@ class ValueInterceptorTestType : public QObject, public QDeclarativePropertyValu Q_OBJECT Q_INTERFACES(QDeclarativePropertyValueInterceptor) public: - virtual void setTarget(const QDeclarativeMetaProperty &) {} + virtual void setTarget(const QDeclarativeProperty &) {} virtual void write(const QVariant &) {} }; QML_DECLARE_TYPE(ValueInterceptorTestType); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir b/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir new file mode 100644 index 0000000..0a8b5d4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir @@ -0,0 +1 @@ +plugin plugin diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp index 154693c..fd94cc6 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp @@ -73,15 +73,10 @@ public: qWarning("plugin created"); } - QStringList keys() const - { - return QStringList() << QLatin1String("com.nokia.AutoTestQmlPluginType"); - } - - void initialize(QDeclarativeEngine*, const char *uri) + void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType"); - QML_REGISTER_TYPE(com.nokia.AutoTestQmlPluginType,1,0,MyPluginType,MyPluginType); + qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); } }; diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro index 348080d..035cb7d 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro @@ -2,4 +2,5 @@ TEMPLATE = lib CONFIG += plugin SOURCES = plugin.cpp QT = core declarative -DESTDIR = qdeclarativemodules +DESTDIR = ../com/nokia/AutoTestQmlPluginType + diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro index dd65511..d895ed0 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES = tst_qdeclarativemoduleplugin.cpp QT += declarative +CONFIG -= app_bundle DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index 7170469..22e50cc 100644 --- a/tests/auto/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -2,4 +2,4 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativemetaproperty.cpp +SOURCES += tst_qdeclarativeproperty.cpp diff --git a/tests/auto/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index f2ed341..a3aefe3 100644 --- a/tests/auto/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -41,8 +41,8 @@ #include <qtest.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> -#include <QtDeclarative/qdeclarativemetaproperty.h> -#include <QtDeclarative/private/qdeclarativemetaproperty_p.h> +#include <QtDeclarative/qdeclarativeproperty.h> +#include <QtDeclarative/private/qdeclarativeproperty_p.h> #include <private/qguard_p.h> #include <private/qdeclarativebinding_p.h> #include <QtGui/QLineEdit> @@ -90,11 +90,11 @@ private: QML_DECLARE_TYPE(MyContainer); QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES) -class tst_qdeclarativemetaproperty : public QObject +class tst_qdeclarativeproperty : public QObject { Q_OBJECT public: - tst_qdeclarativemetaproperty() {} + tst_qdeclarativeproperty() {} private slots: void initTestCase(); @@ -126,9 +126,9 @@ private: QDeclarativeEngine engine; }; -void tst_qdeclarativemetaproperty::qmlmetaproperty() +void tst_qdeclarativeproperty::qmlmetaproperty() { - QDeclarativeMetaProperty prop; + QDeclarativeProperty prop; QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); @@ -149,7 +149,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::Invalid); + QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -157,18 +157,18 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::InvalidCategory); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), -1); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } @@ -216,13 +216,13 @@ private: QML_DECLARE_TYPE(PropertyObject); -void tst_qdeclarativemetaproperty::qmlmetaproperty_object() +void tst_qdeclarativeproperty::qmlmetaproperty_object() { QObject object; // Has no default property PropertyObject dobject; // Has default property { - QDeclarativeMetaProperty prop(&object); + QDeclarativeProperty prop(&object); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); @@ -243,7 +243,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::Invalid); + QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -251,24 +251,24 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::InvalidCategory); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), -1); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } { - QDeclarativeMetaProperty prop(&dobject); + QDeclarativeProperty prop(&dobject); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -290,7 +290,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), (QDeclarativeMetaProperty::Type)(QDeclarativeMetaProperty::Property | QDeclarativeMetaProperty::Default)); + QCOMPARE(prop.type(), (QDeclarativeProperty::Type)(QDeclarativeProperty::Property | QDeclarativeProperty::Default)); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isDefault(), true); QCOMPARE(prop.isWritable(), false); @@ -298,32 +298,32 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == binding); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } } -void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() +void tst_qdeclarativeproperty::qmlmetaproperty_object_string() { QObject object; PropertyObject dobject; { - QDeclarativeMetaProperty prop(&object, QString("defaultProperty")); + QDeclarativeProperty prop(&object, QString("defaultProperty")); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); @@ -344,7 +344,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::Invalid); + QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -352,24 +352,24 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::InvalidCategory); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), -1); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } { - QDeclarativeMetaProperty prop(&dobject, QString("defaultProperty")); + QDeclarativeProperty prop(&dobject, QString("defaultProperty")); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -391,7 +391,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::Property); + QCOMPARE(prop.type(), QDeclarativeProperty::Property); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -399,26 +399,26 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == binding); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } { - QDeclarativeMetaProperty prop(&dobject, QString("onClicked")); + QDeclarativeProperty prop(&dobject, QString("onClicked")); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -440,7 +440,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() 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(), QDeclarativeMetaProperty::SignalProperty); + QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -448,19 +448,19 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::InvalidCategory); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } @@ -514,13 +514,13 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string() } } -void tst_qdeclarativemetaproperty::qmlmetaproperty_object_context() +void tst_qdeclarativeproperty::qmlmetaproperty_object_context() { QObject object; // Has no default property PropertyObject dobject; // Has default property { - QDeclarativeMetaProperty prop(&object, engine.rootContext()); + QDeclarativeProperty prop(&object, engine.rootContext()); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); @@ -541,7 +541,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_context() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::Invalid); + QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -549,24 +549,24 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_context() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::InvalidCategory); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), -1); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } { - QDeclarativeMetaProperty prop(&dobject, engine.rootContext()); + QDeclarativeProperty prop(&dobject, engine.rootContext()); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -588,7 +588,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_context() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), (QDeclarativeMetaProperty::Type)(QDeclarativeMetaProperty::Property | QDeclarativeMetaProperty::Default)); + QCOMPARE(prop.type(), (QDeclarativeProperty::Type)(QDeclarativeProperty::Property | QDeclarativeProperty::Default)); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isDefault(), true); QCOMPARE(prop.isWritable(), false); @@ -596,32 +596,32 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_context() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == binding); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } } -void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() +void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() { QObject object; PropertyObject dobject; { - QDeclarativeMetaProperty prop(&object, QString("defaultProperty"), engine.rootContext()); + QDeclarativeProperty prop(&object, QString("defaultProperty"), engine.rootContext()); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); QVERIFY(binding != 0); @@ -642,7 +642,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::Invalid); + QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -650,24 +650,24 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::InvalidCategory); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QVERIFY(prop.property().name() == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), -1); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } { - QDeclarativeMetaProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); + QDeclarativeProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -689,7 +689,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::Property); + QCOMPARE(prop.type(), QDeclarativeProperty::Property); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -697,26 +697,26 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int"); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding != 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == binding); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } { - QDeclarativeMetaProperty prop(&dobject, QString("onClicked"), engine.rootContext()); + QDeclarativeProperty prop(&dobject, QString("onClicked"), engine.rootContext()); QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -738,7 +738,7 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() 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(), QDeclarativeMetaProperty::SignalProperty); + QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -746,19 +746,19 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyTypeCategory(), QDeclarativeMetaProperty::InvalidCategory); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QDeclarativeMetaPropertyPrivate::binding(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setBinding(prop, binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::setSignalExpression(prop, expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); - QVERIFY(QDeclarativeMetaPropertyPrivate::signalExpression(prop) == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } @@ -812,34 +812,34 @@ void tst_qdeclarativemetaproperty::qmlmetaproperty_object_string_context() } } -void tst_qdeclarativemetaproperty::name() +void tst_qdeclarativeproperty::name() { { - QDeclarativeMetaProperty p; + QDeclarativeProperty p; QCOMPARE(p.name(), QString()); } { PropertyObject o; - QDeclarativeMetaProperty p(&o); + QDeclarativeProperty p(&o); QCOMPARE(p.name(), QString("defaultProperty")); } { QObject o; - QDeclarativeMetaProperty p(&o, QString("objectName")); + QDeclarativeProperty p(&o, QString("objectName")); QCOMPARE(p.name(), QString("objectName")); } { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onClicked"); + QDeclarativeProperty p(&o, "onClicked"); QCOMPARE(p.name(), QString("onClicked")); } { QObject o; - QDeclarativeMetaProperty p(&o, "onClicked"); + QDeclarativeProperty p(&o, "onClicked"); QCOMPARE(p.name(), QString()); } @@ -857,53 +857,53 @@ void tst_qdeclarativemetaproperty::name() { QObject o; - QDeclarativeMetaProperty p(&o, "foo"); + QDeclarativeProperty p(&o, "foo"); QCOMPARE(p.name(), QString()); } { - QDeclarativeMetaProperty p(0, "foo"); + QDeclarativeProperty p(0, "foo"); QCOMPARE(p.name(), QString()); } { PropertyObject o; - QDeclarativeMetaProperty p(&o, "rectProperty"); + QDeclarativeProperty p(&o, "rectProperty"); QCOMPARE(p.name(), QString("rectProperty")); } { PropertyObject o; - QDeclarativeMetaProperty p(&o, "rectProperty.x"); + QDeclarativeProperty p(&o, "rectProperty.x"); QCOMPARE(p.name(), QString("rectProperty.x")); } { PropertyObject o; - QDeclarativeMetaProperty p(&o, "rectProperty.foo"); + QDeclarativeProperty p(&o, "rectProperty.foo"); QCOMPARE(p.name(), QString()); } } -void tst_qdeclarativemetaproperty::read() +void tst_qdeclarativeproperty::read() { // Invalid { - QDeclarativeMetaProperty p; + QDeclarativeProperty p; QCOMPARE(p.read(), QVariant()); } // Default prop { PropertyObject o; - QDeclarativeMetaProperty p(&o); + QDeclarativeProperty p(&o); QCOMPARE(p.read(), QVariant(10)); } // Invalid default prop { QObject o; - QDeclarativeMetaProperty p(&o); + QDeclarativeProperty p(&o); QCOMPARE(p.read(), QVariant()); } @@ -911,7 +911,7 @@ void tst_qdeclarativemetaproperty::read() { QObject o; - QDeclarativeMetaProperty p(&o, "objectName"); + QDeclarativeProperty p(&o, "objectName"); QCOMPARE(p.read(), QVariant(QString())); o.setObjectName("myName"); @@ -922,25 +922,25 @@ void tst_qdeclarativemetaproperty::read() // Value-type prop { PropertyObject o; - QDeclarativeMetaProperty p(&o, "rectProperty.x"); + QDeclarativeProperty p(&o, "rectProperty.x"); QCOMPARE(p.read(), QVariant(10)); } // Invalid value-type prop { PropertyObject o; - QDeclarativeMetaProperty p(&o, "rectProperty.foo"); + QDeclarativeProperty p(&o, "rectProperty.foo"); QCOMPARE(p.read(), QVariant()); } // Signal property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onClicked"); + QDeclarativeProperty p(&o, "onClicked"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == QDeclarativeMetaPropertyPrivate::setSignalExpression(p, new QDeclarativeExpression())); - QVERIFY(0 != QDeclarativeMetaPropertyPrivate::signalExpression(p)); + QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression())); + QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); } @@ -960,7 +960,7 @@ void tst_qdeclarativemetaproperty::read() // Deleted object { PropertyObject *o = new PropertyObject; - QDeclarativeMetaProperty p(o, "rectProperty.x"); + QDeclarativeProperty p(o, "rectProperty.x"); QCOMPARE(p.read(), QVariant(10)); delete o; QCOMPARE(p.read(), QVariant()); @@ -973,7 +973,7 @@ void tst_qdeclarativemetaproperty::read() QObject *object = component.create(); QVERIFY(object != 0); - QDeclarativeMetaProperty p(object, "MyContainer.foo", qmlContext(object)); + QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object)); QCOMPARE(p.read(), QVariant(13)); delete object; } @@ -983,7 +983,7 @@ void tst_qdeclarativemetaproperty::read() QObject *object = component.create(); QVERIFY(object != 0); - QDeclarativeMetaProperty p(object, "MyContainer.foo", qmlContext(object)); + QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object)); QCOMPARE(p.read(), QVariant(10)); delete object; } @@ -993,45 +993,45 @@ void tst_qdeclarativemetaproperty::read() QObject *object = component.create(); QVERIFY(object != 0); - QDeclarativeMetaProperty p(object, "Foo.MyContainer.foo", qmlContext(object)); + QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object)); QCOMPARE(p.read(), QVariant(10)); delete object; } } -void tst_qdeclarativemetaproperty::write() +void tst_qdeclarativeproperty::write() { // Invalid { - QDeclarativeMetaProperty p; + QDeclarativeProperty p; QCOMPARE(p.write(QVariant(10)), false); } // Read-only default prop { PropertyObject o; - QDeclarativeMetaProperty p(&o); + QDeclarativeProperty p(&o); QCOMPARE(p.write(QVariant(10)), false); } // Invalid default prop { QObject o; - QDeclarativeMetaProperty p(&o); + QDeclarativeProperty p(&o); QCOMPARE(p.write(QVariant(10)), false); } // Read-only prop by name { PropertyObject o; - QDeclarativeMetaProperty p(&o, QString("defaultProperty")); + QDeclarativeProperty p(&o, QString("defaultProperty")); QCOMPARE(p.write(QVariant(10)), false); } // Writable prop by name { PropertyObject o; - QDeclarativeMetaProperty p(&o, QString("objectName")); + QDeclarativeProperty p(&o, QString("objectName")); QCOMPARE(o.objectName(), QString()); QCOMPARE(p.write(QVariant(QString("myName"))), true); QCOMPARE(o.objectName(), QString("myName")); @@ -1040,7 +1040,7 @@ void tst_qdeclarativemetaproperty::write() // Deleted object { PropertyObject *o = new PropertyObject; - QDeclarativeMetaProperty p(o, QString("objectName")); + QDeclarativeProperty p(o, QString("objectName")); QCOMPARE(p.write(QVariant(QString("myName"))), true); QCOMPARE(o->objectName(), QString("myName")); @@ -1052,15 +1052,15 @@ void tst_qdeclarativemetaproperty::write() // Signal property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onClicked"); + QDeclarativeProperty p(&o, "onClicked"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == QDeclarativeMetaPropertyPrivate::setSignalExpression(p, new QDeclarativeExpression())); - QVERIFY(0 != QDeclarativeMetaPropertyPrivate::signalExpression(p)); + QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression())); + QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 != QDeclarativeMetaPropertyPrivate::signalExpression(p)); + QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p)); } // Automatic signal property @@ -1080,13 +1080,13 @@ void tst_qdeclarativemetaproperty::write() // Value-type property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "wrectProperty"); + QDeclarativeProperty p(&o, "wrectProperty"); QCOMPARE(o.wrectProperty(), QRect()); QCOMPARE(p.write(QRect(1, 13, 99, 8)), true); QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8)); - QDeclarativeMetaProperty p2(&o, "wrectProperty.x"); + QDeclarativeProperty p2(&o, "wrectProperty.x"); QCOMPARE(p2.read(), QVariant(1)); QCOMPARE(p2.write(QVariant(6)), true); QCOMPARE(p2.read(), QVariant(6)); @@ -1096,12 +1096,12 @@ void tst_qdeclarativemetaproperty::write() // URL-property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "url"); + QDeclarativeProperty p(&o, "url"); QCOMPARE(p.write(QUrl("main.qml")), true); QCOMPARE(o.url(), QUrl("main.qml")); - QDeclarativeMetaProperty p2(&o, "url", engine.rootContext()); + QDeclarativeProperty p2(&o, "url", engine.rootContext()); QUrl result = engine.baseUrl().resolved(QUrl("main.qml")); QVERIFY(result != QUrl("main.qml")); @@ -1117,7 +1117,7 @@ void tst_qdeclarativemetaproperty::write() QObject *object = component.create(); QVERIFY(object != 0); - QDeclarativeMetaProperty p(object, "MyContainer.foo", qmlContext(object)); + QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object)); p.write(QVariant(99)); QCOMPARE(p.read(), QVariant(99)); delete object; @@ -1128,18 +1128,18 @@ void tst_qdeclarativemetaproperty::write() QObject *object = component.create(); QVERIFY(object != 0); - QDeclarativeMetaProperty p(object, "Foo.MyContainer.foo", qmlContext(object)); + QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object)); p.write(QVariant(99)); QCOMPARE(p.read(), QVariant(99)); delete object; } } -void tst_qdeclarativemetaproperty::reset() +void tst_qdeclarativeproperty::reset() { // Invalid { - QDeclarativeMetaProperty p; + QDeclarativeProperty p; QCOMPARE(p.isResettable(), false); QCOMPARE(p.reset(), false); } @@ -1147,7 +1147,7 @@ void tst_qdeclarativemetaproperty::reset() // Read-only default prop { PropertyObject o; - QDeclarativeMetaProperty p(&o); + QDeclarativeProperty p(&o); QCOMPARE(p.isResettable(), false); QCOMPARE(p.reset(), false); } @@ -1155,7 +1155,7 @@ void tst_qdeclarativemetaproperty::reset() // Invalid default prop { QObject o; - QDeclarativeMetaProperty p(&o); + QDeclarativeProperty p(&o); QCOMPARE(p.isResettable(), false); QCOMPARE(p.reset(), false); } @@ -1163,7 +1163,7 @@ void tst_qdeclarativemetaproperty::reset() // Non-resettable-only prop by name { PropertyObject o; - QDeclarativeMetaProperty p(&o, QString("defaultProperty")); + QDeclarativeProperty p(&o, QString("defaultProperty")); QCOMPARE(p.isResettable(), false); QCOMPARE(p.reset(), false); } @@ -1171,7 +1171,7 @@ void tst_qdeclarativemetaproperty::reset() // Resettable prop by name { PropertyObject o; - QDeclarativeMetaProperty p(&o, QString("resettableProperty")); + QDeclarativeProperty p(&o, QString("resettableProperty")); QCOMPARE(p.read(), QVariant(9)); QCOMPARE(p.write(QVariant(11)), true); @@ -1187,7 +1187,7 @@ void tst_qdeclarativemetaproperty::reset() { PropertyObject *o = new PropertyObject; - QDeclarativeMetaProperty p(o, QString("resettableProperty")); + QDeclarativeProperty p(o, QString("resettableProperty")); QCOMPARE(p.isResettable(), true); QCOMPARE(p.reset(), true); @@ -1201,7 +1201,7 @@ void tst_qdeclarativemetaproperty::reset() // Signal property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onClicked"); + QDeclarativeProperty p(&o, "onClicked"); QCOMPARE(p.isResettable(), false); QCOMPARE(p.reset(), false); @@ -1217,7 +1217,7 @@ void tst_qdeclarativemetaproperty::reset() } } -void tst_qdeclarativemetaproperty::writeObjectToList() +void tst_qdeclarativeproperty::writeObjectToList() { QDeclarativeComponent containerComponent(&engine); containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); @@ -1227,14 +1227,14 @@ void tst_qdeclarativemetaproperty::writeObjectToList() QVERIFY(list.count() == 1); MyQmlObject *object = new MyQmlObject; - QDeclarativeMetaProperty prop(container, "children"); + QDeclarativeProperty prop(container, "children"); prop.write(qVariantFromValue(object)); QCOMPARE(list.count(), 1); QCOMPARE(list.at(0), object); } Q_DECLARE_METATYPE(QList<QObject *>); -void tst_qdeclarativemetaproperty::writeListToList() +void tst_qdeclarativeproperty::writeListToList() { QDeclarativeComponent containerComponent(&engine); containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); @@ -1245,7 +1245,7 @@ void tst_qdeclarativemetaproperty::writeListToList() QList<QObject*> objList; objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject(); - QDeclarativeMetaProperty prop(container, "children"); + QDeclarativeProperty prop(container, "children"); prop.write(qVariantFromValue(objList)); QCOMPARE(list.count(), 4); @@ -1256,7 +1256,7 @@ void tst_qdeclarativemetaproperty::writeListToList() QCOMPARE(container->children()->size(), 1);*/ } -void tst_qdeclarativemetaproperty::crashOnValueProperty() +void tst_qdeclarativeproperty::crashOnValueProperty() { QDeclarativeEngine *engine = new QDeclarativeEngine; QDeclarativeComponent component(engine); @@ -1265,7 +1265,7 @@ void tst_qdeclarativemetaproperty::crashOnValueProperty() PropertyObject *obj = qobject_cast<PropertyObject*>(component.create()); QVERIFY(obj != 0); - QDeclarativeMetaProperty p(obj, "wrectProperty.x", qmlContext(obj)); + QDeclarativeProperty p(obj, "wrectProperty.x", qmlContext(obj)); QCOMPARE(p.name(), QString("wrectProperty.x")); QCOMPARE(p.read(), QVariant(10)); @@ -1280,49 +1280,49 @@ void tst_qdeclarativemetaproperty::crashOnValueProperty() QCOMPARE(p.read(), QVariant(20)); } -void tst_qdeclarativemetaproperty::copy() +void tst_qdeclarativeproperty::copy() { PropertyObject object; - QDeclarativeMetaProperty *property = new QDeclarativeMetaProperty(&object, QLatin1String("defaultProperty")); + QDeclarativeProperty *property = new QDeclarativeProperty(&object, QLatin1String("defaultProperty")); QCOMPARE(property->name(), QString("defaultProperty")); QCOMPARE(property->read(), QVariant(10)); - QCOMPARE(property->type(), QDeclarativeMetaProperty::Property); - QCOMPARE(property->propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(property->type(), QDeclarativeProperty::Property); + QCOMPARE(property->propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(property->propertyType(), (int)QVariant::Int); - QDeclarativeMetaProperty p1(*property); + QDeclarativeProperty p1(*property); QCOMPARE(p1.name(), QString("defaultProperty")); QCOMPARE(p1.read(), QVariant(10)); - QCOMPARE(p1.type(), QDeclarativeMetaProperty::Property); - QCOMPARE(p1.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(p1.type(), QDeclarativeProperty::Property); + QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(p1.propertyType(), (int)QVariant::Int); - QDeclarativeMetaProperty p2(&object, QLatin1String("url")); + QDeclarativeProperty p2(&object, QLatin1String("url")); QCOMPARE(p2.name(), QString("url")); p2 = *property; QCOMPARE(p2.name(), QString("defaultProperty")); QCOMPARE(p2.read(), QVariant(10)); - QCOMPARE(p2.type(), QDeclarativeMetaProperty::Property); - QCOMPARE(p2.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(p2.type(), QDeclarativeProperty::Property); + QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(p2.propertyType(), (int)QVariant::Int); delete property; property = 0; QCOMPARE(p1.name(), QString("defaultProperty")); QCOMPARE(p1.read(), QVariant(10)); - QCOMPARE(p1.type(), QDeclarativeMetaProperty::Property); - QCOMPARE(p1.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(p1.type(), QDeclarativeProperty::Property); + QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(p1.propertyType(), (int)QVariant::Int); QCOMPARE(p2.name(), QString("defaultProperty")); QCOMPARE(p2.read(), QVariant(10)); - QCOMPARE(p2.type(), QDeclarativeMetaProperty::Property); - QCOMPARE(p2.propertyTypeCategory(), QDeclarativeMetaProperty::Normal); + QCOMPARE(p2.type(), QDeclarativeProperty::Property); + QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal); QCOMPARE(p2.propertyType(), (int)QVariant::Int); } -void tst_qdeclarativemetaproperty::initTestCase() +void tst_qdeclarativeproperty::initTestCase() { QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject); QML_REGISTER_TYPE(Test,1,0,PropertyObject,PropertyObject); @@ -1330,6 +1330,6 @@ void tst_qdeclarativemetaproperty::initTestCase() } -QTEST_MAIN(tst_qdeclarativemetaproperty) +QTEST_MAIN(tst_qdeclarativeproperty) -#include "tst_qdeclarativemetaproperty.moc" +#include "tst_qdeclarativeproperty.moc" diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml new file mode 100644 index 0000000..a0a2b8c --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +Rectangle { + width: 640 + height: 480 + Text { + id: theText + width: 50 + wrap: true + text: "a text string that is longer than 50 pixels" + } + + states: State { + name: "state1" + PropertyChanges { + target: theText + width: undefined + } + } +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index feac9c2..8d3ca7a 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -43,6 +43,7 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <private/qdeclarativeanchors_p_p.h> #include <private/qdeclarativerectangle_p.h> +#include <private/qdeclarativetext_p.h> #include <private/qdeclarativepropertychanges_p.h> #include <private/qdeclarativestategroup_p.h> @@ -104,6 +105,7 @@ private slots: void tempState(); void illegalTempState(); void nonExistantProperty(); + void reset(); }; void tst_qdeclarativestates::initTestCase() @@ -476,10 +478,8 @@ void tst_qdeclarativestates::parentChange() rect->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(15)); QCOMPARE(innerRect->scale(), qreal(.5)); - QEXPECT_FAIL("", "QTBUG-2919", Continue); - QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(12.4148145657)); - QEXPECT_FAIL("", "QTBUG-2919", Continue); - QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(10.6470476128)); + QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075)); + QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433)); } { @@ -500,8 +500,8 @@ void tst_qdeclarativestates::parentChange() QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); - QEXPECT_FAIL("", "QTBUG-2919", Continue); - QCOMPARE(innerRect->y(), qreal(0)); + //do a non-qFuzzyCompare fuzzy compare + QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001)); } } @@ -945,6 +945,25 @@ void tst_qdeclarativestates::nonExistantProperty() QCOMPARE(rect->state(), QLatin1String("blue")); } +void tst_qdeclarativestates::reset() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect != 0); + + QDeclarativeText *text = rect->findChild<QDeclarativeText*>(); + QVERIFY(text != 0); + QCOMPARE(text->width(), qreal(50.)); + QVERIFY(text->width() < text->height()); + + rect->setState("state1"); + + QVERIFY(text->width() > 51); + QVERIFY(text->width() > text->height()); +} + QTEST_MAIN(tst_qdeclarativestates) #include "tst_qdeclarativestates.moc" diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 8b80e16..dfc2829 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -52,7 +52,8 @@ #include <QFont> #include <qdeclarative.h> #include <QDeclarativePropertyValueSource> -#include <QDeclarativeMetaProperty> +#include <QDeclarativeProperty> +#include <private/qdeclarativeproperty_p.h> class MyTypeObject : public QObject { @@ -134,7 +135,7 @@ class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSo { Q_OBJECT public: - virtual void setTarget(const QDeclarativeMetaProperty &p) { p.write(3345); } + virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); } }; QML_DECLARE_TYPE(MyConstantValueSource); @@ -142,11 +143,11 @@ class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValu { Q_OBJECT public: - virtual void setTarget(const QDeclarativeMetaProperty &p) { prop = p; } - virtual void write(const QVariant &value) { prop.write(value.toInt() + 13, QDeclarativeMetaProperty::BypassInterceptor); } + virtual void setTarget(const QDeclarativeProperty &p) { prop = p; } + virtual void write(const QVariant &value) { QDeclarativePropertyPrivate::write(prop, value.toInt() + 13, QDeclarativePropertyPrivate::BypassInterceptor); } private: - QDeclarativeMetaProperty prop; + QDeclarativeProperty prop; }; QML_DECLARE_TYPE(MyOffsetValueInterceptor); diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 1bf7850..6ffe2a7 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -978,6 +978,47 @@ void tst_QGL::glWidgetWithAlpha() delete w; } + +void qt_opengl_draw_test_pattern(QPainter* painter, int width, int height) +{ + QPainterPath intersectingPath; + intersectingPath.moveTo(0, 0); + intersectingPath.lineTo(100, 0); + intersectingPath.lineTo(0, 100); + intersectingPath.lineTo(100, 100); + intersectingPath.closeSubpath(); + + QPainterPath trianglePath; + trianglePath.moveTo(50, 0); + trianglePath.lineTo(100, 100); + trianglePath.lineTo(0, 100); + trianglePath.closeSubpath(); + + painter->setTransform(QTransform()); // reset xform + painter->fillRect(-1, -1, width+2, height+2, Qt::red); // Background + painter->translate(14, 14); + painter->fillPath(intersectingPath, Qt::blue); // Test stencil buffer works + painter->translate(128, 0); + painter->setClipPath(trianglePath); // Test depth buffer works + painter->setTransform(QTransform()); // reset xform ready for fill + painter->fillRect(-1, -1, width+2, height+2, Qt::green); +} + +void qt_opengl_check_test_pattern(const QImage& img) +{ + // As we're doing more than trivial painting, we can't just compare to + // an image rendered with raster. Instead, we sample at well-defined + // test-points: + QFUZZY_COMPARE_PIXELS(img.pixel(39, 64), QColor(Qt::red).rgb()); + QFUZZY_COMPARE_PIXELS(img.pixel(89, 64), QColor(Qt::red).rgb()); + QFUZZY_COMPARE_PIXELS(img.pixel(64, 39), QColor(Qt::blue).rgb()); + QFUZZY_COMPARE_PIXELS(img.pixel(64, 89), QColor(Qt::blue).rgb()); + + QFUZZY_COMPARE_PIXELS(img.pixel(167, 39), QColor(Qt::red).rgb()); + QFUZZY_COMPARE_PIXELS(img.pixel(217, 39), QColor(Qt::red).rgb()); + QFUZZY_COMPARE_PIXELS(img.pixel(192, 64), QColor(Qt::green).rgb()); +} + class GLWidget : public QGLWidget { public: @@ -992,9 +1033,7 @@ public: QPaintEngine* pe = p.paintEngine(); engineType = pe->type(); - // This test only ensures it's possible to paint onto a QGLWidget. Full - // paint engine feature testing is way out of scope! - p.fillRect(-1, -1, width()+2, height()+2, Qt::red); + qt_opengl_draw_test_pattern(&p, width(), height()); // No p.end() or swap buffers, should be done automatically } @@ -1007,7 +1046,7 @@ void tst_QGL::glWidgetRendering() #ifdef Q_WS_QWS w.setWindowFlags(Qt::FramelessWindowHint); #endif - w.setGeometry(100, 100, 200, 200); + w.resize(256, 128); w.show(); #ifdef Q_WS_X11 @@ -1018,11 +1057,8 @@ void tst_QGL::glWidgetRendering() QVERIFY(w.beginOk); QVERIFY(w.engineType == QPaintEngine::OpenGL || w.engineType == QPaintEngine::OpenGL2); - QImage fb = w.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32); - QImage reference(fb.size(), QImage::Format_RGB32); - reference.fill(0xffff0000); - - QFUZZY_COMPARE_IMAGES(fb, reference); + QImage fb = w.grabFrameBuffer(false); + qt_opengl_check_test_pattern(fb); } void tst_QGL::glFBOSimpleRendering() @@ -1075,46 +1111,23 @@ void tst_QGL::glFBORendering() // Don't complicate things by using NPOT: QGLFramebufferObject *fbo = new QGLFramebufferObject(256, 128, fboFormat); + if (fbo->attachment() != QGLFramebufferObject::CombinedDepthStencil) { + delete fbo; + QSKIP("FBOs missing combined depth~stencil support", SkipSingle); + } + QPainter fboPainter; bool painterBegun = fboPainter.begin(fbo); QVERIFY(painterBegun); - QPainterPath intersectingPath; - intersectingPath.moveTo(0, 0); - intersectingPath.lineTo(100, 0); - intersectingPath.lineTo(0, 100); - intersectingPath.lineTo(100, 100); - intersectingPath.closeSubpath(); - - QPainterPath trianglePath; - trianglePath.moveTo(50, 0); - trianglePath.lineTo(100, 100); - trianglePath.lineTo(0, 100); - trianglePath.closeSubpath(); + qt_opengl_draw_test_pattern(&fboPainter, fbo->width(), fbo->height()); - fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::red); // Background - fboPainter.translate(14, 14); - fboPainter.fillPath(intersectingPath, Qt::blue); // Test stencil buffer works - fboPainter.translate(128, 0); - fboPainter.setClipPath(trianglePath); // Test depth buffer works - fboPainter.setTransform(QTransform()); // reset xform - fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::green); fboPainter.end(); QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32); delete fbo; - // As we're doing more than trivial painting, we can't just compare to - // an image rendered with raster. Instead, we sample at well-defined - // test-points: - QFUZZY_COMPARE_PIXELS(fb.pixel(39, 64), QColor(Qt::red).rgb()); - QFUZZY_COMPARE_PIXELS(fb.pixel(89, 64), QColor(Qt::red).rgb()); - QFUZZY_COMPARE_PIXELS(fb.pixel(64, 39), QColor(Qt::blue).rgb()); - QFUZZY_COMPARE_PIXELS(fb.pixel(64, 89), QColor(Qt::blue).rgb()); - - QFUZZY_COMPARE_PIXELS(fb.pixel(167, 39), QColor(Qt::red).rgb()); - QFUZZY_COMPARE_PIXELS(fb.pixel(217, 39), QColor(Qt::red).rgb()); - QFUZZY_COMPARE_PIXELS(fb.pixel(192, 64), QColor(Qt::green).rgb()); + qt_opengl_check_test_pattern(fb); } @@ -1137,6 +1150,16 @@ void tst_QGL::multipleFBOInterleavedRendering() QGLFramebufferObject *fbo2 = new QGLFramebufferObject(256, 128, fboFormat); QGLFramebufferObject *fbo3 = new QGLFramebufferObject(256, 128, fboFormat); + if ( (fbo1->attachment() != QGLFramebufferObject::CombinedDepthStencil) || + (fbo2->attachment() != QGLFramebufferObject::CombinedDepthStencil) || + (fbo3->attachment() != QGLFramebufferObject::CombinedDepthStencil) ) + { + delete fbo1; + delete fbo2; + delete fbo3; + QSKIP("FBOs missing combined depth~stencil support", SkipSingle); + } + QPainter fbo1Painter; QPainter fbo2Painter; QPainter fbo3Painter; @@ -1242,7 +1265,7 @@ protected: QPainter widgetPainter; widgetPainterBeginOk = widgetPainter.begin(this); QGLFramebufferObjectFormat fboFormat; - fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + fboFormat.setAttachment(QGLFramebufferObject::NoAttachment); QGLFramebufferObject *fbo = new QGLFramebufferObject(128, 128, fboFormat); QPainter fboPainter; diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index beb83a1..a03b2c7 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -107,6 +107,7 @@ private slots: void saveAndRestore(); void drawBorderPixmap(); + void drawPixmapFragments(); void drawLine_data(); void drawLine(); @@ -994,6 +995,49 @@ void tst_QPainter::drawBorderPixmap() QTileRules(Qt::StretchTile,Qt::StretchTile), 0); } +void tst_QPainter::drawPixmapFragments() +{ + QPixmap origPixmap(20, 20); + QPixmap resPixmap(20, 20); + QPainter::Fragment fragments[4] = { {15, 15, 0, 0, 10, 10, 1, 1, 0, 1}, + { 5, 15, 10, 0, 10, 10, 1, 1, 0, 1}, + {15, 5, 0, 10, 10, 10, 1, 1, 0, 1}, + { 5, 5, 10, 10, 10, 10, 1, 1, 0, 1} }; + { + QPainter p(&origPixmap); + p.fillRect(0, 0, 10, 10, Qt::red); + p.fillRect(10, 0, 10, 10, Qt::green); + p.fillRect(0, 10, 10, 10, Qt::blue); + p.fillRect(10, 10, 10, 10, Qt::yellow); + } + { + QPainter p(&resPixmap); + p.drawPixmapFragments(fragments, 4, origPixmap); + } + + QImage origImage = origPixmap.toImage().convertToFormat(QImage::Format_ARGB32); + QImage resImage = resPixmap.toImage().convertToFormat(QImage::Format_ARGB32); + + QVERIFY(resImage.size() == resPixmap.size()); + QVERIFY(resImage.pixel(5, 5) == origImage.pixel(15, 15)); + QVERIFY(resImage.pixel(5, 15) == origImage.pixel(15, 5)); + QVERIFY(resImage.pixel(15, 5) == origImage.pixel(5, 15)); + QVERIFY(resImage.pixel(15, 15) == origImage.pixel(5, 5)); + + + QPainter::Fragment fragment = QPainter::Fragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2)); + QVERIFY(fragment.x == 20); + QVERIFY(fragment.y == 20); + QVERIFY(fragment.sourceLeft == 30); + QVERIFY(fragment.sourceTop == 30); + QVERIFY(fragment.width == 2); + QVERIFY(fragment.height == 2); + QVERIFY(fragment.scaleX == 1); + QVERIFY(fragment.scaleY == 1); + QVERIFY(fragment.rotation == 0); + QVERIFY(fragment.opacity == 1); +} + void tst_QPainter::drawLine_data() { QTest::addColumn<QLine>("line"); @@ -3443,8 +3487,8 @@ bool verifyOutlineFillConsistency(const QImage &img, QRgb outside, QRgb inside, if ((dx == 0) == (dy == 0)) continue; QRgb neighbor = img.pixel(p.x() + dx, p.y() + dy); - if (pixel == inside && neighbor == outside || - pixel == outside && neighbor == inside) + if ((pixel == inside && neighbor == outside) || + (pixel == outside && neighbor == inside)) return false; } } diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 5b2b0cf..56eaf25 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -137,6 +137,7 @@ private slots: void task255652_removeRowsRecursive(); void taskQTBUG_6205_doubleProxySelectionSetSourceModel(); void taskQTBUG_7537_appearsAndSort(); + void taskQTBUG_7716_unnecessaryDynamicSorting(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -918,15 +919,16 @@ void tst_QSortFilterProxyModel::removeRows() QStandardItemModel model; QSortFilterProxyModel proxy; proxy.setSourceModel(&model); - if (sortOrder != -1) - proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder)); - if (!filter.isEmpty()) - proxy.setFilterRegExp(QRegExp(filter)); // prepare model foreach (QString s, initial) model.appendRow(new QStandardItem(s)); + if (sortOrder != -1) + proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder)); + if (!filter.isEmpty()) + proxy.setFilterRegExp(QRegExp(filter)); + // remove the rows QCOMPARE(proxy.removeRows(position, count, QModelIndex()), success); QCOMPARE(model.rowCount(QModelIndex()), expectedSource.count()); @@ -2419,6 +2421,7 @@ void tst_QSortFilterProxyModel::sortColumnTracking2() { QStandardItemModel model; QSortFilterProxyModel proxyModel; + proxyModel.setDynamicSortFilter(true); proxyModel.setSourceModel(&model); proxyModel.sort(0); @@ -2921,5 +2924,32 @@ void tst_QSortFilterProxyModel::taskQTBUG_7537_appearsAndSort() QCOMPARE(spyChanged2.count(), 1); } +void tst_QSortFilterProxyModel::taskQTBUG_7716_unnecessaryDynamicSorting() +{ + QStringListModel model; + const QStringList initial = QString("bravo charlie delta echo").split(" "); + model.setStringList(initial); + QSortFilterProxyModel proxy; + proxy.setDynamicSortFilter(false); + proxy.setSourceModel(&model); + proxy.sort(Qt::AscendingOrder); + + //append two rows + int maxrows = proxy.rowCount(QModelIndex()); + model.insertRows(maxrows, 2); + model.setData(model.index(maxrows, 0), QString("alpha")); + model.setData(model.index(maxrows + 1, 0), QString("fondue")); + + //append new items to the initial string list and compare with model + QStringList expected = initial; + expected << QString("alpha") << QString("fondue"); + + //if bug 7716 is present, new rows were prepended, when they should have been appended + for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) { + QModelIndex index = proxy.index(row, 0, QModelIndex()); + QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expected.at(row)); + } +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" diff --git a/tests/auto/qstatictext/qstatictext.pro b/tests/auto/qstatictext/qstatictext.pro index a759a90..0f1ca68 100644 --- a/tests/auto/qstatictext/qstatictext.pro +++ b/tests/auto/qstatictext/qstatictext.pro @@ -1,4 +1,4 @@ load(qttest_p4) -QT = core gui opengl +QT = core gui SOURCES += tst_qstatictext.cpp diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp index 68f05c1..16832ad 100644 --- a/tests/auto/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/qstatictext/tst_qstatictext.cpp @@ -45,13 +45,20 @@ #include <QtGui/QImage> #include <qstatictext.h> +#include <qpaintengine.h> + #include <private/qstatictext_p.h> +#include <private/qapplication_p.h> // #define DEBUG_SAVE_IMAGE class tst_QStaticText: public QObject { Q_OBJECT + +private: + bool supportsTransformations() const; + private slots: void init(); void cleanup(); @@ -177,6 +184,8 @@ void tst_QStaticText::prepareToCorrectData() p.drawStaticText(QPointF(11, 12), text); } + if (!supportsTransformations()) + QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort); QCOMPARE(imageDrawStaticText, imageDrawText); } @@ -288,6 +297,25 @@ void tst_QStaticText::translatedPainter() QCOMPARE(imageDrawStaticText, imageDrawText); } +bool tst_QStaticText::supportsTransformations() const +{ + QPixmap pm(10, 10); + QPainter p(&pm); + QPaintEngine *engine = p.paintEngine(); + + QPaintEngine::Type type = engine->type(); + + if (type == QPaintEngine::OpenGL2 + || type == QPaintEngine::OpenGL +#if !defined Q_WS_WIN + || type == QPaintEngine::Raster +#endif + ) + return false; + + return true; +} + void tst_QStaticText::rotatedPainter() { QPixmap imageDrawText(1000, 1000); @@ -314,6 +342,8 @@ void tst_QStaticText::rotatedPainter() imageDrawStaticText.save("rotatedPainter_imageDrawStaticText.png"); #endif + if (!supportsTransformations()) + QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort); QCOMPARE(imageDrawStaticText, imageDrawText); } @@ -340,6 +370,8 @@ void tst_QStaticText::scaledPainter() p.drawStaticText(QPointF(11, 12), text); } + if (!supportsTransformations()) + QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort); QCOMPARE(imageDrawStaticText, imageDrawText); } @@ -370,7 +402,6 @@ void tst_QStaticText::projectedPainter() } QCOMPARE(imageDrawStaticText, imageDrawText); - } void tst_QStaticText::rotatedScaledAndTranslatedPainter() @@ -405,6 +436,8 @@ void tst_QStaticText::rotatedScaledAndTranslatedPainter() imageDrawStaticText.save("rotatedScaledAndPainter_imageDrawStaticText.png"); #endif + if (!supportsTransformations()) + QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort); QCOMPARE(imageDrawStaticText, imageDrawText); } @@ -444,6 +477,8 @@ void tst_QStaticText::transformationChanged() imageDrawStaticText.save("transformationChanged_imageDrawStaticText.png"); #endif + if (!supportsTransformations()) + QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort); QCOMPARE(imageDrawStaticText, imageDrawText); } diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp index 8e95818..e9ae7a6 100644 --- a/tests/auto/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/qstringbuilder1/stringbuilder.cpp @@ -44,6 +44,14 @@ // "some literal", but replacing all vocals by their umlauted UTF-8 string :) #define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l" + +//fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS +#ifndef QT_USE_FAST_CONCATENATION +#define Q % +#else +#define Q P +#endif + void runScenario() { // set codec for C strings to 0, enforcing Latin1 @@ -59,13 +67,13 @@ void runScenario() QString r; QByteArray ba(LITERAL); - r = l1literal P l1literal; + r = l1literal Q l1literal; QCOMPARE(r, r2); r = string P string; QCOMPARE(r, r2); - r = stringref P stringref; + r = stringref Q stringref; QCOMPARE(r, QString(stringref.toString() + stringref.toString())); - r = string P l1literal; + r = string Q l1literal; QCOMPARE(r, r2); r = string P l1string; QCOMPARE(r, r2); diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index fd4815e..e39cf6c 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3083,6 +3083,20 @@ void tst_QTreeView::styleOptionViewItem() QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 3); QApplication::processEvents(); + + item00->setText("OnlyOne"); + item0->insertRow(2, new QStandardItem("OnlyOne Last")); + view.collapse(item0->index()); + item0->removeRow(0); + delegate.count = 0; + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); + + item0->removeRow(1); + item0->setText("OnlyOne"); + delegate.count = 0; + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); } } |