diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-06-22 09:23:26 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-22 06:54:59 +0200 |
commit | 55faad4873a9409bb1b33a10da7329d13a95aff9 (patch) | |
tree | b08f5b801079e49ddc9d6a5839eeb14a1e238a0f /tests | |
parent | 033bf75d99c281d4a133fada297b7b141a0af555 (diff) |
Handle enum values of -1 correctly.
This was already handled correctly most places; now the
remaining cases (using an enum in ListModel, and assigning
an enum to an integer property) should also work correctly.
Task-number: QTBUG-21679
Change-Id: Ibff13f0b94da94b18e2e3bae4aa6ba44e0fa944b
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests')
4 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/enums.3.qml b/tests/auto/qml/qqmlecmascript/data/enums.3.qml index c77d635a1e..fd3432fc9f 100644 --- a/tests/auto/qml/qqmlecmascript/data/enums.3.qml +++ b/tests/auto/qml/qqmlecmascript/data/enums.3.qml @@ -19,6 +19,9 @@ Item { property int h: Namespace.MyQmlObject.EnumValue3 property int i: Namespace.MyQmlObject.EnumValue4 + // -1 enum + property int j: MyQmlObject.EnumValue5 + // Count the onChanged signals to see whether // they're assigned as literals or via bindings property int ac: 0 @@ -29,6 +32,7 @@ Item { property int fc: 0 property int hc: 0 property int ic: 0 + property int jc: 0 onAChanged: ac++ onBChanged: bc++ @@ -38,4 +42,5 @@ Item { onFChanged: fc++ onHChanged: hc++ onIChanged: ic++ + onJChanged: jc++ } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 8f3804a05b..ab44d5986e 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -111,7 +111,7 @@ public: 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 }; + enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3, EnumValue5 = -1 }; bool trueProperty() const { return true; } bool falseProperty() const { return false; } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index d344758147..c429ffaa4b 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -983,6 +983,7 @@ void tst_qqmlecmascript::enums() QCOMPARE(object->property("f").toInt(), 3); QCOMPARE(object->property("h").toInt(), 2); QCOMPARE(object->property("i").toInt(), 3); + QCOMPARE(object->property("j").toInt(), -1); // count of change signals QCOMPARE(object->property("ac").toInt(), 0); @@ -993,6 +994,7 @@ void tst_qqmlecmascript::enums() QCOMPARE(object->property("fc").toInt(), 0); QCOMPARE(object->property("hc").toInt(), 1); // namespace -> binding QCOMPARE(object->property("ic").toInt(), 1); // namespace -> binding + QCOMPARE(object->property("jc").toInt(), 0); delete object; } diff --git a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp index 4c4aa4801f..89e88869e3 100644 --- a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp +++ b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp @@ -41,6 +41,7 @@ #include <qtest.h> #include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquicktext_p.h> +#include <QtQuick/private/qquickanimation_p.h> #include <QtQml/private/qqmlengine_p.h> #include <QtQml/private/qquicklistmodel_p.h> #include <QtQml/private/qqmlexpression_p.h> @@ -228,6 +229,11 @@ void tst_qquicklistmodel::static_types_data() << QVariant(double(Qt::AlignBottom)) << QString(); + QTest::newRow("negative enum") + << "ListElement { foo: Animation.Infinite }" + << QVariant(double(QQuickAbstractAnimation::Infinite)) + << QString(); + QTest::newRow("role error") << "ListElement { foo: 1 } ListElement { foo: 'string' }" << QVariant() |