summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmlbindengine/enums.1.qml20
-rw-r--r--tests/auto/declarative/qmlbindengine/testtypes.h19
-rw-r--r--tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp19
3 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlbindengine/enums.1.qml b/tests/auto/declarative/qmlbindengine/enums.1.qml
new file mode 100644
index 0000000..6351823
--- /dev/null
+++ b/tests/auto/declarative/qmlbindengine/enums.1.qml
@@ -0,0 +1,20 @@
+import Qt.test 1.0
+import Qt.test 1.0 as Namespace
+
+MyQmlObject {
+ // Enums from non-namespaced type
+ property int a: MyQmlObject.EnumValue1
+ property int b: MyQmlObject.EnumValue2
+ property int c: MyQmlObject.EnumValue3
+ property int d: MyQmlObject.EnumValue4
+
+ // Enums from namespaced type
+ property int e: Namespace.MyQmlObject.EnumValue1
+ property int f: Namespace.MyQmlObject.EnumValue2
+ property int g: Namespace.MyQmlObject.EnumValue3
+ property int h: Namespace.MyQmlObject.EnumValue4
+
+ // Test that enums don't mask attached properties
+ property int i: MyQmlObject.value
+ property int j: Namespace.MyQmlObject.value
+}
diff --git a/tests/auto/declarative/qmlbindengine/testtypes.h b/tests/auto/declarative/qmlbindengine/testtypes.h
index f5b309e..f27c0b0 100644
--- a/tests/auto/declarative/qmlbindengine/testtypes.h
+++ b/tests/auto/declarative/qmlbindengine/testtypes.h
@@ -5,9 +5,21 @@
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlexpression.h>
+class MyQmlAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value CONSTANT)
+public:
+ MyQmlAttachedObject(QObject *parent) : QObject(parent) {}
+
+ int value() const { return 19; }
+};
+
class MyQmlObject : public QObject
{
Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_ENUMS(MyEnum2)
Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
@@ -15,6 +27,9 @@ class MyQmlObject : public QObject
public:
MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0) {}
+ enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
+ enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
+
bool trueProperty() const { return true; }
bool falseProperty() const { return false; }
@@ -39,6 +54,10 @@ public:
bool methodIntCalled() const { return m_methodIntCalled; }
QString string() const { return m_string; }
+
+ static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new MyQmlAttachedObject(o);
+ }
signals:
void basicSignal();
void argumentSignal(int a, QString b, qreal c);
diff --git a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
index 01cb54b..80373fe 100644
--- a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
+++ b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
@@ -38,6 +38,7 @@ private slots:
void objectPropertiesTriggerReeval();
void deferredProperties();
void extensionObjects();
+ void enums();
private:
QmlEngine engine;
@@ -366,6 +367,24 @@ void tst_qmlbindengine::extensionObjects()
QCOMPARE(object->baseProperty(), 92);
}
+void tst_qmlbindengine::enums()
+{
+ QmlComponent component(&engine, TEST_FILE("enums.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 1);
+ QCOMPARE(object->property("c").toInt(), 2);
+ QCOMPARE(object->property("d").toInt(), 3);
+ QCOMPARE(object->property("e").toInt(), 0);
+ QCOMPARE(object->property("f").toInt(), 1);
+ QCOMPARE(object->property("g").toInt(), 2);
+ QCOMPARE(object->property("h").toInt(), 3);
+ QCOMPARE(object->property("i").toInt(), 19);
+ QCOMPARE(object->property("j").toInt(), 19);
+}
+
QTEST_MAIN(tst_qmlbindengine)
#include "tst_qmlbindengine.moc"