summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeecmascript
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-06-25 05:13:20 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-06-25 05:13:20 (GMT)
commit46233eaa956e57a4c948cec759a3be606a8bdcb8 (patch)
tree17e9335f320a7f41d0271f28361cac913a4ad36b /tests/auto/declarative/qdeclarativeecmascript
parent2d7e341646e302506531cb0bf87b8da5d088c319 (diff)
downloadQt-46233eaa956e57a4c948cec759a3be606a8bdcb8.zip
Qt-46233eaa956e57a4c948cec759a3be606a8bdcb8.tar.gz
Qt-46233eaa956e57a4c948cec759a3be606a8bdcb8.tar.bz2
Handle enums in method arguments in the same way as QtScript
QML will now invoke methods with enums as arguments, in the same fashion as QtScript. QTBUG-11313
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp7
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index fef76ef..849879e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -557,7 +557,9 @@ Q_DECLARE_METATYPE(QScriptValue);
class MyInvokableObject : public QObject
{
Q_OBJECT
+ Q_ENUMS(TestEnum)
public:
+ enum TestEnum { EnumValue1, EnumValue2 };
MyInvokableObject() { reset(); }
int invoked() const { return m_invoked; }
@@ -589,6 +591,8 @@ public:
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; }
+ Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(18); m_actuals << (int)e; }
+
private:
void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
int m_invoked;
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 5619f22..43900ae 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -1721,6 +1721,13 @@ void tst_qdeclarativeecmascript::callQtInvokables()
QCOMPARE(o.actuals().count(), 2);
QCOMPARE(o.actuals().at(0), QVariant(10));
QCOMPARE(o.actuals().at(1), QVariant(11));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_with_enum(9)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 18);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
}
// QTBUG-5675