diff options
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/variantConvert.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.h | 14 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 14 |
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/variantConvert.qml b/tests/auto/qml/qqmlecmascript/data/variantConvert.qml new file mode 100644 index 0000000000..f15b255987 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/variantConvert.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + Component.onCompleted: { + var testVar = variantObject.getIndex() + variantObject.selection(testVar, 1) + } +} + diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 03e3262e7b..4c22468080 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -47,6 +47,9 @@ #include <QtQml/qjsvalue.h> #include <QtQml/qqmlscriptstring.h> #include <QtQml/qqmlcomponent.h> +#include <QtCore/QModelIndex> +#include <QtCore/QPersistentModelIndex> +#include <QtCore/QItemSelection> #include <private/qqmlengine_p.h> #include <private/qv4qobjectwrapper_p.h> @@ -1726,6 +1729,17 @@ public: Q_INVOKABLE bool clashes() const { return true; } }; +class VariantConvertObject : public QObject +{ + Q_OBJECT +public: + QString funcCalled; +public slots: + QPersistentModelIndex getIndex() const { return QPersistentModelIndex(QModelIndex()); } + void selection(const QModelIndex &mi, int n = 0) { funcCalled = QLatin1String("QModelIndex"); } + void selection(const QItemSelection &is, int n = 0) { funcCalled = QLatin1String("QItemSelection"); } +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 4b0cbfa1aa..1e10841430 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -381,6 +381,7 @@ private slots: void getThisObject(); void semicolonAfterProperty(); void hugeStack(); + void variantConversionMethod(); void gcCrashRegressionTest(); @@ -9292,6 +9293,19 @@ void tst_qqmlecmascript::gcCrashRegressionTest() QCOMPARE(process.exitCode(), 0); } +void tst_qqmlecmascript::variantConversionMethod() +{ + QQmlEngine qmlengine; + + VariantConvertObject obj; + qmlengine.rootContext()->setContextProperty("variantObject", &obj); + + QQmlComponent component(&qmlengine, testFileUrl("variantConvert.qml")); + QScopedPointer<QObject> o(component.create()); + QVERIFY(o != nullptr); + QCOMPARE(obj.funcCalled, QLatin1String("QModelIndex")); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |