aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-03-22 10:38:00 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-26 02:55:20 +0200
commitd120c3c383d7db7a7c7f1602ba27f04cebb8abfa (patch)
tree1c39dcfbc3f92754b396afa9ac142cb5b471f5fd /tests
parent6b516a83051727c1ca02a8b400409927ad615ea6 (diff)
Support registered QFlags in QML methods and signal handlers.
Change-Id: I2a71122303dcf7af4f07c3ffb73456bcdce62a74 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/registeredFlagMethod.qml5
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h5
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp15
3 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/registeredFlagMethod.qml b/tests/auto/qml/qqmlecmascript/data/registeredFlagMethod.qml
new file mode 100644
index 0000000000..b323b49662
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/registeredFlagMethod.qml
@@ -0,0 +1,5 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ onBasicSignal: registeredFlagMethod(Qt.RightButton)
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index 54fab26405..519f9e479a 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -102,7 +102,7 @@ class MyQmlObject : public QObject
Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
public:
- MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {}
+ MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0), m_buttons(0) {}
enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
@@ -173,6 +173,7 @@ public:
};
QVariant variant() const { return m_variant; }
QJSValue qjsvalue() const { return m_qjsvalue; }
+ Qt::MouseButtons buttons() const { return m_buttons; }
int intProperty() const { return m_intProperty; }
void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
@@ -201,6 +202,7 @@ public slots:
void variantMethod(const QVariant &v) { m_variant = v; }
void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; }
void v8function(QQmlV8Function*);
+ void registeredFlagMethod(Qt::MouseButtons v) { m_buttons = v; }
private:
friend class tst_qqmlecmascript;
@@ -217,6 +219,7 @@ private:
QVariant m_variant;
QJSValue m_qjsvalue;
int m_intProperty;
+ Qt::MouseButtons m_buttons;
};
QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 403cc63496..fa1a6a5920 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -244,6 +244,7 @@ private slots:
void revision();
void invokableWithQObjectDerived();
void realTypePrecision();
+ void registeredFlagMethod();
void automaticSemicolon();
void unaryExpression();
@@ -6354,6 +6355,20 @@ void tst_qqmlecmascript::realTypePrecision()
QCOMPARE(object->property("test6").toDouble(), 1234567890.*2);
}
+void tst_qqmlecmascript::registeredFlagMethod()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("registeredFlagMethod.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->buttons(), 0);
+ emit object->basicSignal();
+ QCOMPARE(object->buttons(), Qt::RightButton);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"