summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-04-05 16:55:18 +1000
committerBea Lam <bea.lam@nokia.com>2011-04-12 11:07:49 +1000
commitf2219ce983098fc14655d8f3bb8a7fee2c9abe4d (patch)
treef8efd2e3eab7ff4ee868985fa7cdeb3fad0f0f1e /tests/auto/declarative
parent6ec7695eaa02c923b90d72e3918b9ab50da63e41 (diff)
Allow enum values to be used as signal parameters
The fix does not work for enums declared outside of the class that emits the signal, since in this case it is not possible to access the metaobject of the class that declared the enum. However the fix makes a special case for the Qt namespace to allow enums in this namespace to be used. Task-number: QTBUG-15983 Change-Id: I6f72255b07010311a20fe068bd97c7db7b294d9b Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp46
5 files changed, 33 insertions, 27 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
index 8addcb9125..6467c42bb9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
@@ -1,5 +1,5 @@
import Qt.test 1.0
MyQmlObject {
- onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c)
+ onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c + ' ' + d + ' ' + e)
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
index ffbe317690..4fc2dab943 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
@@ -7,10 +7,12 @@ MyQmlObject
property real realProperty
property color colorProperty
property variant variantProperty
+ property int enumProperty
+ property int qtEnumProperty
- signal mySignal(int a, real b, color c, variant d)
+ signal mySignal(int a, real b, color c, variant d, int e, int f)
- onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; }
+ onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; enumProperty = e; qtEnumProperty = f; }
- onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1))
+ onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton)
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index 7e63bd54f9..1d65b15476 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -127,6 +127,8 @@ void registerTypes()
qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
+ qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
+ qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 081cc4ce5a..94cec3fb18 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -159,7 +159,7 @@ public:
signals:
void basicSignal();
- void argumentSignal(int a, QString b, qreal c);
+ void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
void stringChanged();
void objectChanged();
void anotherBasicSignal();
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 48466d5a32..78766712b8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -304,8 +304,8 @@ void tst_qdeclarativeecmascript::signalAssignment()
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.25);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25"));
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
}
}
@@ -870,7 +870,7 @@ void tst_qdeclarativeecmascript::scope()
QCOMPARE(object->property("test").toInt(), 0);
QCOMPARE(object->property("test2").toString(), QString());
- emit object->argumentSignal(13, "Argument Scope", 9);
+ emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 13);
QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
@@ -895,6 +895,8 @@ void tst_qdeclarativeecmascript::signalParameterTypes()
QCOMPARE(object->property("realProperty").toReal(), 19.2);
QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
+ QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
+ QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
}
/*
@@ -1139,7 +1141,7 @@ void tst_qdeclarativeecmascript::signalTriggeredBindings()
QCOMPARE(object->property("test1").toReal(), 200.);
QCOMPARE(object->property("test2").toReal(), 200.);
- object->argumentSignal(10, QString(), 10);
+ object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("base").toReal(), 400.);
QCOMPARE(object->property("test1").toReal(), 400.);
@@ -1940,7 +1942,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1953,7 +1955,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1966,7 +1968,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1979,7 +1981,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -1992,7 +1994,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -2005,7 +2007,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2021,13 +2023,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2040,13 +2042,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2059,13 +2061,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 3);
delete object;
@@ -2077,13 +2079,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 3);
delete object;