diff options
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlbundle/data/imports/bundletest/plugin1.pro | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmlbundle/tst_qqmlbundle.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 26 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 71 | ||||
-rw-r--r-- | tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 25 | ||||
-rw-r--r-- | tests/auto/qml/qqmlinstruction/qqmlinstruction.pro | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp | 32 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/literals.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/testtypes.h | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp | 17 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/tst_qqmlqt.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qml/v4/tst_v4.cpp | 40 |
16 files changed, 84 insertions, 177 deletions
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index 5848b42028..92f48f398f 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -85,7 +85,7 @@ private slots: void reloadQmlWindow(); }; -void tst_QQmlInspector::startQmlsceneProcess(const char *qmlFile) +void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */) { const QString argument = "-qmljsdebugger=port:" STR_PORT ",block"; diff --git a/tests/auto/qml/qqmlbundle/data/imports/bundletest/plugin1.pro b/tests/auto/qml/qqmlbundle/data/imports/bundletest/plugin1.pro index 2ffa05a007..934bb2d591 100644 --- a/tests/auto/qml/qqmlbundle/data/imports/bundletest/plugin1.pro +++ b/tests/auto/qml/qqmlbundle/data/imports/bundletest/plugin1.pro @@ -3,4 +3,5 @@ CONFIG += plugin SOURCES += plugin.cpp QT = core qml +DESTDIR = ./ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlbundle/tst_qqmlbundle.cpp b/tests/auto/qml/qqmlbundle/tst_qqmlbundle.cpp index 70cb319938..168e685699 100644 --- a/tests/auto/qml/qqmlbundle/tst_qqmlbundle.cpp +++ b/tests/auto/qml/qqmlbundle/tst_qqmlbundle.cpp @@ -201,7 +201,7 @@ void tst_qqmlbundle::import() engine.addImportPath(testFile("imports")); QQmlComponent component(&engine, testFileUrl("import.qml")); - QVERIFY(component.isReady()); + QVERIFY2(component.isReady(), QQmlDataTest::msgComponentError(component, &engine)); QObject *o = component.create(); QVERIFY(o != 0); diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index d3aba444af..748d4d71e8 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -226,20 +226,13 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties() delete testBindingThisObj; } -static QStringList warnings; -static void msgHandler(QtMsgType, const QMessageLogContext &, const QString &warning) -{ - warnings << warning; -} - void tst_qqmlcomponent::qmlCreateParentReference() { QQmlEngine engine; QCOMPARE(engine.outputWarningsToStandardError(), true); - warnings.clear(); - QtMessageHandler old = qInstallMessageHandler(msgHandler); + QQmlTestMessageHandler messageHandler; QQmlComponent component(&engine, testFileUrl("createParentReference.qml")); QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); @@ -249,12 +242,10 @@ void tst_qqmlcomponent::qmlCreateParentReference() QVERIFY(QMetaObject::invokeMethod(object, "createChild")); delete object; - qInstallMessageHandler(old); - engine.setOutputWarningsToStandardError(false); QCOMPARE(engine.outputWarningsToStandardError(), false); - QCOMPARE(warnings.count(), 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } void tst_qqmlcomponent::async() @@ -398,13 +389,14 @@ void tst_qqmlcomponent::onDestructionCount() // Warning should not be emitted any further QCOMPARE(engine.outputWarningsToStandardError(), true); - warnings.clear(); - QtMessageHandler old = qInstallMessageHandler(msgHandler); - - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); + QStringList warnings; + { + QQmlTestMessageHandler messageHandler; - qInstallMessageHandler(old); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + warnings = messageHandler.messages(); + } engine.setOutputWarningsToStandardError(false); QCOMPARE(engine.outputWarningsToStandardError(), false); diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index b9e31d2216..a7ef405aa3 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -231,7 +231,7 @@ class TestObject : public QObject Q_PROPERTY(bool ran READ ran WRITE setRan) public: - TestObject(QObject *parent = 0) : m_ran(false) {} + TestObject(QObject *parent = 0) : QObject(parent), m_ran(false) {} ~TestObject() {} bool ran() const { return m_ran; } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 1cf8e13c3c..9ecb3b6e1d 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1923,27 +1923,18 @@ void tst_qqmlecmascript::compileInvalidBinding() delete object; } -static int transientErrorsMsgCount = 0; -static void transientErrorsMsgHandler(QtMsgType, const QMessageLogContext &, const QString &) -{ - ++transientErrorsMsgCount; -} - // Check that transient binding errors are not displayed void tst_qqmlecmascript::transientErrors() { { QQmlComponent component(&engine, testFileUrl("transientErrors.qml")); - transientErrorsMsgCount = 0; - QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; QObject *object = component.create(); QVERIFY(object != 0); - qInstallMessageHandler(old); - - QCOMPARE(transientErrorsMsgCount, 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete object; } @@ -1952,15 +1943,12 @@ void tst_qqmlecmascript::transientErrors() { QQmlComponent component(&engine, testFileUrl("transientErrors.2.qml")); - transientErrorsMsgCount = 0; - QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; QObject *object = component.create(); QVERIFY(object != 0); - qInstallMessageHandler(old); - - QCOMPARE(transientErrorsMsgCount, 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete object; } @@ -1973,13 +1961,11 @@ void tst_qqmlecmascript::shutdownErrors() QObject *object = component.create(); QVERIFY(object != 0); - transientErrorsMsgCount = 0; - QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; delete object; - qInstallMessageHandler(old); - QCOMPARE(transientErrorsMsgCount, 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } void tst_qqmlecmascript::compositePropertyType() @@ -3801,6 +3787,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { v8::Persistent<v8::Context> context = v8::Context::New(); v8::Context::Scope context_scope(context); v8::Local<v8::Object> temporaryScope = engine->qmlScope(scriptContext, NULL); + Q_UNUSED(temporaryScope) context.Dispose(); } @@ -5793,14 +5780,11 @@ void tst_qqmlecmascript::qtbug_9792() delete context; - transientErrorsMsgCount = 0; - QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; object->basicSignal(); - - qInstallMessageHandler(old); - QCOMPARE(transientErrorsMsgCount, 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete object; } @@ -5834,14 +5818,11 @@ void tst_qqmlecmascript::noSpuriousWarningsAtShutdown() QObject *o = component.create(); - transientErrorsMsgCount = 0; - QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; delete o; - qInstallMessageHandler(old); - - QCOMPARE(transientErrorsMsgCount, 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } @@ -5850,14 +5831,11 @@ void tst_qqmlecmascript::noSpuriousWarningsAtShutdown() QObject *o = component.create(); - transientErrorsMsgCount = 0; - QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; delete o; - qInstallMessageHandler(old); - - QCOMPARE(transientErrorsMsgCount, 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } } @@ -6671,22 +6649,15 @@ void tst_qqmlecmascript::doubleEvaluate() delete object; } -static QStringList messages; -static void captureMsgHandler(QtMsgType, const QMessageLogContext &, const QString &msg) -{ - messages.append(msg); -} - void tst_qqmlecmascript::nonNotifyable() { QV4Compiler::enableV4(false); QQmlComponent component(&engine, testFileUrl("nonNotifyable.qml")); QV4Compiler::enableV4(true); - QtMessageHandler old = qInstallMessageHandler(captureMsgHandler); - messages.clear(); + QQmlTestMessageHandler messageHandler; + QObject *object = component.create(); - qInstallMessageHandler(old); QVERIFY(object != 0); @@ -6697,9 +6668,9 @@ void tst_qqmlecmascript::nonNotifyable() QLatin1String(object->metaObject()->className()) + QLatin1String("::value"); - QCOMPARE(messages.length(), 2); - QCOMPARE(messages.at(0), expected1); - QCOMPARE(messages.at(1), expected2); + QCOMPARE(messageHandler.messages().length(), 2); + QCOMPARE(messageHandler.messages().at(0), expected1); + QCOMPARE(messageHandler.messages().at(1), expected2); delete object; } @@ -7124,16 +7095,14 @@ void tst_qqmlecmascript::bindingSuppression() EventProcessor processor; engine.rootContext()->setContextProperty("pendingEvents", &processor); - transientErrorsMsgCount = 0; - QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; QQmlComponent c(&engine, testFileUrl("bindingSuppression.qml")); QObject *obj = c.create(); QVERIFY(obj != 0); delete obj; - qInstallMessageHandler(old); - QCOMPARE(transientErrorsMsgCount, 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } void tst_qqmlecmascript::signalEmitted() diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 128294bbcb..2a78831ba1 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -417,12 +417,6 @@ void tst_qqmlengine::failedCompilation_data() QTest::newRow("Invalid content") << "failedCompilation.1.qml"; } -static QStringList warnings; -static void msgHandler(QtMsgType, const QMessageLogContext &, const QString &warning) -{ - warnings << warning; -} - void tst_qqmlengine::outputWarningsToStandardError() { QQmlEngine engine; @@ -434,35 +428,26 @@ void tst_qqmlengine::outputWarningsToStandardError() QVERIFY(c.isReady() == true); - warnings.clear(); - QtMessageHandler old = qInstallMessageHandler(msgHandler); + QQmlTestMessageHandler messageHandler; QObject *o = c.create(); - qInstallMessageHandler(old); - QVERIFY(o != 0); delete o; - QCOMPARE(warnings.count(), 1); - QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>: Unable to assign [undefined] to int")); - warnings.clear(); - + QCOMPARE(messageHandler.messages().count(), 1); + QCOMPARE(messageHandler.messages().at(0), QLatin1String("<Unknown File>: Unable to assign [undefined] to int")); + messageHandler.clear(); engine.setOutputWarningsToStandardError(false); QCOMPARE(engine.outputWarningsToStandardError(), false); - - old = qInstallMessageHandler(msgHandler); - o = c.create(); - qInstallMessageHandler(old); - QVERIFY(o != 0); delete o; - QCOMPARE(warnings.count(), 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } void tst_qqmlengine::objectOwnership() diff --git a/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro index 1eb4a203a3..73f29ab973 100644 --- a/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro +++ b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro @@ -5,5 +5,7 @@ macx:CONFIG -= app_bundle CONFIG += parallel_test +include (../../shared/util.pri) + QT += core-private gui-private v8-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index 7d27751e77..e25c38d9cc 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include <qtest.h> +#include "../../shared/util.h" #include <private/qqmlcompiler_p.h> #include <QVector3D> @@ -65,12 +66,6 @@ private slots: void time(); }; -static QStringList messages; -static void msgHandler(QtMsgType, const QMessageLogContext &, const QString &msg) -{ - messages << msg; -} - void tst_qqmlinstruction::dump() { QQmlEngine engine; @@ -128,14 +123,14 @@ void tst_qqmlinstruction::dump() { QQmlCompiledData::Instruction::StoreFloat i; i.propertyIndex = 3; - i.value = 11.3; + i.value = 11.3f; data->addInstruction(i); } { QQmlCompiledData::Instruction::StoreDouble i; i.propertyIndex = 4; - i.value = 14.8; + i.value = 14.8f; data->addInstruction(i); } @@ -564,15 +559,14 @@ void tst_qqmlinstruction::dump() << "57\t\tSTORE_VAR_BOOL\t\t83\ttrue" << "-------------------------------------------------------------------------------"; - messages = QStringList(); - QtMessageHandler old = qInstallMessageHandler(msgHandler); + QQmlTestMessageHandler messageHandler; data->dumpInstructions(); - qInstallMessageHandler(old); - QCOMPARE(messages.count(), expect.count()); - for (int ii = 0; ii < messages.count(); ++ii) { - QCOMPARE(messages.at(ii), expect.at(ii)); + const int messageCount = messageHandler.messages().count(); + QCOMPARE(messageCount, expect.count()); + for (int ii = 0; ii < messageCount; ++ii) { + QCOMPARE(messageHandler.messages().at(ii), expect.at(ii)); } data->release(); @@ -676,8 +670,8 @@ void tst_qqmlinstruction::vector3d() QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector3D::QVector3D), Q_ALIGNOF(QVector3D)); QQmlInstruction i; - i.storeVector3D.vector.xp = 8.2; - i.storeVector3D.vector.yp = 99.3; + i.storeVector3D.vector.xp = 8.2f; + i.storeVector3D.vector.yp = 99.3f; i.storeVector3D.vector.zp = 12.0; const QVector3D &vector = (const QVector3D &)(i.storeVector3D.vector); @@ -692,10 +686,10 @@ void tst_qqmlinstruction::vector4d() QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector4D::QVector4D), Q_ALIGNOF(QVector4D)); QQmlInstruction i; - i.storeVector4D.vector.xp = 8.2; - i.storeVector4D.vector.yp = 99.3; + i.storeVector4D.vector.xp = 8.2f; + i.storeVector4D.vector.yp = 99.3f; i.storeVector4D.vector.zp = 12.0; - i.storeVector4D.vector.wp = 121.1; + i.storeVector4D.vector.wp = 121.1f; const QVector4D &vector = (const QVector4D &)(i.storeVector4D.vector); QCOMPARE(vector.x(), (qreal)(float)8.2); diff --git a/tests/auto/qml/qqmllanguage/data/literals.qml b/tests/auto/qml/qqmllanguage/data/literals.qml index 3a3e8461e4..ffef050438 100644 --- a/tests/auto/qml/qqmllanguage/data/literals.qml +++ b/tests/auto/qml/qqmllanguage/data/literals.qml @@ -18,7 +18,6 @@ QtObject { property variant c7: "\'" property variant c8: "\"" property variant c9: "\\" - property variant c10: "\251" - property variant c11: "\xA9" - property variant c12: "\u00A9" // unicode + property variant c10: "\xA9" + property variant c11: "\u00A9" // unicode } diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index bd6205cbdf..e83e9e11ac 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -939,7 +939,7 @@ class MyUncreateableBaseClass : public QObject Q_PROPERTY(bool prop2 READ prop2 WRITE setprop2 REVISION 1) Q_PROPERTY(bool prop3 READ prop3 WRITE setprop3 REVISION 1) public: - explicit MyUncreateableBaseClass(bool arg, QObject *parent = 0) + explicit MyUncreateableBaseClass(bool /* arg */, QObject *parent = 0) : QObject(parent), _prop1(false), _prop2(false), _prop3(false) { } diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 6b4830f11d..bd92c68f8e 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -596,8 +596,8 @@ void tst_qqmllanguage::assignBasicTypes() QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99)); QCOMPARE(object->boolProperty(), true); QCOMPARE(object->variantProperty(), QVariant("Hello World!")); - QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); - QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3)); + QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2f)); + QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2f, 2.3f)); QUrl encoded; encoded.setEncodedUrl("main.qml?with%3cencoded%3edata", QUrl::TolerantMode); QCOMPARE(object->urlProperty(), component.url().resolved(encoded)); @@ -2571,7 +2571,7 @@ void tst_qqmllanguage::importJs() QCOMPARE(expected.size(), actual.size()); for (int i = 0; i < expected.size(); ++i) { - size_t compareLen = std::min(expected.at(i).length(), actual.at(i).length()); + const int compareLen = qMin(expected.at(i).length(), actual.at(i).length()); QCOMPARE(expected.at(i).left(compareLen), actual.at(i).left(compareLen)); } } @@ -2948,13 +2948,12 @@ void tst_qqmllanguage::signalWithDefaultArg() QCOMPARE(object->property("signalCount").toInt(), 2); QCOMPARE(object->property("signalArg").toInt(), 15); - const QMetaObject *metaObject = object->metaObject(); - metaObject->invokeMethod(object, "emitNoArgSignal"); + QMetaObject::invokeMethod(object, "emitNoArgSignal"); QCOMPARE(object->property("signalCount").toInt(), 3); QCOMPARE(object->property("signalArg").toInt(), 5); - metaObject->invokeMethod(object, "emitArgSignal"); + QMetaObject::invokeMethod(object, "emitArgSignal"); QCOMPARE(object->property("signalCount").toInt(), 4); QCOMPARE(object->property("signalArg").toInt(), 22); @@ -3065,9 +3064,8 @@ void tst_qqmllanguage::literals_data() QTest::newRow("special8") << "c8" << QVariant(QString("\"")); QTest::newRow("special9") << "c9" << QVariant(QString("\\")); // We don't handle octal escape sequences -// QTest::newRow("special10") << "c10" << QVariant(QString("\251")); - QTest::newRow("special11") << "c11" << QVariant(QString::fromLatin1("\xa9")); - QTest::newRow("special12") << "c12" << QVariant(QString::fromUtf8("\u00A9")); + QTest::newRow("special11") << "c10" << QVariant(QString(1, QChar(0xa9))); + QTest::newRow("special12") << "c11" << QVariant(QString(1, QChar(0x00A9))); } void tst_qqmllanguage::literals() diff --git a/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro index bf22afa20c..81212bb064 100644 --- a/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro +++ b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro @@ -4,6 +4,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qqmlpropertymap.cpp +include (../../shared/util.pri) + CONFIG += parallel_test QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 99179f533b..af2a032a30 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <qtest.h> +#include "../../shared/util.h" #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcontext.h> #include <QtQml/qqmlpropertymap.h> @@ -294,19 +295,9 @@ public slots: void testSlot() {} }; -namespace -{ - QStringList messages; - void msgHandler(QtMsgType, const QMessageLogContext &, const QString &msg) - { - messages << msg; - } -} - void tst_QQmlPropertyMap::metaObjectAccessibility() { - messages.clear(); - QtMessageHandler old = qInstallMessageHandler(msgHandler); + QQmlTestMessageHandler messageHandler; QQmlEngine engine; @@ -318,9 +309,7 @@ void tst_QQmlPropertyMap::metaObjectAccessibility() QCOMPARE(map.metaObject()->className(), "MyEnhancedPropertyMap"); - qInstallMessageHandler(old); - - QCOMPARE(messages.count(), 0); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } QTEST_MAIN(tst_QQmlPropertyMap) diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index 22be661755..9a525df973 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -320,8 +320,8 @@ void tst_qqmlqt::vector2d() QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(qvariant_cast<QVector2D>(object->property("test1")), QVector2D(1, 0.9)); - QCOMPARE(qvariant_cast<QVector2D>(object->property("test2")), QVector2D(102, -982.1)); + QCOMPARE(qvariant_cast<QVector2D>(object->property("test1")), QVector2D(1, 0.9f)); + QCOMPARE(qvariant_cast<QVector2D>(object->property("test2")), QVector2D(102, -982.1f)); QCOMPARE(qvariant_cast<QVector2D>(object->property("test3")), QVector2D()); QCOMPARE(qvariant_cast<QVector2D>(object->property("test4")), QVector2D()); @@ -340,8 +340,8 @@ void tst_qqmlqt::vector3d() QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9)); - QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1)); + QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9f)); + QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1f)); QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D()); QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D()); @@ -360,8 +360,8 @@ void tst_qqmlqt::vector4d() QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(qvariant_cast<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9, 0.6)); - QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1, 10)); + QCOMPARE(qvariant_cast<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9f, 0.6f)); + QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1f, 10)); QCOMPARE(qvariant_cast<QVector4D>(object->property("test3")), QVector4D()); QCOMPARE(qvariant_cast<QVector4D>(object->property("test4")), QVector4D()); @@ -380,8 +380,8 @@ void tst_qqmlqt::quaternion() QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(qvariant_cast<QQuaternion>(object->property("test1")), QQuaternion(2, 17, 0.9, 0.6)); - QCOMPARE(qvariant_cast<QQuaternion>(object->property("test2")), QQuaternion(102, -10, -982.1, 10)); + QCOMPARE(qvariant_cast<QQuaternion>(object->property("test1")), QQuaternion(2, 17, 0.9f, 0.6f)); + QCOMPARE(qvariant_cast<QQuaternion>(object->property("test2")), QQuaternion(102, -10, -982.1f, 10)); QCOMPARE(qvariant_cast<QQuaternion>(object->property("test3")), QQuaternion()); QCOMPARE(qvariant_cast<QQuaternion>(object->property("test4")), QQuaternion()); diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp index f5e66a1d83..0644b363dd 100644 --- a/tests/auto/qml/v4/tst_v4.cpp +++ b/tests/auto/qml/v4/tst_v4.cpp @@ -104,16 +104,6 @@ void tst_v4::initTestCase() registerTypes(); } -static int v4ErrorCount; -static QList<QString> v4ErrorMessages; -static void v4ErrorsMsgHandler(QtMsgType, const QMessageLogContext &, const QString &message) -{ - v4ErrorMessages.append(message); - - if (message.contains("QV4")) - ++v4ErrorCount; -} - void tst_v4::qtscript() { QFETCH(QString, file); @@ -121,21 +111,14 @@ void tst_v4::qtscript() QQmlComponent component(&engine, testFileUrl(file)); - v4ErrorCount = 0; - v4ErrorMessages.clear(); - QtMessageHandler old = qInstallMessageHandler(v4ErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; QObject *o = component.create(); delete o; - qInstallMessageHandler(old); - - if (v4ErrorCount) { - foreach (const QString &msg, v4ErrorMessages) - qDebug() << msg; - } QEXPECT_FAIL("jsvalueHandling", "QTBUG-26951 - QJSValue has a different representation of NULL to QV8Engine", Continue); - QCOMPARE(v4ErrorCount, 0); + const int v4ErrorCount = messageHandler.messages().filter(QLatin1String("QV4")).size(); + QVERIFY2(v4ErrorCount == 0, qPrintable(messageHandler.messageString())); QV4Compiler::enableBindingsTest(false); } @@ -959,12 +942,6 @@ void tst_v4::subscriptions() } } -static QStringList messages; -static void msgHandler(QtMsgType, const QMessageLogContext &, const QString &msg) -{ - messages << msg; -} - static QByteArray getAddress(int address) { return QByteArray::number(address); @@ -1108,8 +1085,7 @@ void tst_v4::debuggingDumpInstructions() expectedPreAddress << "\t\tInitString\t\tString_DataIndex(0) -> String_Slot(0)"; QStringList expected; - messages = QStringList(); - QtMessageHandler old = qInstallMessageHandler(msgHandler); + QQmlTestMessageHandler messageHandler; QQmlJS::Bytecode bc; #define DUMP_INSTR_IN_UNIT_TEST(I, FMT) { QQmlJS::V4InstrData<QQmlJS::V4Instr::I> i; memset(&i, 0, sizeof(i)); bc.append(i); } @@ -1130,15 +1106,15 @@ void tst_v4::debuggingDumpInstructions() bc.dump(start, end); // ensure that the output was expected. - qInstallMessageHandler(old); - QCOMPARE(messages.count(), expected.count()); - for (int ii = 0; ii < messages.count(); ++ii) { + const int messageCount = messageHandler.messages().count(); + QCOMPARE(messageCount, expected.count()); + for (int ii = 0; ii < messageCount; ++ii) { // Calculating the destination address of a null jump/branch instruction is tricky // so instead we simply don't compare that part of those instructions. QRegExp ignoreAddress("\\bAddress\\((\\w*)\\)"); ignoreAddress.setMinimal(true); QString expectOut = expected.at(ii); expectOut.replace(ignoreAddress, ""); - QString actualOut = messages.at(ii); actualOut.replace(ignoreAddress, ""); + QString actualOut = messageHandler.messages().at(ii); actualOut.replace(ignoreAddress, ""); QCOMPARE(actualOut, expectOut); } } |