diff options
Diffstat (limited to 'tests/auto/declarative')
30 files changed, 1276 insertions, 121 deletions
diff --git a/tests/auto/declarative/qmlconnection/data/trimming.qml b/tests/auto/declarative/qmlconnection/data/trimming.qml new file mode 100644 index 0000000..c27dc46 --- /dev/null +++ b/tests/auto/declarative/qmlconnection/data/trimming.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +Item { + id: screen; width: 50 + + property string tested + signal testMe(int param1, string param2) + + Connection { sender: screen; signal: "testMe(param1, param2)"; script: screen.tested = param2 + param1 } +} diff --git a/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp b/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp index b21da48..3d9ee46 100644 --- a/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp +++ b/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp @@ -57,6 +57,7 @@ private slots: void defaultValues(); void properties(); void connection(); + void trimming(); private: QmlEngine engine; @@ -113,6 +114,26 @@ void tst_qmlconnection::connection() delete item; } +void tst_qmlconnection::trimming() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/trimming.qml")); + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(c.create()); + + QVERIFY(item != 0); + + QCOMPARE(item->property("tested").toString(), QString("")); + int index = item->metaObject()->indexOfSignal("testMe(int,QString)"); + QMetaMethod method = item->metaObject()->method(index); + method.invoke(item, + Qt::DirectConnection, + Q_ARG(int, 5), + Q_ARG(QString, "worked")); + QCOMPARE(item->property("tested").toString(), QString("worked5")); + + delete item; +} + QTEST_MAIN(tst_qmlconnection) #include "tst_qmlconnection.moc" diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml new file mode 100644 index 0000000..db7f2b5 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml @@ -0,0 +1,26 @@ +import Qt.test 1.0 + +MyTypeObject { + flagProperty: if(1) "FlagVal1 | FlagVal3" + enumProperty: if(1) "EnumVal2" + stringProperty: if(1) "Hello World!" + uintProperty: if(1) 10 + intProperty: if(1) -19 + realProperty: if(1) 23.2 + doubleProperty: if(1) -19.7 + floatProperty: if(1) 8.5 + colorProperty: if(1) "red" + dateProperty: if(1) "1982-11-25" + timeProperty: if(1) "11:11:32" + dateTimeProperty: if(1) "2009-05-12T13:22:01" + pointProperty: if(1) "99,13" + pointFProperty: if(1) "-10.1,12.3" + sizeProperty: if(1) "99x13" + sizeFProperty: if(1) "0.1x0.2" + rectProperty: if(1) "9,7,100x200" + rectFProperty: if(1) "1000.1,-10.9,400x90.99" + boolProperty: if(1) true + variantProperty: if(1) "Hello World!" + vectorProperty: if(1) "10,1,2.2" + urlProperty: if(1) "main.qml" +} diff --git a/tests/auto/declarative/qmlecmascript/data/jsObject.qml b/tests/auto/declarative/qmlecmascript/data/jsObject.qml new file mode 100644 index 0000000..4128c92 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/jsObject.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +QtObject { + property int test + + Component.onCompleted: { + var o = new Object; + o.test = 92; + test = o.test; + } +} + diff --git a/tests/auto/declarative/qmlecmascript/data/methods.1.qml b/tests/auto/declarative/qmlecmascript/data/methods.1.qml index 8ba300f..42ed9a5 100644 --- a/tests/auto/declarative/qmlecmascript/data/methods.1.qml +++ b/tests/auto/declarative/qmlecmascript/data/methods.1.qml @@ -2,5 +2,5 @@ import Qt.test 1.0 MyQmlObject { id: MyObject - onBasicSignal: MyObject.method() + onBasicSignal: MyObject.methodNoArgs() } diff --git a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml b/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml new file mode 100644 index 0000000..eceff60 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +MyQmlObject { + property bool setUndefined: false + + resettableProperty: setUndefined?undefined:92 +} diff --git a/tests/auto/declarative/qmlecmascript/qmlecmascript.pro b/tests/auto/declarative/qmlecmascript/qmlecmascript.pro index 46ae045..9f592e8 100644 --- a/tests/auto/declarative/qmlecmascript/qmlecmascript.pro +++ b/tests/auto/declarative/qmlecmascript/qmlecmascript.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative script macx:CONFIG -= app_bundle SOURCES += tst_qmlecmascript.cpp \ diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h index b275b8a..09c850d 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.h +++ b/tests/auto/declarative/qmlecmascript/testtypes.h @@ -48,6 +48,13 @@ #include <QtCore/qsize.h> #include <QtDeclarative/qmllist.h> #include <QtCore/qrect.h> +#include <QtGui/qmatrix.h> +#include <QtGui/qcolor.h> +#include <QtGui/qvector3d.h> +#include <QtCore/qdatetime.h> +#include <QtScript/qscriptvalue.h> +#include <QtDeclarative/qmlscriptstring.h> +#include <QtDeclarative/qmlcomponent.h> class MyQmlAttachedObject : public QObject { @@ -72,9 +79,10 @@ class MyQmlObject : public QObject Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QmlList<QObject *> *objectQmlListProperty READ objectQmlListProperty CONSTANT) Q_PROPERTY(QList<QObject *> *objectListProperty READ objectListProperty CONSTANT) + Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) public: - MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0) {} + MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {} enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 }; enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 }; @@ -116,6 +124,11 @@ public: int value() const { return m_value; } void setValue(int v) { m_value = v; } + + int resettableProperty() const { return m_resetProperty; } + void setResettableProperty(int v) { m_resetProperty = v; } + void resetProperty() { m_resetProperty = 13; } + signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c); @@ -126,7 +139,7 @@ signals: public slots: void deleteMe() { delete this; } - void method() { m_methodCalled = true; } + void methodNoArgs() { m_methodCalled = true; } void method(int a) { if(a == 163) m_methodIntCalled = true; } void setString(const QString &s) { m_string = s; } @@ -140,6 +153,7 @@ private: QmlConcreteList<QObject *> m_objectQmlList; QList<QObject *> m_objectQList; int m_value; + int m_resetProperty; }; QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) @@ -148,7 +162,7 @@ QML_DECLARE_TYPE(MyQmlObject); class MyQmlContainer : public QObject { Q_OBJECT - Q_PROPERTY(QList<MyQmlObject*>* children READ children) + Q_PROPERTY(QList<MyQmlObject*>* children READ children CONSTANT) public: MyQmlContainer() {} @@ -270,15 +284,164 @@ QML_DECLARE_TYPE(MyExtendedObject); class MyTypeObject : public QObject { Q_OBJECT + Q_ENUMS(MyEnum) + Q_FLAGS(MyFlags) + + Q_PROPERTY(QString id READ id WRITE setId); + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty); + Q_PROPERTY(QmlComponent *componentProperty READ componentProperty WRITE setComponentProperty); + Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty); + Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty); + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty); + Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty); + 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); + Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty); Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty); Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty); Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty); Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty); Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged); + Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2); 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(QUrl urlProperty READ urlProperty WRITE setUrlProperty); + + Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty); + public: - MyTypeObject() {} + MyTypeObject() + : objectPropertyValue(0), componentPropertyValue(0) {} + + QString idValue; + QString id() const { + return idValue; + } + void setId(const QString &v) { + idValue = v; + } + + QObject *objectPropertyValue; + QObject *objectProperty() const { + return objectPropertyValue; + } + void setObjectProperty(QObject *v) { + objectPropertyValue = v; + } + + QmlComponent *componentPropertyValue; + QmlComponent *componentProperty() const { + return componentPropertyValue; + } + void setComponentProperty(QmlComponent *v) { + componentPropertyValue = v; + } + + enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 }; + Q_DECLARE_FLAGS(MyFlags, MyFlag) + MyFlags flagPropertyValue; + MyFlags flagProperty() const { + return flagPropertyValue; + } + void setFlagProperty(MyFlags v) { + flagPropertyValue = v; + } + + enum MyEnum { EnumVal1, EnumVal2 }; + MyEnum enumPropertyValue; + MyEnum enumProperty() const { + return enumPropertyValue; + } + void setEnumProperty(MyEnum v) { + enumPropertyValue = v; + } + + QString stringPropertyValue; + QString stringProperty() const { + return stringPropertyValue; + } + void setStringProperty(const QString &v) { + stringPropertyValue = v; + } + + uint uintPropertyValue; + uint uintProperty() const { + return uintPropertyValue; + } + void setUintProperty(const uint &v) { + uintPropertyValue = v; + } + + int intPropertyValue; + int intProperty() const { + return intPropertyValue; + } + void setIntProperty(const int &v) { + intPropertyValue = v; + } + + qreal realPropertyValue; + qreal realProperty() const { + return realPropertyValue; + } + void setRealProperty(const qreal &v) { + realPropertyValue = v; + } + + double doublePropertyValue; + double doubleProperty() const { + return doublePropertyValue; + } + void setDoubleProperty(const double &v) { + doublePropertyValue = v; + } + + float floatPropertyValue; + float floatProperty() const { + return floatPropertyValue; + } + void setFloatProperty(const float &v) { + floatPropertyValue = v; + } + + QColor colorPropertyValue; + QColor colorProperty() const { + return colorPropertyValue; + } + void setColorProperty(const QColor &v) { + colorPropertyValue = v; + } + + QDate datePropertyValue; + QDate dateProperty() const { + return datePropertyValue; + } + void setDateProperty(const QDate &v) { + datePropertyValue = v; + } + + QTime timePropertyValue; + QTime timeProperty() const { + return timePropertyValue; + } + void setTimeProperty(const QTime &v) { + timePropertyValue = v; + } + + QDateTime dateTimePropertyValue; + QDateTime dateTimeProperty() const { + return dateTimePropertyValue; + } + void setDateTimeProperty(const QDateTime &v) { + dateTimePropertyValue = v; + } QPoint pointPropertyValue; QPoint pointProperty() const { @@ -318,6 +481,15 @@ public: } void setRectProperty(const QRect &v) { rectPropertyValue = v; + emit rectPropertyChanged(); + } + + QRect rectPropertyValue2; + QRect rectProperty2() const { + return rectPropertyValue2; + } + void setRectProperty2(const QRect &v) { + rectPropertyValue2 = v; } QRectF rectFPropertyValue; @@ -328,8 +500,96 @@ public: rectFPropertyValue = v; } + bool boolPropertyValue; + bool boolProperty() const { + return boolPropertyValue; + } + void setBoolProperty(const bool &v) { + boolPropertyValue = v; + } + + QVariant variantPropertyValue; + QVariant variantProperty() const { + return variantPropertyValue; + } + void setVariantProperty(const QVariant &v) { + variantPropertyValue = v; + } + + QVector3D vectorPropertyValue; + QVector3D vectorProperty() const { + return vectorPropertyValue; + } + void setVectorProperty(const QVector3D &v) { + vectorPropertyValue = v; + } + + QUrl urlPropertyValue; + QUrl urlProperty() const { + return urlPropertyValue; + } + void setUrlProperty(const QUrl &v) { + urlPropertyValue = v; + } + + QmlScriptString scriptPropertyValue; + QmlScriptString scriptProperty() const { + return scriptPropertyValue; + } + void setScriptProperty(const QmlScriptString &v) { + scriptPropertyValue = v; + } + + void doAction() { emit action(); } +signals: + void action(); + void rectPropertyChanged(); }; +Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags) QML_DECLARE_TYPE(MyTypeObject); +Q_DECLARE_METATYPE(QScriptValue); +class MyInvokableObject : public QObject +{ + Q_OBJECT +public: + MyInvokableObject() { reset(); } + + int invoked() const { return m_invoked; } + bool error() const { return m_invokedError; } + const QVariantList &actuals() const { return m_actuals; } + void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); } + + Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); } + Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); } + + Q_INVOKABLE void method_NoArgs() { invoke(0); } + Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; } + Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.7; } + Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); } + Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; } + Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; } + Q_INVOKABLE QScriptValue method_NoArgs_QScriptValue() { invoke(6); return QScriptValue("Hello world"); } + Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); } + + Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; } + Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; } + Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; } + Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; } + Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; } + Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); } + Q_INVOKABLE void method_QScriptValue(QScriptValue a) { invoke(14); m_actuals << qVariantFromValue(a); } + Q_INVOKABLE void method_intQScriptValue(int a, QScriptValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); } + + Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; } + Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; } + +private: + void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;} + int m_invoked; + bool m_invokedError; + QVariantList m_actuals; +}; + #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 3aa1aff..c41e248 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -47,6 +47,9 @@ #include <QtCore/qdebug.h> #include <QtCore/private/qguard_p.h> #include <QtCore/qdir.h> +#include <QtCore/qnumeric.h> +#include <private/qmlengine_p.h> +#include <private/qmlglobalscriptclass_p.h> #include "testtypes.h" /* @@ -73,6 +76,7 @@ public: tst_qmlecmascript() {} private slots: + void assignBasicTypes(); void idShortcutInvalidates(); void boolPropertiesEvaluateAsBool(); void methods(); @@ -112,13 +116,77 @@ private slots: void shutdownErrors(); void externalScript(); void compositePropertyType(); + void jsObject(); + void undefinedResetsProperty(); + void listToVariant(); void bug1(); + void callQtInvokables(); private: QmlEngine engine; }; +void tst_qmlecmascript::assignBasicTypes() +{ + { + QmlComponent component(&engine, TEST_FILE("assignBasicTypes.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); + QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2); + QCOMPARE(object->stringProperty(), QString("Hello World!")); + QCOMPARE(object->uintProperty(), uint(10)); + 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)); + QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1))); + QCOMPARE(object->pointProperty(), QPoint(99,13)); + QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3)); + QCOMPARE(object->sizeProperty(), QSize(99, 13)); + QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2)); + QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200)); + QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99)); + QCOMPARE(object->boolProperty(), true); + QCOMPARE(object->variantProperty(), QVariant("Hello World!")); + QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); + delete object; + } + { + QmlComponent component(&engine, TEST_FILE("assignBasicTypes.2.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); + QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2); + QCOMPARE(object->stringProperty(), QString("Hello World!")); + QCOMPARE(object->uintProperty(), uint(10)); + 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)); + QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1))); + QCOMPARE(object->pointProperty(), QPoint(99,13)); + QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3)); + QCOMPARE(object->sizeProperty(), QSize(99, 13)); + QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2)); + QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200)); + QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99)); + QCOMPARE(object->boolProperty(), true); + QCOMPARE(object->variantProperty(), QVariant("Hello World!")); + QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); + delete object; + } +} + void tst_qmlecmascript::idShortcutInvalidates() { { @@ -1058,6 +1126,52 @@ void tst_qmlecmascript::compositePropertyType() delete object; } +// QTBUG-5759 +void tst_qmlecmascript::jsObject() +{ + QmlComponent component(&engine, TEST_FILE("jsObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 92); + + delete object; +} + +void tst_qmlecmascript::undefinedResetsProperty() +{ + { + QmlComponent component(&engine, TEST_FILE("undefinedResetsProperty.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("resettableProperty").toInt(), 92); + + object->setProperty("setUndefined", true); + + QCOMPARE(object->property("resettableProperty").toInt(), 13); + + object->setProperty("setUndefined", false); + + QCOMPARE(object->property("resettableProperty").toInt(), 92); + + delete object; + } + { + QmlComponent component(&engine, TEST_FILE("undefinedResetsProperty.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("resettableProperty").toInt(), 19); + + QMetaObject::invokeMethod(object, "doReset"); + + QCOMPARE(object->property("resettableProperty").toInt(), 13); + + delete object; + } +} + // QTBUG-6781 void tst_qmlecmascript::bug1() { @@ -1078,6 +1192,427 @@ void tst_qmlecmascript::bug1() delete object; } +void tst_qmlecmascript::callQtInvokables() +{ + MyInvokableObject o; + + QmlEngine qmlengine; + QmlEnginePrivate *ep = QmlEnginePrivate::get(&qmlengine); + QScriptEngine *engine = &ep->scriptEngine; + ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o)); + + // Non-existant methods + o.reset(); + QCOMPARE(engine->evaluate("object.method_nonexistant()").isError(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_nonexistant(10, 11)").isError(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + // Insufficient arguments + o.reset(); + QCOMPARE(engine->evaluate("object.method_int()").isError(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_intint(10)").isError(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + // Excessive arguments + o.reset(); + QCOMPARE(engine->evaluate("object.method_int(10, 11)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(10)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_intint(10, 11, 12)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 9); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(10)); + QCOMPARE(o.actuals().at(1), QVariant(11)); + + // Test return types + o.reset(); + QCOMPARE(engine->evaluate("object.method_NoArgs()").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 0); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QVERIFY(engine->evaluate("object.method_NoArgs_int()").strictlyEquals(QScriptValue(engine, 6))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 2); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + { + QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()"); + QVERIFY(ret.isVariant()); + QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 3); + QCOMPARE(o.actuals().count(), 0); + } + + o.reset(); + { + QScriptValue ret = engine->evaluate("object.method_NoArgs_QObject()"); + QVERIFY(ret.isQObject()); + QCOMPARE(ret.toQObject(), (QObject *)&o); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 4); + QCOMPARE(o.actuals().count(), 0); + } + + o.reset(); + QCOMPARE(engine->evaluate("object.method_NoArgs_unknown()").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 5); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + { + QScriptValue ret = engine->evaluate("object.method_NoArgs_QScriptValue()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString("Hello world")); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 6); + QCOMPARE(o.actuals().count(), 0); + } + + o.reset(); + QVERIFY(engine->evaluate("object.method_NoArgs_QVariant()").strictlyEquals(QScriptValue(engine, "QML rocks"))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 7); + QCOMPARE(o.actuals().count(), 0); + + // Test arg types + o.reset(); + QCOMPARE(engine->evaluate("object.method_int(94)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_int(\"94\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_int(\"not a number\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_int(null)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_int(undefined)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_int(object)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_intint(122, 9)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 9); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(122)); + QCOMPARE(o.actuals().at(1), QVariant(9)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_real(94.3)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94.3)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_real(\"94.3\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94.3)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_real(\"not a number\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qIsNaN(o.actuals().at(0).toDouble())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_real(null)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_real(undefined)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qIsNaN(o.actuals().at(0).toDouble())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_real(object)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qIsNaN(o.actuals().at(0).toDouble())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QString(\"Hello world\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant("Hello world")); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QString(19)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant("19")); + + o.reset(); + { + QString expected = "MyInvokableObject(0x" + QString::number((intptr_t)&o, 16) + ")"; + QCOMPARE(engine->evaluate("object.method_QString(object)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(expected)); + } + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QString(null)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QString())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QString(undefined)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QString())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QPointF(0)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QPointF(null)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QPointF(undefined)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QPointF(object)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPointF())").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2))); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPoint())").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12))); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QObject(0)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QObject(\"Hello world\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QObject(null)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QObject(undefined)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QObject(object)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QScriptValue(null)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isNull()); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QScriptValue(undefined)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isUndefined()); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QScriptValue(19)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).strictlyEquals(QScriptValue(engine, 19))); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QScriptValue([19, 20])").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isArray()); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_intQScriptValue(4, null)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(4)); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isNull()); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_intQScriptValue(8, undefined)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(8)); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isUndefined()); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_intQScriptValue(3, 19)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(3)); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).strictlyEquals(QScriptValue(engine, 19))); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_intQScriptValue(44, [19, 20])").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(44)); + QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isArray()); + + // Test overloads - QML will always invoke the *last* method + o.reset(); + QCOMPARE(engine->evaluate("object.method_overload()").isError(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_overload(10)").isError(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_overload(10, 11)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 17); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(10)); + QCOMPARE(o.actuals().at(1), QVariant(11)); +} + +// QTBUG-5675 +void tst_qmlecmascript::listToVariant() +{ + QmlComponent component(&engine, TEST_FILE("listToVariant.qml")); + + MyQmlContainer container; + + QmlContext context(engine.rootContext()); + context.addDefaultObject(&container); + + QObject *object = component.create(&context); + QVERIFY(object != 0); + + QCOMPARE(object->property("test"), QVariant::fromValue(container.children())); + + delete object; + +} + QTEST_MAIN(tst_qmlecmascript) #include "tst_qmlecmascript.moc" diff --git a/tests/auto/declarative/qmlfontloader/data/FreeMono.ttf b/tests/auto/declarative/qmlfontloader/data/FreeMono.ttf Binary files differdeleted file mode 100644 index d7ce52d..0000000 --- a/tests/auto/declarative/qmlfontloader/data/FreeMono.ttf +++ /dev/null diff --git a/tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf b/tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf Binary files differnew file mode 100644 index 0000000..cf93f96 --- /dev/null +++ b/tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf diff --git a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp index 27664fb..25bb935 100644 --- a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp +++ b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp @@ -99,14 +99,14 @@ void tst_qmlfontloader::namedFont() void tst_qmlfontloader::localFont() { - QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/FreeMono.ttf\" }"; + QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }"; QmlComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("FreeMono")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready); } diff --git a/tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml b/tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml new file mode 100644 index 0000000..e620e26 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyPropertyValueSource { + property int x +} + diff --git a/tests/auto/declarative/qmllanguage/data/assignSignal.qml b/tests/auto/declarative/qmllanguage/data/assignSignal.qml index 3abc04d..2a48df8 100644 --- a/tests/auto/declarative/qmllanguage/data/assignSignal.qml +++ b/tests/auto/declarative/qmllanguage/data/assignSignal.qml @@ -1,5 +1,5 @@ import Test 1.0 MyQmlObject { onBasicSignal: basicSlot() - onBasicParameterizedSignal: basicSlot(parameter) + onBasicParameterizedSignal: basicSlotWithArgs(parameter) } diff --git a/tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml b/tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml new file mode 100644 index 0000000..57a6070 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + intProperty : MyCompositeValueSource {} +} + diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h index 0f2cdf9..d6ca898 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.h +++ b/tests/auto/declarative/qmllanguage/testtypes.h @@ -139,7 +139,7 @@ public: void setCustomType(const MyCustomVariantType &v) { m_custom = v; } public slots: void basicSlot() { qWarning("MyQmlObject::basicSlot"); } - void basicSlot(int v) { qWarning("MyQmlObject::basicSlot(%d)", v); } + void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); } signals: void basicSignal(); diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index e3a81cb..0a636db 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -541,7 +541,7 @@ void tst_qmllanguage::assignSignal() QVERIFY(object != 0); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); emit object->basicSignal(); - QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot(9)"); + QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)"); emit object->basicParameterizedSignal(9); } @@ -650,6 +650,7 @@ void tst_qmllanguage::autoComponentCreation() void tst_qmllanguage::propertyValueSource() { + { QmlComponent component(&engine, TEST_FILE("propertyValueSource.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -658,8 +659,7 @@ void tst_qmllanguage::propertyValueSource() QList<QObject *> valueSources; QObjectList allChildren = object->findChildren<QObject*>(); foreach (QObject *child, allChildren) { - QmlType *type = QmlMetaType::qmlType(child->metaObject()); - if (type && type->propertyValueSourceCast() != -1) + if (qobject_cast<QmlPropertyValueSource *>(child)) valueSources.append(child); } @@ -669,6 +669,28 @@ void tst_qmllanguage::propertyValueSource() QVERIFY(valueSource != 0); QCOMPARE(valueSource->prop.object(), object); QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty"))); + } + + { + QmlComponent component(&engine, TEST_FILE("propertyValueSource.2.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QList<QObject *> valueSources; + QObjectList allChildren = object->findChildren<QObject*>(); + foreach (QObject *child, allChildren) { + if (qobject_cast<QmlPropertyValueSource *>(child)) + valueSources.append(child); + } + + QCOMPARE(valueSources.count(), 1); + MyPropertyValueSource *valueSource = + qobject_cast<MyPropertyValueSource *>(valueSources.at(0)); + QVERIFY(valueSource != 0); + QCOMPARE(valueSource->prop.object(), object); + QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty"))); + } } void tst_qmllanguage::attachedProperties() diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index 0986d20..a36541e 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -52,6 +52,8 @@ public: private slots: void static_i18n(); + void static_nestedElements(); + void static_nestedElements_data(); void dynamic_data(); void dynamic(); void error_data(); @@ -72,6 +74,50 @@ void tst_QmlListModel::static_i18n() delete obj; } +void tst_QmlListModel::static_nestedElements() +{ + QFETCH(int, elementCount); + + QStringList elements; + for (int i=0; i<elementCount; i++) + elements.append("ListElement { a: 1; b: 2 }"); + QString elementsStr = elements.join(",\n") + "\n"; + + QString componentStr = + "import Qt 4.6\n" + "ListModel {\n" + " ListElement {\n" + " attributes: [\n"; + componentStr += elementsStr.toUtf8().constData(); + componentStr += + " ]\n" + " }\n" + "}"; + + QmlEngine engine; + QmlComponent component(&engine); + component.setData(componentStr.toUtf8(), QUrl("file://")); + + QmlListModel *obj = qobject_cast<QmlListModel*>(component.create()); + QVERIFY(obj != 0); + + QScriptValue prop = obj->get(0).property(QLatin1String("attributes")).property(QLatin1String("count")); + QVERIFY(prop.isNumber()); + QCOMPARE(prop.toInt32(), qint32(elementCount)); + + delete obj; +} + +void tst_QmlListModel::static_nestedElements_data() +{ + QTest::addColumn<int>("elementCount"); + + QTest::newRow("0 items") << 0; + QTest::newRow("1 item") << 1; + QTest::newRow("2 items") << 2; + QTest::newRow("many items") << 5; +} + void tst_QmlListModel::dynamic_data() { QTest::addColumn<QString>("script"); @@ -83,6 +129,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; + QTest::newRow("get2") << "{get(-1)}" << 0 << "QML ListModel (unknown location) get: index -1 out of range"; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; @@ -100,6 +147,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; + QTest::newRow("remove3a") << "{append({'foo':123});remove(-1)}" << 0 << "QML ListModel (unknown location) remove: index -1 out of range"; QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range"; @@ -120,17 +168,19 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << ""; QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; + QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object"; QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object"; QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; - QTest::newRow("setprop1") << "{append({'foo':123});set(0,'foo',456);count}" << 1 << ""; - QTest::newRow("setprop2") << "{append({'foo':123});set(0,'foo',456);get(0).foo}" << 456 << ""; - QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});set(0,'foo',999);get(0).foo}" << 999 << ""; - QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});set(0,'foo',999);get(0).bar}" << 456 << ""; - QTest::newRow("setprop4a") << "{set(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; - QTest::newRow("setprop4a") << "{append({'foo':123,'bar':456});set(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range"; - QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});set(1,'bar',222);get(1).bar}" << 222 << ""; + QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << ""; + QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << ""; + QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << ""; + QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << ""; + QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; + QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; + QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range"; + QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << ""; QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << ""; diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index 63d8274..ec6b87f 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -56,6 +56,20 @@ public: QML_DECLARE_TYPE(MyQmlObject); QML_DEFINE_TYPE(Test,1,0,MyQmlObject,MyQmlObject); +class MyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo WRITE setFoo) +public: + MyAttached(QObject *parent) : QObject(parent), m_foo(13) {} + + int foo() const { return m_foo; } + void setFoo(int f) { m_foo = f; } + +private: + int m_foo; +}; + class MyContainer : public QObject { Q_OBJECT @@ -67,6 +81,10 @@ public: QList<MyQmlObject*> *children() { return &m_children; } QmlConcreteList<MyQmlObject *> *qmlChildren() { return &m_qmlChildren; } + static MyAttached *qmlAttachedProperties(QObject *o) { + return new MyAttached(o); + } + private: QList<MyQmlObject*> m_children; QmlConcreteList<MyQmlObject *> m_qmlChildren; @@ -74,6 +92,7 @@ private: QML_DECLARE_TYPE(MyContainer); QML_DEFINE_TYPE(Test,1,0,MyContainer,MyContainer); +QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES) class tst_qmlmetaproperty : public QObject { @@ -94,6 +113,7 @@ private slots: void name(); void read(); void write(); + void reset(); // Functionality void writeObjectToList(); @@ -134,6 +154,7 @@ void tst_qmlmetaproperty::qmlmetaproperty() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty); @@ -159,9 +180,12 @@ class PropertyObject : public QObject Q_PROPERTY(QRect rectProperty READ rectProperty); Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty); Q_PROPERTY(QUrl url READ url WRITE setUrl); + Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty); Q_CLASSINFO("DefaultProperty", "defaultProperty"); public: + PropertyObject() : m_resetProperty(9) {} + int defaultProperty() { return 10; } QRect rectProperty() { return QRect(10, 10, 1, 209); } @@ -171,10 +195,15 @@ public: QUrl url() { return m_url; } void setUrl(const QUrl &u) { m_url = u; } + int resettableProperty() const { return m_resetProperty; } + void setResettableProperty(int r) { m_resetProperty = r; } + void resetProperty() { m_resetProperty = 9; } + signals: void clicked(); private: + int m_resetProperty; QRect m_rect; QUrl m_url; }; @@ -211,6 +240,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty); @@ -257,6 +287,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object() QCOMPARE(prop.isDefault(), true); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal); @@ -310,6 +341,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty); @@ -356,6 +388,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal); @@ -404,6 +437,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_string() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty); @@ -456,6 +490,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_context() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty); @@ -502,6 +537,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_context() QCOMPARE(prop.isDefault(), true); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal); @@ -555,6 +591,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), false); QCOMPARE(prop.object(), (QObject *)0); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty); @@ -601,6 +638,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal); @@ -649,6 +687,7 @@ void tst_qmlmetaproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty); @@ -798,6 +837,38 @@ void tst_qmlmetaproperty::read() delete o; QCOMPARE(p.read(), QVariant()); } + + // Attached property + { + QmlComponent component(&engine); + component.setData("import Test 1.0\nMyContainer { }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object)); + QCOMPARE(p.read(), QVariant(13)); + delete object; + } + { + QmlComponent component(&engine); + component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object)); + QCOMPARE(p.read(), QVariant(10)); + delete object; + } + { + QmlComponent component(&engine); + component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QmlMetaProperty p = QmlMetaProperty::createProperty(object, "Foo.MyContainer.foo", qmlContext(object)); + QCOMPARE(p.read(), QVariant(10)); + delete object; + } } void tst_qmlmetaproperty::write() @@ -896,6 +967,103 @@ void tst_qmlmetaproperty::write() QCOMPARE(p2.write(QUrl("main.qml")), true); QCOMPARE(o.url(), result); } + + // Attached property + { + QmlComponent component(&engine); + component.setData("import Test 1.0\nMyContainer { }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object)); + p.write(QVariant(99)); + QCOMPARE(p.read(), QVariant(99)); + delete object; + } + { + QmlComponent component(&engine); + component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QmlMetaProperty p = QmlMetaProperty::createProperty(object, "Foo.MyContainer.foo", qmlContext(object)); + p.write(QVariant(99)); + QCOMPARE(p.read(), QVariant(99)); + delete object; + } +} + +void tst_qmlmetaproperty::reset() +{ + // Invalid + { + QmlMetaProperty p; + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Read-only default prop + { + PropertyObject o; + QmlMetaProperty p(&o); + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Invalid default prop + { + QObject o; + QmlMetaProperty p(&o); + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Non-resettable-only prop by name + { + PropertyObject o; + QmlMetaProperty p(&o, QString("defaultProperty")); + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Resettable prop by name + { + PropertyObject o; + QmlMetaProperty p(&o, QString("resettableProperty")); + + QCOMPARE(p.read(), QVariant(9)); + QCOMPARE(p.write(QVariant(11)), true); + QCOMPARE(p.read(), QVariant(11)); + + QCOMPARE(p.isResettable(), true); + QCOMPARE(p.reset(), true); + + QCOMPARE(p.read(), QVariant(9)); + } + + // Deleted object + { + PropertyObject *o = new PropertyObject; + + QmlMetaProperty p(o, QString("resettableProperty")); + + QCOMPARE(p.isResettable(), true); + QCOMPARE(p.reset(), true); + + delete o; + + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Signal property + { + PropertyObject o; + QmlMetaProperty p(&o, "onClicked"); + + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } } void tst_qmlmetaproperty::writeObjectToList() diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp index 215f3c3..6c9d849 100644 --- a/tests/auto/declarative/shared/testhttpserver.cpp +++ b/tests/auto/declarative/shared/testhttpserver.cpp @@ -106,6 +106,15 @@ bool TestHTTPServer::serveDirectory(const QString &dir, Mode mode) return true; } +/* + Add an alias, so that if filename is requested and does not exist, + alias may be returned. +*/ +void TestHTTPServer::addAlias(const QString &filename, const QString &alias) +{ + aliases.insert(filename, alias); +} + bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &body) { m_hasFailed = false; @@ -226,7 +235,12 @@ bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileName) Mode mode = dirs.at(ii).second; QString dirFile = dir + QLatin1String("/") + QLatin1String(fileName); - + + if (!QFile::exists(dirFile)) { + if (aliases.contains(fileName)) + dirFile = dir + QLatin1String("/") + aliases.value(fileName); + } + QFile file(dirFile); if (file.open(QIODevice::ReadOnly)) { diff --git a/tests/auto/declarative/shared/testhttpserver.h b/tests/auto/declarative/shared/testhttpserver.h index 62fe7b4..2a8709f 100644 --- a/tests/auto/declarative/shared/testhttpserver.h +++ b/tests/auto/declarative/shared/testhttpserver.h @@ -61,6 +61,8 @@ public: bool wait(const QUrl &expect, const QUrl &reply, const QUrl &body); bool hasFailed() const; + void addAlias(const QString &filename, const QString &aliasName); + private slots: void newConnection(); void disconnected(); @@ -80,6 +82,8 @@ private: QByteArray bodyData; bool m_hasFailed; + QHash<QString,QString> aliases; + QTcpServer server; }; diff --git a/tests/auto/declarative/states/data/nonExistantProp.qml b/tests/auto/declarative/states/data/nonExistantProp.qml new file mode 100644 index 0000000..582029d --- /dev/null +++ b/tests/auto/declarative/states/data/nonExistantProp.qml @@ -0,0 +1,11 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: MyRectangle; colr: "blue" } + } +} diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp index 3c89747..bf8948a 100644 --- a/tests/auto/declarative/states/tst_states.cpp +++ b/tests/auto/declarative/states/tst_states.cpp @@ -75,6 +75,7 @@ private slots: void deletingState(); void tempState(); void illegalTempState(); + void nonExistantProperty(); }; void tst_states::basicChanges() @@ -857,6 +858,19 @@ void tst_states::illegalTempState() QCOMPARE(rect->state(), QLatin1String("placed")); } +void tst_states::nonExistantProperty() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create()); + QVERIFY(rect != 0); + + QTest::ignoreMessage(QtWarningMsg, "QML PropertyChanges (file://" SRCDIR "/data/nonExistantProp.qml:9:9) Cannot assign to non-existant property \"colr\""); + rect->setState("blue"); + QCOMPARE(rect->state(), QLatin1String("blue")); +} + QTEST_MAIN(tst_states) #include "tst_states.moc" diff --git a/tests/auto/declarative/visual/webview/settings/FreeMono.ttf b/tests/auto/declarative/visual/webview/settings/FreeMono.ttf Binary files differdeleted file mode 100644 index d7ce52d..0000000 --- a/tests/auto/declarative/visual/webview/settings/FreeMono.ttf +++ /dev/null diff --git a/tests/auto/declarative/visual/webview/settings/data/setFontFamily.0.png b/tests/auto/declarative/visual/webview/settings/data/setFontFamily.0.png Binary files differindex 1a0448a..f3c621a 100644 --- a/tests/auto/declarative/visual/webview/settings/data/setFontFamily.0.png +++ b/tests/auto/declarative/visual/webview/settings/data/setFontFamily.0.png diff --git a/tests/auto/declarative/visual/webview/settings/data/setFontFamily.qml b/tests/auto/declarative/visual/webview/settings/data/setFontFamily.qml index da71ef1..cf74d42 100644 --- a/tests/auto/declarative/visual/webview/settings/data/setFontFamily.qml +++ b/tests/auto/declarative/visual/webview/settings/data/setFontFamily.qml @@ -6,239 +6,239 @@ VisualTest { } Frame { msec: 16 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 32 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 48 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 64 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 80 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 96 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 112 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 128 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 144 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 160 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 176 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 192 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 208 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 224 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 240 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 256 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 272 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 288 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 304 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 320 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 336 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 352 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 368 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 384 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 400 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 416 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 432 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 448 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 464 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 480 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 496 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 512 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 528 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 544 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 560 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 576 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 592 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 608 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 624 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 640 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 656 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 672 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 688 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 704 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 720 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 736 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 752 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 768 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 784 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 800 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 816 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 832 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 848 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 864 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 880 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 896 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 912 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 928 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 944 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 960 @@ -246,106 +246,106 @@ VisualTest { } Frame { msec: 976 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 992 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1008 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1024 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1040 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1056 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1072 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1088 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1104 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1120 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1136 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1152 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1168 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1184 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1200 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1216 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1232 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1248 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1264 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1280 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1296 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1312 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1328 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1344 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1360 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } Frame { msec: 1376 - hash: "52d74d4a6716ed4d4e202de6480b13b2" + hash: "7ef8bb83c146898bd75de8951a932b58" } } diff --git a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml index 99d5f2a..26deed8 100644 --- a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml +++ b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml @@ -2,9 +2,9 @@ import Qt 4.6 WebView { url: "test.html" - width: 200 - height: 200 + width: 300 + height: 300 settings.standardFontFamily: font.name // WebKit doesn't seem to honour any other FontFamily settings - FontLoader { id: font; source: "FreeMono.ttf" } + FontLoader { id: font; source: "tarzeau_ocr_a.ttf" } } diff --git a/tests/auto/declarative/visual/webview/settings/tarzeau_ocr_a.ttf b/tests/auto/declarative/visual/webview/settings/tarzeau_ocr_a.ttf Binary files differnew file mode 100644 index 0000000..cf93f96 --- /dev/null +++ b/tests/auto/declarative/visual/webview/settings/tarzeau_ocr_a.ttf diff --git a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp index 6e0d582..d3201e2 100644 --- a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp +++ b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp @@ -43,8 +43,6 @@ #include <QmlEngine> #include <QmlComponent> #include <QDebug> -#include <QWebPage> -#include <QWebFrame> #include <QNetworkCookieJar> #include "testhttpserver.h" @@ -118,14 +116,6 @@ private: QmlEngine engine; }; -class QWebPageWithJavaScriptConsoleMessages : public QWebPage { -public: - void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) - { - qWarning() << sourceID << ":" << lineNumber << ":" << message; - } -}; - inline QUrl TEST_FILE(const QString &filename) { return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); diff --git a/tests/auto/declarative/xmlhttprequest/xmlhttprequest.pro b/tests/auto/declarative/xmlhttprequest/xmlhttprequest.pro index 6af4e39..1da28e5 100644 --- a/tests/auto/declarative/xmlhttprequest/xmlhttprequest.pro +++ b/tests/auto/declarative/xmlhttprequest/xmlhttprequest.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative webkit network +contains(QT_CONFIG,declarative): QT += declarative network macx:CONFIG -= app_bundle INCLUDEPATH += ../shared/ |