diff options
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 77 | ||||
-rw-r--r-- | src/testlib/qtestlightxmlstreamer.cpp | 3 | ||||
-rw-r--r-- | src/testlib/qtestlogger.cpp | 3 | ||||
-rw-r--r-- | src/testlib/qtestxmlstreamer.cpp | 3 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/data/createComponent.qml | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml | 25 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/data/hsla.qml | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/data/rgba.qml | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 95 |
9 files changed, 129 insertions, 94 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 96145fb..8e19240 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -957,7 +957,7 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS Q_ASSERT(context); if(ctxt->argumentCount() != 1) { - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter")); }else{ QString arg = ctxt->argument(0).toString(); if (arg.isEmpty()) @@ -977,7 +977,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS QDeclarativeEngine* activeEngine = activeEnginePriv->q_func(); if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 or 3 parameters")); QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt); Q_ASSERT(context); @@ -997,35 +997,30 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1)); if(!parentArg) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("parent object not found")); QDeclarativeComponent component(activeEngine); component.setData(qml.toUtf8(), url); if(component.isError()) { QList<QDeclarativeError> errors = component.errors(); - qWarning().nospace() << "QDeclarativeEngine::createQmlObject():"; + QString errstr = QLatin1String("Qt.createQmlObject(): "); foreach (const QDeclarativeError &error, errors) - qWarning().nospace() << " " << error; - - return engine->nullValue(); + errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n"); + return ctxt->throwError(errstr); } - if (!component.isReady()) { - qWarning().nospace() << "QDeclarativeEngine::createQmlObject(): Component is not ready"; - - return engine->nullValue(); - } + if (!component.isReady()) + return ctxt->throwError(QDeclarativeEngine::tr("Qt.createQmlObject(): component is not ready")); QObject *obj = component.create(context->asQDeclarativeContext()); if(component.isError()) { QList<QDeclarativeError> errors = component.errors(); - qWarning().nospace() << "QDeclarativeEngine::createQmlObject():"; + QString errstr = QLatin1String("Qt.createQmlObject(): "); foreach (const QDeclarativeError &error, errors) - qWarning().nospace() << " " << error; - - return engine->nullValue(); + errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n"); + return ctxt->throwError(errstr); } Q_ASSERT(obj); @@ -1051,7 +1046,7 @@ QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScript QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 3) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 3 parameters")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); qsreal z = ctxt->argument(2).toNumber(); @@ -1062,7 +1057,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters")); QDate date = ctxt->argument(0).toDateTime().date(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1073,7 +1068,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("invalid date format")); } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } @@ -1082,7 +1077,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters")); QTime date = ctxt->argument(0).toDateTime().time(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1093,7 +1088,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("invalid time format")); } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } @@ -1102,7 +1097,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters")); QDateTime date = ctxt->argument(0).toDateTime(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1113,7 +1108,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("invalid datetiem format")); } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } @@ -1122,14 +1117,20 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine { int argCount = ctxt->argumentCount(); if(argCount < 3 || argCount > 4) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 3 or 4 parameters")); qsreal r = ctxt->argument(0).toNumber(); qsreal g = ctxt->argument(1).toNumber(); qsreal b = ctxt->argument(2).toNumber(); qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1; - if (r < 0 || r > 1 || g < 0 || g > 1 || b < 0 || b > 1 || a < 0 || a > 1) - return engine->nullValue(); + if (r < 0.0) r=0.0; + if (r > 1.0) r=1.0; + if (g < 0.0) g=0.0; + if (g > 1.0) g=1.0; + if (b < 0.0) b=0.0; + if (b > 1.0) b=1.0; + if (a < 0.0) a=0.0; + if (a > 1.0) a=1.0; return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a))); } @@ -1138,14 +1139,20 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine { int argCount = ctxt->argumentCount(); if(argCount < 3 || argCount > 4) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 3 or 4 parameters")); qsreal h = ctxt->argument(0).toNumber(); qsreal s = ctxt->argument(1).toNumber(); qsreal l = ctxt->argument(2).toNumber(); qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1; - if (h < 0 || h > 1 || s < 0 || s > 1 || l < 0 || l > 1 || a < 0 || a > 1) - return engine->nullValue(); + if (h < 0.0) h=0.0; + if (h > 1.0) h=1.0; + if (s < 0.0) s=0.0; + if (s > 1.0) s=1.0; + if (l < 0.0) l=0.0; + if (l > 1.0) l=1.0; + if (a < 0.0) a=0.0; + if (a > 1.0) a=1.0; return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a))); } @@ -1153,7 +1160,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 4) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 4 parameters")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); @@ -1169,7 +1176,7 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); return qScriptValueFromValue(engine, qVariantFromValue(QPointF(x, y))); @@ -1178,7 +1185,7 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters")); qsreal w = ctxt->argument(0).toNumber(); qsreal h = ctxt->argument(1).toNumber(); return qScriptValueFromValue(engine, qVariantFromValue(QSizeF(w, h))); @@ -1187,7 +1194,7 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 1) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter")); QVariant v = ctxt->argument(0).toVariant(); QColor color; if (v.userType() == QVariant::Color) @@ -1206,7 +1213,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 1) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter")); QVariant v = ctxt->argument(0).toVariant(); QColor color; if (v.userType() == QVariant::Color) @@ -1300,7 +1307,7 @@ QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptE QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters")); //get color QVariant v = ctxt->argument(0).toVariant(); QColor color; diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index 0ac9ea8..8c22a4f 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -87,12 +87,13 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBu QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n", + QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <DataTag>%s</DataTag><Description><![CDATA[%s]]></Description>\n</Message>\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), + element->attributeValue(QTest::AI_Tag) ? element->attributeValue(QTest::AI_Tag) : "", cdataDesc.constData()); break; } diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index 6c76388..79bb84c 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -318,6 +318,9 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char break; } + const char *tag = QTestResult::currentDataTag(); + if (tag) + errorElement->addAttribute(QTest::AI_Tag, tag); errorElement->addAttribute(QTest::AI_Type, typeBuf); errorElement->addAttribute(QTest::AI_Description, message); diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index b9946e5..9addb31 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -111,12 +111,13 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n", + QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <DataTag>%s</DataTag>\n <Description><![CDATA[%s]]></Description>\n</Message>\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), + element->attributeValue(QTest::AI_Tag) ? element->attributeValue(QTest::AI_Tag) : "", cdataDesc.constData()); break; } diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml index d9b70ec..412c467 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml @@ -1,19 +1,16 @@ import Qt 4.6 QtObject { - property bool incorrectArgCount1: false - property bool incorrectArgCount2: false property bool emptyArg: false property string relativeUrl property string absoluteUrl + property QtObject incorectArgCount1: createComponent() + property QtObject incorectArgCount2: createComponent("main.qml", 10) + Component.onCompleted: { - // Test that using incorrect argument count returns a null object - incorrectArgCount1 = (createComponent() == null); - incorrectArgCount2 = (createComponent("main.qml", 10) == null); emptyArg = (createComponent("") == null); - var r = createComponent("createComponentData.qml"); relativeUrl = r.url; diff --git a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml index 54a3e7d..a7edb2b 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml @@ -3,25 +3,26 @@ import Qt 4.6 Item { id: root - property bool incorrectArgCount1: false - property bool incorrectArgCount2: false + // errors resulting in exceptions + property QtObject incorrectArgCount1: createQmlObject() + property QtObject incorrectArgCount2: createQmlObject("import Qt 4.6\nQtObject{}", root, "main.qml", 10) + property QtObject noParent: createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13}", 0) + property QtObject notAvailable: createQmlObject("import Qt 4.6\nQtObject{Blah{}}", root) + property QtObject errors: createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") + property bool emptyArg: false - property bool noParent: false - property bool notAvailable: false property bool runtimeError: false - property bool errors: false property bool success: false Component.onCompleted: { - // errors - incorrectArgCount1 = (createQmlObject() == null); - incorrectArgCount2 = (createQmlObject("import Qt 4.6\nQtObject{}", root, "main.qml", 10) == null); + // errors resulting in nulls emptyArg = (createQmlObject("", root) == null); - errors = (createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") == null); - noParent = (createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13}", 0) == null); - notAvailable = (createQmlObject("import Qt 4.6\nQtObject{Blah{}}", root) == null); - runtimeError = (createQmlObject("import Qt 4.6\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root) == null); + try { + createQmlObject("import Qt 4.6\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root) + } catch (error) { + console.log("RunTimeError: ",error.message); + } var o = createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\n}", root); success = (o.test == 13); diff --git a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml index df51ccd..142410b 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml @@ -5,7 +5,7 @@ QtObject { property color test2: Qt.hsla(1, 0.5, 0.3); property color test3: Qt.hsla(1, 1); property color test4: Qt.hsla(1, 1, 1, 1, 1); - property color test5: Qt.hsla(1.2, 1, 1); - property color test6: Qt.hsla(-0.1, 1, 1); + property color test5: Qt.hsla(1.2, 1.3, 1.4, 1.5); + property color test6: Qt.hsla(-0.1, -0.2, -0.3, -0.4); } diff --git a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml index 6dd6565..66305a4 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml @@ -5,6 +5,6 @@ QtObject { property color test2: Qt.rgba(1, 0.5, 0.3); property color test3: Qt.rgba(1, 1); property color test4: Qt.rgba(1, 1, 1, 1, 1); - property color test5: Qt.rgba(1.2, 1, 1); - property color test6: Qt.rgba(-0.1, 1, 1); + property color test5: Qt.rgba(1.2, 1.3, 1.4, 1.5); + property color test6: Qt.rgba(-0.1, -0.2, -0.3, -0.4); } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 98f1200..4d22b0a 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -102,14 +102,10 @@ void tst_qdeclarativeqt::rgba() { QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml")); - QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor"; - QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor"; - QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor"; - QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor"; + QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); QObject *object = component.create(); QVERIFY(object != 0); @@ -119,8 +115,8 @@ void tst_qdeclarativeqt::rgba() QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1)); QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor()); - QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); - QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1)); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromRgbF(0, 0, 0, 0)); delete object; } @@ -129,14 +125,10 @@ void tst_qdeclarativeqt::hsla() { QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml")); - QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor"; - QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor"; - QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor"; - QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor"; + QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); QObject *object = component.create(); QVERIFY(object != 0); @@ -145,8 +137,8 @@ void tst_qdeclarativeqt::hsla() QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1)); QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor()); - QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); - QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHslF(1, 1, 1, 1)); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromHslF(0, 0, 0, 0)); delete object; } @@ -154,6 +146,12 @@ void tst_qdeclarativeqt::hsla() void tst_qdeclarativeqt::rect() { QDeclarativeComponent component(&engine, TEST_FILE("rect.qml")); + + QString warning1 = component.url().toString() + ":6: Error: expected 4 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 4 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -169,6 +167,12 @@ void tst_qdeclarativeqt::rect() void tst_qdeclarativeqt::point() { QDeclarativeComponent component(&engine, TEST_FILE("point.qml")); + + QString warning1 = component.url().toString() + ":6: Error: expected 2 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 2 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -183,6 +187,12 @@ void tst_qdeclarativeqt::point() void tst_qdeclarativeqt::size() { QDeclarativeComponent component(&engine, TEST_FILE("size.qml")); + + QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters"; + QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -198,6 +208,12 @@ void tst_qdeclarativeqt::size() void tst_qdeclarativeqt::vector() { QDeclarativeComponent component(&engine, TEST_FILE("vector.qml")); + + QString warning1 = component.url().toString() + ":6: Error: expected 3 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 3 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -212,6 +228,12 @@ void tst_qdeclarativeqt::vector() void tst_qdeclarativeqt::lighter() { QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml")); + + QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter"; + QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -228,6 +250,12 @@ void tst_qdeclarativeqt::lighter() void tst_qdeclarativeqt::darker() { QDeclarativeComponent component(&engine, TEST_FILE("darker.qml")); + + QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter"; + QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -245,8 +273,9 @@ void tst_qdeclarativeqt::tint() { QDeclarativeComponent component(&engine, TEST_FILE("tint.qml")); - QString warning1 = component.url().toString() + ":7: Unable to assign null to QColor"; - QString warning2 = component.url().toString() + ":8: Unable to assign null to QColor"; + QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters"; + QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -305,13 +334,15 @@ void tst_qdeclarativeqt::md5() void tst_qdeclarativeqt::createComponent() { QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml")); + + QString warning1 = component.url().toString() + ":9: Error: expected 1 parameter"; + QString warning2 = component.url().toString() + ":10: Error: expected 1 parameter"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(object->property("incorrectArgCount1").toBool(), true); - QCOMPARE(object->property("incorrectArgCount2").toBool(), true); - QCOMPARE(object->property("emptyArg").toBool(), true); - QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml")); QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString()); @@ -322,30 +353,24 @@ void tst_qdeclarativeqt::createQmlObject() { QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml")); - QString warning1 = "QDeclarativeEngine::createQmlObject():"; - QString warning2 = " " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name"; - QString warning3 = "QDeclarativeEngine::createQmlObject():"; - QString warning4 = " " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type"; - QString warning5 = "QDeclarativeEngine::createQmlObject():"; - QString warning6 = " " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method"; + QString warning1 = component.url().toString() + ":7: Error: expected 2 or 3 parameters"; + QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type\n"; + QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name\n"; + QString warning4 = component.url().toString()+ ":9: Error: parent object not found"; + QString warning5 = component.url().toString()+ ":8: Error: expected 2 or 3 parameters"; + QString warning6 = "RunTimeError: Qt.createQmlObject(): " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method\n"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning6)); + QTest::ignoreMessage(QtDebugMsg, qPrintable(warning6)); QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(object->property("incorrectArgCount1").toBool(), true); - QCOMPARE(object->property("incorrectArgCount2").toBool(), true); QCOMPARE(object->property("emptyArg").toBool(), true); - QCOMPARE(object->property("errors").toBool(), true); - QCOMPARE(object->property("noParent").toBool(), true); - QCOMPARE(object->property("notAvailable").toBool(), true); - QCOMPARE(object->property("runtimeError").toBool(), true); QCOMPARE(object->property("success").toBool(), true); QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(object); |