diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
3 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml new file mode 100644 index 0000000000..451cb03206 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool result + urlProperty: stringProperty + "/index.html" + intProperty: if (urlProperty) 123; else 321 + value: urlProperty == stringProperty + "/index.html" + result: urlProperty == urlProperty +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index cd5bac5253..2f1d3f9414 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -93,6 +93,7 @@ class MyQmlObject : public QObject Q_PROPERTY(int value READ value WRITE setValue) Q_PROPERTY(int console READ console CONSTANT) Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT) Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) @@ -118,6 +119,15 @@ public: emit stringChanged(); } + QUrl urlProperty() const { return m_url; } + void setUrlProperty(const QUrl &url) + { + if (url == m_url) + return; + m_url = url; + emit urlChanged(); + } + QObject *objectProperty() const { return m_object; } void setObjectProperty(QObject *obj) { if (obj == m_object) @@ -171,6 +181,7 @@ signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e); void stringChanged(); + void urlChanged(); void objectChanged(); void anotherBasicSignal(); void thirdBasicSignal(); @@ -196,6 +207,7 @@ private: QObject *m_object; QString m_string; + QUrl m_url; QList<QObject *> m_objectQList; int m_value; int m_resetProperty; diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index a01c80b7e3..f3d810ed9d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -220,6 +220,7 @@ private slots: void aliasWritesOverrideBindings(); void aliasToCompositeElement(); void realToInt(); + void urlProperty(); void dynamicString(); void include(); void signalHandlers(); @@ -5462,6 +5463,21 @@ void tst_qdeclarativeecmascript::realToInt() QMetaObject::invokeMethod(object, "test2"); QCOMPARE(object->value(), int(8)); } + +void tst_qdeclarativeecmascript::urlProperty() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("urlProperty.1.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); + QVERIFY(object != 0); + object->setStringProperty("http://qt-project.org"); + QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html")); + QCOMPARE(object->intProperty(), 123); + QCOMPARE(object->value(), 1); + QCOMPARE(object->property("result").toBool(), true); + } +} + void tst_qdeclarativeecmascript::dynamicString() { QDeclarativeComponent component(&engine, TEST_FILE("dynamicString.qml")); |