diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-11-12 09:50:29 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-15 13:07:52 +0100 |
commit | 0dc17ae4d8b01582d9a9d2fa89f0d72cd022f5cf (patch) | |
tree | c427b62e6f20f17b71f1f0de0d59cd5fc8b6d5ae /tests | |
parent | d7a876d0025290e506622af85403fa3c5fed795b (diff) |
Fix === operator for value types
Fix === comparison for urls and other QML value types.
Task-number: QTBUG-33546
Change-Id: I4a7066e6bbc7de7c599fe2c7b2fdfb75e0ff5196
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/misctypetest.qml | 28 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 24 |
4 files changed, 69 insertions, 1 deletions
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 2b8da26dc9..e73edc812a 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -2206,7 +2206,7 @@ void tst_QJSValue::strictlyEquals() { QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); QJSValue var2 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QVERIFY(!var1.strictlyEquals(var2)); + QVERIFY(var1.strictlyEquals(var2)); } { QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); diff --git a/tests/auto/qml/qqmlecmascript/data/misctypetest.qml b/tests/auto/qml/qqmlecmascript/data/misctypetest.qml new file mode 100644 index 0000000000..60ff53a2b4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/misctypetest.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + MiscTypeTest { + id: mtt + } + + function test_invalid_url_equal() + { + return mtt.invalidUrl() == mtt.invalidUrl(); + } + + function test_invalid_url_refequal() + { + return mtt.invalidUrl() === mtt.invalidUrl(); + } + + function test_valid_url_equal() + { + return mtt.validUrl() == mtt.validUrl(); + } + + function test_valid_url_refequal() + { + return mtt.validUrl() === mtt.validUrl(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 053281f230..41fa3672bd 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -235,6 +235,21 @@ public: } }; +class MiscTypeTestClass : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE QUrl invalidUrl() + { + return QUrl(); + } + + Q_INVOKABLE QUrl validUrl() + { + return QUrl("http://wwww.qt-project.org"); + } +}; + class MyStringClass : public QObject { Q_OBJECT @@ -353,6 +368,7 @@ void registerTypes() qmlRegisterType<MyDateClass>("Qt.test", 1, 0, "MyDateClass"); qmlRegisterType<MyStringClass>("Qt.test", 1, 0, "MyStringClass"); + qmlRegisterType<MiscTypeTestClass>("Qt.test", 1, 0, "MiscTypeTest"); qmlRegisterSingletonType<testImportOrderApi>("Qt.test.importOrderApi",1,0,"Data",testImportOrder_api); qmlRegisterSingletonType<testImportOrderApi>("NamespaceAndType",1,0,"NamespaceAndType",testImportOrder_api); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 36ccbe0558..0f6d0b035d 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -312,6 +312,7 @@ private slots: void qtbug_34493(); void singletonFromQMLToCpp(); void setPropertyOnInvalid(); + void miscTypeTest(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -7383,6 +7384,29 @@ void tst_qqmlecmascript::setPropertyOnInvalid() } } +void tst_qqmlecmascript::miscTypeTest() +{ + QQmlComponent component(&engine, testFileUrl("misctypetest.qml")); + + QObject *object = component.create(); + if (object == 0) + qDebug() << component.errorString(); + QVERIFY(object != 0); + + QVariant q; + QMetaObject::invokeMethod(object, "test_invalid_url_equal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + QMetaObject::invokeMethod(object, "test_invalid_url_strictequal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + QMetaObject::invokeMethod(object, "test_valid_url_equal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + QMetaObject::invokeMethod(object, "test_valid_url_strictequal", Q_RETURN_ARG(QVariant, q)); + QVERIFY(q.toBool() == true); + + delete object; + +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |