diff options
Diffstat (limited to 'tests/auto/qml')
58 files changed, 778 insertions, 32 deletions
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro index 0d11213cb4..81fe3d5943 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -12,4 +12,4 @@ include (../../../shared/util.pri) CONFIG += parallel_test declarative_debug -QT += qml-private testlib +QT += core-private v8-private qml-private testlib diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp index a2cac08a21..c5992a4403 100644 --- a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp +++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -91,6 +91,7 @@ public: QList<QByteArray> snapshotMessages; signals: + void started(); void complete(); void snapshot(); @@ -158,6 +159,9 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message) case QV8ProfilerService::V8SnapshotComplete: emit snapshot(); break; + case QV8ProfilerService::V8Started: + emit started(); + break; default: QString failMessage = QString("Unknown message type: %1").arg(messageType); QFAIL(qPrintable(failMessage)); @@ -208,6 +212,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -225,6 +231,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled() QFAIL(qPrintable(failMsg)); } m_client->startProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -236,6 +244,8 @@ void tst_QV8ProfilerService::nonBlockingConnect() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -257,6 +267,8 @@ void tst_QV8ProfilerService::profileOnExit() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -270,6 +282,8 @@ void tst_QV8ProfilerService::console() m_client->stopProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); QVERIFY(!m_client->traceMessages.isEmpty()); diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 7a62a71df1..bcfbcbdbf0 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -19,6 +19,7 @@ PUBLICTESTS += \ qqmlinfo \ qqmllistreference \ qqmllocale \ + qqmlmetaobject \ qqmlmoduleplugin \ qqmlqt \ qqmltranslation \ diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index 2d764317c5..dfc88fb78c 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -96,10 +96,11 @@ void tst_qmlmin::initTestCase() // Add invalid files (i.e. files with syntax errors) invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/property.4.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/empty.qml"; - invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/missingObject.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml"; diff --git a/tests/auto/qml/qqmlcomponent/data/createParentReference.qml b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml new file mode 100644 index 0000000000..daa5d3c167 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: root + width: 100 + height: 100 + + function createChild() { + Qt.createQmlObject("import QtQuick 2.0;" + + "Item { width: parent.width; }", root); + } +} diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index d277952f22..603c091a03 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -71,6 +71,7 @@ private slots: void qmlCreateObject(); void qmlCreateObjectWithProperties(); void qmlIncubateObject(); + void qmlCreateParentReference(); private: QQmlEngine engine; @@ -181,6 +182,37 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties() delete testBindingThisObj; } +static QStringList warnings; +static void msgHandler(QtMsgType, const char *warning) +{ + warnings << QString::fromUtf8(warning); +} + +void tst_qqmlcomponent::qmlCreateParentReference() +{ + QQmlEngine engine; + + QCOMPARE(engine.outputWarningsToStandardError(), true); + + warnings.clear(); + QtMsgHandler old = qInstallMsgHandler(msgHandler); + + QQmlComponent component(&engine, testFileUrl("createParentReference.qml")); + QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(QMetaObject::invokeMethod(object, "createChild")); + delete object; + + qInstallMsgHandler(old); + + engine.setOutputWarningsToStandardError(false); + QCOMPARE(engine.outputWarningsToStandardError(), false); + + QCOMPARE(warnings.count(), 0); +} + QTEST_MAIN(tst_qqmlcomponent) #include "tst_qqmlcomponent.moc" diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js new file mode 100644 index 0000000000..7a4f434665 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js @@ -0,0 +1,5 @@ +.import Qt.test 1.0 as QObjectModuleApi + +function testFunc() { + return QObjectModuleApi.qobjectTestProperty +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml new file mode 100644 index 0000000000..b3e545dd7c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import "importModuleApi.js" as Script + +Item { + property variant testValue: 5 + + Component.onCompleted: { + testValue = Script.testFunc(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml new file mode 100644 index 0000000000..f84ba8c722 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Rectangle { + id: root + + Component.onCompleted: { + var o = Qt.createQmlObject("import QtQuick 2.0; \ + \ + Item { \ + property bool b: true; \ + }", root, "Instance") + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml new file mode 100644 index 0000000000..690b7cf216 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + onUnnamedArgumentSignal: setString('pass ' + a + ' ' + c) +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml new file mode 100644 index 0000000000..0e1e728a86 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + + +MyQmlObject { + onSignalWithGlobalName: setString('pass ' + parseInt("5")) +} diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 154e6f019c..1d68e8ae13 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -180,6 +180,7 @@ public: signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e); + void unnamedArgumentSignal(int a, qreal, QString c); void stringChanged(); void urlChanged(); void objectChanged(); @@ -188,6 +189,7 @@ signals: void signalWithUnknownType(const MyQmlObject::MyType &arg); void signalWithVariant(const QVariant &arg); void signalWithQJSValue(const QJSValue &arg); + void signalWithGlobalName(int parseInt); void intChanged(); public slots: diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index af219c8826..676557a81c 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -376,6 +376,27 @@ void tst_qqmlecmascript::signalAssignment() QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2")); delete object; } + + { + QQmlComponent component(&engine, testFileUrl("signalAssignment.3.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->unnamedArgumentSignal(19, 10.25, "Hello world!"); + QEXPECT_FAIL("", "QTBUG-24481", Continue); + QCOMPARE(object->string(), QString("pass 19 Hello world!")); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("signalAssignment.4.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->signalWithGlobalName(19); + QCOMPARE(object->string(), QString("pass 5")); + delete object; + } } void tst_qqmlecmascript::methods() @@ -1570,8 +1591,6 @@ void tst_qqmlecmascript::compileInvalidBinding() { // QTBUG-23387: ensure that invalid bindings don't cause a crash. QQmlComponent component(&engine, testFileUrl("v8bindingException.qml")); - QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL"; - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); QVERIFY(object != 0); delete object; @@ -3248,6 +3267,13 @@ void tst_qqmlecmascript::importScripts_data() << QStringList() << (QStringList() << QLatin1String("testValue")) << (QVariantList() << QVariant(18)); + + QTest::newRow("import module api into js import") + << testFileUrl("jsimport/testImportModuleApi.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("testValue")) + << (QVariantList() << QVariant(20)); } void tst_qqmlecmascript::importScripts() @@ -5287,12 +5313,21 @@ void tst_qqmlecmascript::qtbug_21864() void tst_qqmlecmascript::rewriteMultiLineStrings() { - // QTBUG-23387 - QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - QTRY_COMPARE(o->property("test").toBool(), true); - delete o; + { + // QTBUG-23387 + QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QTRY_COMPARE(o->property("test").toBool(), true); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings_crlf.1.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; + } } void tst_qqmlecmascript::qobjectConnectionListExceptionHandling() diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index 07b89af0a3..d076f038d3 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -499,9 +499,9 @@ void tst_qqmlinstruction::dump() << "24\t\tSTORE_OBJECT\t\t21" << "25\t\tSTORE_VARIANT_OBJECT\t22" << "26\t\tSTORE_INTERFACE\t\t23" - << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\"" + << "27\t\tSTORE_SIGNAL\t\t2\t3" << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4" - << "29\t\tASSIGN_SIGNAL_OBJECT\t4\t\t\t\"mySignal\"" + << "29\t\tASSIGN_SIGNAL_OBJECT\t4" << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9" << "31\t\tSTORE_BINDING\t26\t3\t2" << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4" diff --git a/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt new file mode 100644 index 0000000000..cf772e881e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt @@ -0,0 +1 @@ +4:27:Expected token `identifier' diff --git a/tests/auto/qml/qqmllanguage/data/signal.5.qml b/tests/auto/qml/qqmllanguage/data/signal.5.qml new file mode 100644 index 0000000000..63921cb2ca --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.5.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + signal mySignal(string) +} + diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index e9898bd039..e7294f090c 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -67,7 +67,8 @@ public: }; QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface"); +#define MyInterface_iid "org.qt-project.Qt.Test.MyInterface" +Q_DECLARE_INTERFACE(MyInterface, MyInterface_iid); QT_END_NAMESPACE QML_DECLARE_INTERFACE(MyInterface); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 379c32d4b8..266cd2a52d 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -354,6 +354,7 @@ void tst_qqmllanguage::errors_data() QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false; QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false; QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false; + QTest::newRow("signal.5") << "signal.5.qml" << "signal.5.errors.txt" << false; QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false; diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index af1a81847b..46435fb8fc 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -68,6 +68,8 @@ private slots: void dayName(); void standaloneDayName_data(); void standaloneDayName(); + void firstDayOfWeek_data(); + void firstDayOfWeek(); void weekDays_data(); void weekDays(); void uiLanguages_data(); @@ -154,7 +156,6 @@ void tst_qqmllocale::addPropertyData(const QString &l) LOCALE_PROP(QString,negativeSign), LOCALE_PROP(QString,positiveSign), LOCALE_PROP(QString,exponential), - LOCALE_PROP(int,firstDayOfWeek), LOCALE_PROP(int,measurementSystem), LOCALE_PROP(int,textDirection), { 0, QVariant() } @@ -426,6 +427,41 @@ void tst_qqmllocale::standaloneDayName() delete obj; } +void tst_qqmllocale::firstDayOfWeek_data() +{ + QTest::addColumn<QString>("locale"); + + QTest::newRow("en_US") << "en_US"; + QTest::newRow("de_DE") << "de_DE"; + QTest::newRow("ar_SA") << "ar_SA"; + QTest::newRow("hi_IN") << "hi_IN"; + QTest::newRow("zh_CN") << "zh_CN"; + QTest::newRow("th_TH") << "th_TH"; +} + +void tst_qqmllocale::firstDayOfWeek() +{ + QFETCH(QString, locale); + + QQmlComponent c(&engine, testFileUrl("properties.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val = obj->property("firstDayOfWeek"); + QVERIFY(val.type() == QVariant::Int); + + int day = int(QLocale(locale).firstDayOfWeek()); + if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) + day = 0; + QCOMPARE(day, val.toInt()); + + delete obj; +} + void tst_qqmllocale::weekDays_data() { QTest::addColumn<QString>("locale"); diff --git a/tests/auto/qml/qqmlmetaobject/data/method.1.qml b/tests/auto/qml/qqmlmetaobject/data/method.1.qml new file mode 100644 index 0000000000..a021881743 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/method.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction() { return 19; } +} diff --git a/tests/auto/qml/qqmlmetaobject/data/method.2.qml b/tests/auto/qml/qqmlmetaobject/data/method.2.qml new file mode 100644 index 0000000000..d514955f47 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/method.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction(foo) { return 19; } +} diff --git a/tests/auto/qml/qqmlmetaobject/data/method.3.qml b/tests/auto/qml/qqmlmetaobject/data/method.3.qml new file mode 100644 index 0000000000..d6d19758c9 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/method.3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction(foo, bar, baz) { return 19; } +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml new file mode 100644 index 0000000000..8903bbb3e9 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + property MyQmlObject test: MyQmlObject {} +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml new file mode 100644 index 0000000000..20c42b5851 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property QtObject test: QtObject {} +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml new file mode 100644 index 0000000000..cae1ae6696 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + id: me + property alias test: me +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml new file mode 100644 index 0000000000..86422ae367 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Text { + id: me + font.family: "Arial" + property alias test: me.font.family +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.alias.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.qml new file mode 100644 index 0000000000..33a4a1c5b0 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + objectName: "Joe" + id: me + property alias test: me.objectName +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.bool.qml b/tests/auto/qml/qqmlmetaobject/data/property.bool.qml new file mode 100644 index 0000000000..9459cb6394 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.bool.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property bool test: true +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.color.qml b/tests/auto/qml/qqmlmetaobject/data/property.color.qml new file mode 100644 index 0000000000..7451a27101 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.color.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property color test: "#ff0000" +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.date.qml b/tests/auto/qml/qqmlmetaobject/data/property.date.qml new file mode 100644 index 0000000000..05fcb2516c --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.date.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property date test: "2012-02-07" +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.int.qml b/tests/auto/qml/qqmlmetaobject/data/property.int.qml new file mode 100644 index 0000000000..ae419d08cb --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.int.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int test: 19 +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml new file mode 100644 index 0000000000..602762cba2 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + property list<MyQmlObject> test: [ MyQmlObject {} ] +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml new file mode 100644 index 0000000000..e774d70b42 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property list<QtObject> test: [ QtObject {} ] +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.real.qml b/tests/auto/qml/qqmlmetaobject/data/property.real.qml new file mode 100644 index 0000000000..de2baf5be2 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.real.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property real test: 21 +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.string.qml b/tests/auto/qml/qqmlmetaobject/data/property.string.qml new file mode 100644 index 0000000000..2a625c4fe4 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.string.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property string test: "dog" +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.url.qml b/tests/auto/qml/qqmlmetaobject/data/property.url.qml new file mode 100644 index 0000000000..c820c82515 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.url.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property url test: "http://foo.bar" +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.var.qml b/tests/auto/qml/qqmlmetaobject/data/property.var.qml new file mode 100644 index 0000000000..9ea9245317 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.var.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property var test: [5, true, "ciao"] +} diff --git a/tests/auto/qml/qqmlmetaobject/data/property.variant.qml b/tests/auto/qml/qqmlmetaobject/data/property.variant.qml new file mode 100644 index 0000000000..edffa173c4 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/property.variant.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property variant test: "12,34" +} diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.1.qml b/tests/auto/qml/qqmlmetaobject/data/signal.1.qml new file mode 100644 index 0000000000..113130f3cc --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/signal.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal +} diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.2.qml b/tests/auto/qml/qqmlmetaobject/data/signal.2.qml new file mode 100644 index 0000000000..db860cc7cd --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/signal.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(string foo) +} diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.3.qml b/tests/auto/qml/qqmlmetaobject/data/signal.3.qml new file mode 100644 index 0000000000..4d04041f8f --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/signal.3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(int foo, bool bar, real baz) +} diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.4.qml b/tests/auto/qml/qqmlmetaobject/data/signal.4.qml new file mode 100644 index 0000000000..ad9b002176 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/signal.4.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(variant foo, var bar) +} diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.5.qml b/tests/auto/qml/qqmlmetaobject/data/signal.5.qml new file mode 100644 index 0000000000..b848bb5cb5 --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/data/signal.5.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(color foo, date bar, url baz) +} diff --git a/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro b/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro new file mode 100644 index 0000000000..b87a7cd8bd --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qqmlmetaobject +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlmetaobject.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += qml testlib diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp new file mode 100644 index 0000000000..6cadc3524b --- /dev/null +++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlengine.h> +#include "../../shared/util.h" + +Q_DECLARE_METATYPE(QMetaMethod::MethodType) + +class MyQmlObject : public QObject +{ + Q_OBJECT +}; +QML_DECLARE_TYPE(MyQmlObject) + +class tst_QQmlMetaObject : public QQmlDataTest +{ + Q_OBJECT +private slots: + void initTestCase(); + + void property_data(); + void property(); + void method_data(); + void method(); + +private: + MyQmlObject myQmlObject; +}; + +void tst_QQmlMetaObject::initTestCase() +{ + QQmlDataTest::initTestCase(); + + qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); +} + +void tst_QQmlMetaObject::property_data() +{ + QTest::addColumn<QString>("testFile"); + QTest::addColumn<QByteArray>("cppTypeName"); + QTest::addColumn<int>("cppType"); + QTest::addColumn<bool>("isDefault"); + QTest::addColumn<QVariant>("expectedValue"); + QTest::addColumn<bool>("isWritable"); + QTest::addColumn<QVariant>("newValue"); + + QTest::newRow("int") << "property.int.qml" + << QByteArray("int") << int(QMetaType::Int) + << false // default + << QVariant(19) << true << QVariant(42); + QTest::newRow("bool") << "property.bool.qml" + << QByteArray("bool") << int(QMetaType::Bool) + << true // default + << QVariant(true) << true << QVariant(false); + QTest::newRow("real") << "property.real.qml" + << QByteArray("double") << int(QMetaType::Double) + << false // default + << QVariant(double(21)) + << true // writable + << QVariant(double(37)); + QTest::newRow("string") << "property.string.qml" + << QByteArray("QString") << int(QMetaType::QString) + << true // default + << QVariant(QString::fromLatin1("dog")) + << true // writable + << QVariant(QString::fromLatin1("food")); + QTest::newRow("url") << "property.url.qml" + << QByteArray("QUrl") << int(QMetaType::QUrl) + << false // default + << QVariant(QUrl("http://foo.bar")) + << true //writable + << QVariant(QUrl("http://bar.baz")); + QTest::newRow("color") << "property.color.qml" + << QByteArray("QColor") << int(QMetaType::QColor) + << true // default + << QVariant(QColor("#ff0000")) + << true // writable + << QVariant(QColor("#00ff00")); + QTest::newRow("date") << "property.date.qml" + << QByteArray("QDateTime") << int(QMetaType::QDateTime) + << false // default + << QVariant(QDateTime(QDate(2012, 2, 7))) + << true // writable + << QVariant(QDateTime(QDate(2010, 7, 2))); + QTest::newRow("variant") << "property.variant.qml" + << QByteArray("QVariant") << int(QMetaType::QVariant) + << true // default + << QVariant(QPointF(12, 34)) + << true // writable + << QVariant(QSizeF(45, 67)); + QTest::newRow("var") << "property.var.qml" + << QByteArray("QVariant") << int(QMetaType::QVariant) + << false // default + << QVariant(QVariantList() << 5 << true << "ciao") + << true // writable + << QVariant(QVariantList() << 17.0); + QTest::newRow("QtObject") << "property.QtObject.qml" + << QByteArray("QObject*") << int(QMetaType::QObjectStar) + << false // default + << QVariant() + << true // writable + << QVariant::fromValue(static_cast<QObject*>(this)); + QTest::newRow("list<QtObject>") << "property.list.QtObject.qml" + << QByteArray("QQmlListProperty<QObject>") + << qMetaTypeId<QQmlListProperty<QObject> >() + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("MyQmlObject") << "property.MyQmlObject.qml" + << QByteArray("MyQmlObject*") << qMetaTypeId<MyQmlObject*>() + << false // default + << QVariant() + << true // writable + << QVariant::fromValue(&myQmlObject); + QTest::newRow("list<MyQmlObject>") << "property.list.MyQmlObject.qml" + << QByteArray("QQmlListProperty<MyQmlObject>") + << qMetaTypeId<QQmlListProperty<MyQmlObject> >() + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("alias") << "property.alias.qml" + << QByteArray("QString") << int(QMetaType::QString) + << false // default + << QVariant(QString::fromLatin1("Joe")) + << true // writable + << QVariant(QString::fromLatin1("Bob")); + QTest::newRow("alias-2") << "property.alias.2.qml" + << QByteArray("QObject*") << int(QMetaType::QObjectStar) + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("alias-3") << "property.alias.3.qml" + << QByteArray("QString") << int(QMetaType::QString) + << false // default + << QVariant(QString::fromLatin1("Arial")) + << true // writable + << QVariant(QString::fromLatin1("Helvetica")); +} + +void tst_QQmlMetaObject::property() +{ + QFETCH(QString, testFile); + QFETCH(QByteArray, cppTypeName); + QFETCH(int, cppType); + QFETCH(bool, isDefault); + QFETCH(QVariant, expectedValue); + QFETCH(bool, isWritable); + QFETCH(QVariant, newValue); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl(testFile)); + QObject *object = component.create(); + QVERIFY(object != 0); + + const QMetaObject *mo = object->metaObject(); + QVERIFY(mo->superClass() != 0); + QVERIFY(QByteArray(mo->className()).contains("_QML_")); + QCOMPARE(mo->propertyOffset(), mo->superClass()->propertyCount()); + QCOMPARE(mo->propertyCount(), mo->superClass()->propertyCount() + 1); + + QMetaProperty prop = mo->property(mo->propertyOffset()); + QCOMPARE(prop.name(), "test"); + + QCOMPARE(QByteArray(prop.typeName()), cppTypeName); + QEXPECT_FAIL("QtObject", "prop.type() returns UserType for QtObject properties", Continue); + QEXPECT_FAIL("alias-2", "prop.type() returns UserType for QtObject properties", Continue); + if (prop.userType() < QMetaType::User) + QCOMPARE(prop.type(), QVariant::Type(cppType)); + QCOMPARE(prop.userType(), cppType); + + QVERIFY(!prop.isConstant()); + QVERIFY(!prop.isDesignable()); + QVERIFY(!prop.isEnumType()); + QVERIFY(!prop.isFinal()); + QVERIFY(!prop.isFlagType()); + QVERIFY(prop.isReadable()); + QVERIFY(!prop.isResettable()); + QVERIFY(prop.isScriptable()); + QVERIFY(!prop.isStored()); + QVERIFY(!prop.isUser()); + QVERIFY(prop.isValid()); + QCOMPARE(prop.isWritable(), isWritable); + + QCOMPARE(mo->classInfoOffset(), mo->superClass()->classInfoCount()); + QCOMPARE(mo->classInfoCount(), mo->superClass()->classInfoCount() + (isDefault ? 1 : 0)); + if (isDefault) { + QMetaClassInfo info = mo->classInfo(mo->classInfoOffset()); + QCOMPARE(info.name(), "DefaultProperty"); + QCOMPARE(info.value(), "test"); + } + + QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount()); + QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); // the signal + + QVERIFY(prop.notifySignalIndex() != -1); + QMetaMethod signal = prop.notifySignal(); + QCOMPARE(signal.methodType(), QMetaMethod::Signal); + QCOMPARE(signal.signature(), "testChanged()"); + QCOMPARE(signal.access(), QMetaMethod::Protected); + QCOMPARE(signal.parameterTypes(), QList<QByteArray>()); + QCOMPARE(signal.parameterNames(), QList<QByteArray>()); + QCOMPARE(signal.tag(), ""); + QCOMPARE(signal.typeName(), ""); + + QSignalSpy changedSpy(object, SIGNAL(testChanged())); + QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater())); + + if (expectedValue.isValid()) + QCOMPARE(prop.read(object), expectedValue); + else + QVERIFY(prop.read(object).isValid()); + QCOMPARE(changedSpy.count(), 0); + + if (isWritable) { + QVERIFY(prop.write(object, newValue)); + QCOMPARE(changedSpy.count(), 1); + QCOMPARE(prop.read(object), newValue); + } else { + QVERIFY(!prop.write(object, prop.read(object))); + QCOMPARE(changedSpy.count(), 0); + } + + delete object; +} + +void tst_QQmlMetaObject::method_data() +{ + QTest::addColumn<QString>("testFile"); + QTest::addColumn<QString>("signature"); + QTest::addColumn<QMetaMethod::MethodType>("methodType"); + QTest::addColumn<QString>("returnTypeName"); + QTest::addColumn<QList<QByteArray> >("parameterTypeNames"); + QTest::addColumn<QList<QByteArray> >("parameterNames"); + + QTest::newRow("testFunction()") << "method.1.qml" + << "testFunction()" + << QMetaMethod::Slot + << "QVariant" + << QList<QByteArray>() + << QList<QByteArray>(); + QTest::newRow("testFunction(foo)") << "method.2.qml" + << "testFunction(QVariant)" + << QMetaMethod::Slot + << "QVariant" + << (QList<QByteArray>() << "QVariant") + << (QList<QByteArray>() << "foo"); + QTest::newRow("testFunction(foo, bar, baz)") << "method.3.qml" + << "testFunction(QVariant,QVariant,QVariant)" + << QMetaMethod::Slot + << "QVariant" + << (QList<QByteArray>() << "QVariant" << "QVariant" << "QVariant") + << (QList<QByteArray>() << "foo" << "bar" << "baz"); + QTest::newRow("testSignal") << "signal.1.qml" + << "testSignal()" + << QMetaMethod::Signal + << "" + << QList<QByteArray>() + << QList<QByteArray>(); + QTest::newRow("testSignal(string foo)") << "signal.2.qml" + << "testSignal(QString)" + << QMetaMethod::Signal + << "" + << (QList<QByteArray>() << "QString") + << (QList<QByteArray>() << "foo"); + QTest::newRow("testSignal(int foo, bool bar, real baz)") << "signal.3.qml" + << "testSignal(int,bool,qreal)" + << QMetaMethod::Signal + << "" + << (QList<QByteArray>() << "int" << "bool" << "qreal") + << (QList<QByteArray>() << "foo" << "bar" << "baz"); + QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml" + << "testSignal(QVariant,QVariant)" + << QMetaMethod::Signal + << "" + << (QList<QByteArray>() << "QVariant" << "QVariant") + << (QList<QByteArray>() << "foo" << "bar"); + QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml" + << "testSignal(QColor,QDateTime,QUrl)" + << QMetaMethod::Signal + << "" + << (QList<QByteArray>() << "QColor" << "QDateTime" << "QUrl") + << (QList<QByteArray>() << "foo" << "bar" << "baz"); +} + +void tst_QQmlMetaObject::method() +{ + QFETCH(QString, testFile); + QFETCH(QString, signature); + QFETCH(QMetaMethod::MethodType, methodType); + QFETCH(QString, returnTypeName); + QFETCH(QList<QByteArray>, parameterTypeNames); + QFETCH(QList<QByteArray>, parameterNames); + + QCOMPARE(parameterTypeNames.size(), parameterNames.size()); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl(testFile)); + QObject *object = component.create(); + QVERIFY(object != 0); + + const QMetaObject *mo = object->metaObject(); + QVERIFY(mo->superClass() != 0); + QVERIFY(QByteArray(mo->className()).contains("_QML_")); + QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount()); + QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); + + QMetaMethod method = mo->method(mo->methodOffset()); + QCOMPARE(method.methodType(), methodType); + QCOMPARE(QString::fromUtf8(method.signature()), signature); + QCOMPARE(method.access(), QMetaMethod::Protected); + QCOMPARE(method.parameterTypes(), parameterTypeNames); + QCOMPARE(method.parameterNames(), parameterNames); + QCOMPARE(method.tag(), ""); + QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName); + + delete object; +} + +QTEST_MAIN(tst_QQmlMetaObject) + +#include "tst_qqmlmetaobject.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/empty.json b/tests/auto/qml/qqmlmoduleplugin/empty.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/empty.json @@ -0,0 +1 @@ +{} diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp index 53696b3598..03065b2f27 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp @@ -66,6 +66,8 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -80,5 +82,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp index f62b8addd4..e2ff43dffe 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp @@ -66,6 +66,8 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -80,5 +82,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp index 470aa7a37c..5a91852d22 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp @@ -65,6 +65,8 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -79,5 +81,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp index eec8e3f3af..66c59fde81 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp @@ -56,6 +56,8 @@ public: class MyMixedPlugin : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + public: MyMixedPlugin() { @@ -69,5 +71,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp index 8645028317..a3142ef9b3 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp @@ -56,6 +56,8 @@ public: class MyMixedPlugin : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + public: MyMixedPlugin() { @@ -69,5 +71,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp index 1217df4d0e..a2262f15d6 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp @@ -46,6 +46,8 @@ class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + public: void registerTypes(const char *uri) { @@ -54,5 +56,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp index e0257fe249..a5fc6c1d37 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp @@ -65,6 +65,8 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -79,5 +81,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml b/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml new file mode 100644 index 0000000000..0ffa5eb666 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + property variant somepoint: Qt.point(1,2) + property variant randomjsobj: {"some": 1, "thing": 2} + property bool test1: somepoint != randomjsobj + + property variant similar: {"x":1, "y":2} + property bool test2: somepoint != similar +} diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 695dbe4147..0aa223e733 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -93,6 +93,7 @@ private slots: void returnValues(); void varAssignment(); void bindingsSpliceCorrectly(); + void nonValueTypeComparison(); private: QQmlEngine engine; @@ -950,7 +951,6 @@ void tst_qqmlvaluetypes::autoBindingRemoval() delete object; } - /* { QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -975,6 +975,8 @@ void tst_qqmlvaluetypes::autoBindingRemoval() { QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml")); + QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QRect"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); @@ -992,7 +994,6 @@ void tst_qqmlvaluetypes::autoBindingRemoval() delete object; } -*/ } // Test that property value sources assign to value types @@ -1301,6 +1302,18 @@ void tst_qqmlvaluetypes::bindingsSpliceCorrectly() } } +void tst_qqmlvaluetypes::nonValueTypeComparison() +{ + QQmlComponent component(&engine, testFileUrl("nonValueTypeComparison.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + + delete object; +} + QTEST_MAIN(tst_qqmlvaluetypes) #include "tst_qqmlvaluetypes.moc" diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index a6d90cf688..3761929362 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -170,8 +170,8 @@ void tst_qquickfolderlistmodel::refresh() flm->setProperty("sortReversed", true); - QCOMPARE(removeStart, 0); - QCOMPARE(removeEnd, count-1); + QTRY_COMPARE(removeStart, 0); + QTRY_COMPARE(removeEnd, count-1); // wait for refresh } QTEST_MAIN(tst_qquickfolderlistmodel) diff --git a/tests/auto/qml/v4/data/colorType.qml b/tests/auto/qml/v4/data/colorType.qml new file mode 100644 index 0000000000..f6a98a4a3e --- /dev/null +++ b/tests/auto/qml/v4/data/colorType.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +QtObject { + property bool useMyColor: true + property color myColor: "red" + property color myOtherColor: "green" + + property color test1: useMyColor ? myColor : myOtherColor + property color test2: useMyColor ? "red" : "green" + property color test3: useMyColor ? myColor : "green" + + property bool test4: !myColor ? false : true + + property bool test5: myColor != "red" + property bool test6: myColor == "#ff0000" + property bool test7: myColor != "#00ff00" +} + diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp index 559abf7388..4e3e71f717 100644 --- a/tests/auto/qml/v4/tst_v4.cpp +++ b/tests/auto/qml/v4/tst_v4.cpp @@ -45,6 +45,7 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtCore/qdebug.h> +#include <QtGui/qcolor.h> #include <private/qv4compiler_p.h> @@ -73,6 +74,7 @@ private slots: void stringComparison(); void unaryMinus(); void unaryPlus(); + void colorType(); private: QQmlEngine engine; @@ -348,6 +350,22 @@ void tst_v4::unaryPlus() delete o; } +void tst_v4::colorType() +{ + QQmlComponent component(&engine, testFileUrl("colorType.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").value<QColor>(), QColor("red")); + QCOMPARE(o->property("test2").value<QColor>(), QColor("red")); + QCOMPARE(o->property("test3").value<QColor>(), QColor("red")); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + delete o; +} + QTEST_MAIN(tst_v4) #include "tst_v4.moc" |