diff options
Diffstat (limited to 'tests/auto')
31 files changed, 253 insertions, 247 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); } } diff --git a/tests/auto/qmltest/animations/tst_abstractanimationjobcrash.qml b/tests/auto/qmltest/animations/tst_abstractanimationjobcrash.qml new file mode 100644 index 0000000000..466bb160aa --- /dev/null +++ b/tests/auto/qmltest/animations/tst_abstractanimationjobcrash.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +Item { + Rectangle { + id: rect + + property bool finished: false + + Behavior on opacity { + NumberAnimation { + onRunningChanged: { + if (!running) { + if (rect.opacity <= 0.1) + rect.opacity = 1 + else + rect.finished = true + } + } + } + } + } + + TestCase { + name: "AbstractAnitaionJobCrash" + + function test_noCrash() { + rect.opacity = 0 + while (!rect.finished) + wait(100) + } + } +} diff --git a/tests/auto/quick/geometry/tst_geometry.cpp b/tests/auto/quick/geometry/tst_geometry.cpp index 8bf65d1638..fc5e921db5 100644 --- a/tests/auto/quick/geometry/tst_geometry.cpp +++ b/tests/auto/quick/geometry/tst_geometry.cpp @@ -139,9 +139,9 @@ void GeometryTest::testCustomGeometry() }; static QSGGeometry::Attribute attributes[] = { - { 0, 2, GL_FLOAT }, - { 1, 4, GL_UNSIGNED_BYTE }, - { 2, 4, GL_FLOAT }, + { 0, 2, GL_FLOAT, 0, 0}, + { 1, 4, GL_UNSIGNED_BYTE, 0, 0}, + { 2, 4, GL_FLOAT, 0, 0}, }; static QSGGeometry::AttributeSet set = { 4, 6 * sizeof(float) + 4 * sizeof(unsigned char), attributes }; diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 37d96f4950..dc0db6d4ff 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -292,6 +292,7 @@ private: } void releaseView(QQuickView *view) { Q_ASSERT(view == m_view); + Q_UNUSED(view) m_view->setSource(QUrl()); } #else diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 38c9bb3d8a..bce1366e52 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -661,13 +661,6 @@ void tst_qquickimage::sourceSize_QTBUG_16389() delete window; } -static int numberOfWarnings = 0; -static void checkWarnings(QtMsgType, const QMessageLogContext &, const QString &msg) -{ - if (!msg.contains("QGLContext::makeCurrent(): Failed.")) - numberOfWarnings++; -} - // QTBUG-15690 void tst_qquickimage::nullPixmapPaint() { @@ -679,12 +672,11 @@ void tst_qquickimage::nullPixmapPaint() QTRY_VERIFY(image != 0); image->setSource(SERVER_ADDR + QString("/no-such-file.png")); - QtMessageHandler previousMsgHandler = qInstallMessageHandler(checkWarnings); - + QQmlTestMessageHandler messageHandler; // used to print "QTransform::translate with NaN called" QPixmap pm = QPixmap::fromImage(window->grabWindow()); - qInstallMessageHandler(previousMsgHandler); - QVERIFY(numberOfWarnings == 0); + const QStringList glErrors = messageHandler.messages().filter(QLatin1String("QGLContext::makeCurrent(): Failed."), Qt::CaseInsensitive); + QVERIFY2(glErrors.size() == messageHandler.messages().size(), qPrintable(messageHandler.messageString())); delete image; delete window; diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp index 64eb0a7f42..19b547944c 100644 --- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp +++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp @@ -236,7 +236,7 @@ void tst_qquickimageprovider::runTest(bool async, QQuickImageProvider *provider) // From this point on, treat forced async providers as async behaviour-wise if (engine.imageProvider(QUrl(source).host()) == provider) - async |= provider->flags() & QQuickImageProvider::ForceAsynchronousImageLoading; + async |= (provider->flags() & QQuickImageProvider::ForceAsynchronousImageLoading) != 0; if (async) QTRY_VERIFY(obj->status() == QQuickImage::Loading); diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index af628dff63..51ce74ef40 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -259,18 +259,10 @@ private: } #endif - static void errorMsgHandler(QtMsgType, const QMessageLogContext &, const QString &) - { - ++m_errorCount; - } - QQuickView *m_view; QString testForView; - static int m_errorCount; }; -int tst_QQuickListView::m_errorCount = 0; - class TestObject : public QObject { Q_OBJECT @@ -6785,8 +6777,7 @@ void tst_QQuickListView::parentBinding() { QQuickView *window = createView(); - m_errorCount = 0; - QtMessageHandler old = qInstallMessageHandler(errorMsgHandler); + QQmlTestMessageHandler messageHandler; window->setSource(testFileUrl("parentBinding.qml")); window->show(); @@ -6805,9 +6796,7 @@ void tst_QQuickListView::parentBinding() QCOMPARE(item->height(), listview->height()/12); // there should be no transient binding error - QVERIFY(!m_errorCount); - - qInstallMessageHandler(old); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete window; } diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 698c016f6f..e456297a4e 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -462,6 +462,7 @@ void tst_QQuickLoader::networkComponent() " Component { id: comp; NW.Rect120x60 {} }\n" " Loader { sourceComponent: comp } }") , dataDirectory()); + QTRY_COMPARE(component.status(), QQmlComponent::Ready); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -488,6 +489,7 @@ void tst_QQuickLoader::failNetworkRequest() QQmlComponent component(&engine); component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"" SERVER_ADDR "/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl(QString(SERVER_ADDR "/dummy.qml"))); + QTRY_COMPARE(component.status(), QQmlComponent::Ready); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); QVERIFY(loader != 0); diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index d6b501c619..76768ee395 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -1285,7 +1285,6 @@ void tst_QQuickMouseArea::pressedMultipleButtons() QPoint point(10,10); - int prevButtons = 0; for (int i = 0; i < buttons.count(); ++i) { int btns = buttons.at(i); @@ -1294,8 +1293,6 @@ void tst_QQuickMouseArea::pressedMultipleButtons() QCOMPARE(mouseArea->pressed(), pressed.at(i)); QCOMPARE(mouseArea->pressedButtons(), pressedButtons.at(i)); - - prevButtons = buttons.at(i); } QTest::mousePress(view, Qt::NoButton, 0, point); diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index b9a18eec01..baba59a1aa 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -1722,111 +1722,109 @@ void tst_qquickpositioners::test_flow_implicit_resize() delete window; } -QString warningMessage; - -void interceptWarnings(QtMsgType type, const QMessageLogContext &, const QString &msg) -{ - Q_UNUSED( type ); - warningMessage = msg; -} - void tst_qquickpositioners::test_conflictinganchors() { - QtMessageHandler oldMsgHandler = qInstallMessageHandler(interceptWarnings); + QQmlTestMessageHandler messageHandler; QQmlEngine engine; QQmlComponent component(&engine); component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete item; component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete item; component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete item; component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete item; component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); - warningMessage.clear(); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); + messageHandler.clear(); delete item; component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); - warningMessage.clear(); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); + messageHandler.clear(); delete item; component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - warningMessage.clear(); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete item; component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); - warningMessage.clear(); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); + messageHandler.clear(); delete item; component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); - warningMessage.clear(); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); + messageHandler.clear(); delete item; component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - warningMessage.clear(); + QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); delete item; component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); - warningMessage.clear(); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); + messageHandler.clear(); delete item; component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); - warningMessage.clear(); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); + messageHandler.clear(); delete item; component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); + messageHandler.clear(); delete item; component.setData("import QtQuick 2.0\nFlow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); - qInstallMessageHandler(oldMsgHandler); + QCOMPARE(messageHandler.messages().size(), 1); + QCOMPARE(messageHandler.messages().back(), QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); delete item; } diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index ea2ad71bfc..f8332d661d 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2139,6 +2139,8 @@ void tst_qquicktextedit::positionAt() case QQuickTextEdit::AlignRight: xoff = texteditObject->width() - secondLine.naturalTextWidth(); break; + case QQuickTextEdit::AlignJustify: + break; } int pos = texteditObject->positionAt(texteditObject->width()/2, y0); diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 7e45bd1f14..6c688eda1b 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -3448,15 +3448,13 @@ public: void tst_qquicktextinput::setHAlignClearCache() { QQuickView view; + view.resize(200, 200); MyTextInput input; input.setText("Hello world"); input.setParentItem(view.contentItem()); view.show(); view.requestActivate(); QTest::qWaitForWindowActive(&view); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23485", Abort); -#endif QTRY_COMPARE(input.nbPaint, 1); input.setHAlign(QQuickTextInput::AlignRight); //Changing the alignment should trigger a repaint diff --git a/tests/auto/quick/qquickview/qquickview.pro b/tests/auto/quick/qquickview/qquickview.pro index 079074c83d..3e9c39e2ce 100644 --- a/tests/auto/quick/qquickview/qquickview.pro +++ b/tests/auto/quick/qquickview/qquickview.pro @@ -7,8 +7,6 @@ SOURCES += tst_qquickview.cpp include (../../shared/util.pri) -mac:CONFIG += insignificant_test # QTBUG-28505 - TESTDATA = data/* QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp index 94452b142b..aa20967fa3 100644 --- a/tests/auto/quick/qquickview/tst_qquickview.cpp +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -195,9 +195,8 @@ void tst_QQuickView::errors() { QQuickView *view = new QQuickView; QVERIFY(view); - QtMessageHandler old = qInstallMessageHandler(silentErrorsMsgHandler); + QQmlTestMessageHandler messageHandler; view->setSource(testFileUrl("error1.qml")); - qInstallMessageHandler(old); QVERIFY(view->status() == QQuickView::Error); QVERIFY(view->errors().count() == 1); delete view; diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp index 57c016a16a..eaefb1f9d6 100644 --- a/tests/auto/shared/util.cpp +++ b/tests/auto/shared/util.cpp @@ -46,6 +46,8 @@ #include <QtQml/QQmlContext> #include <QtQml/QQmlEngine> #include <QtCore/QTextStream> +#include <QtCore/QDebug> +#include <QtCore/QMutexLocker> QQmlDataTest *QQmlDataTest::m_instance = 0; @@ -107,3 +109,30 @@ QByteArray QQmlDataTest::msgComponentError(const QQmlComponent &c, } return result.toLocal8Bit(); } + +Q_GLOBAL_STATIC(QMutex, qQmlTestMessageHandlerMutex) + +QQmlTestMessageHandler *QQmlTestMessageHandler::m_instance = 0; + +void QQmlTestMessageHandler::messageHandler(QtMsgType, const QMessageLogContext &, const QString &message) +{ + QMutexLocker locker(qQmlTestMessageHandlerMutex()); + if (QQmlTestMessageHandler::m_instance) + QQmlTestMessageHandler::m_instance->m_messages.push_back(message); +} + +QQmlTestMessageHandler::QQmlTestMessageHandler() +{ + QMutexLocker locker(qQmlTestMessageHandlerMutex()); + Q_ASSERT(!QQmlTestMessageHandler::m_instance); + QQmlTestMessageHandler::m_instance = this; + m_oldHandler = qInstallMessageHandler(messageHandler); +} + +QQmlTestMessageHandler::~QQmlTestMessageHandler() +{ + QMutexLocker locker(qQmlTestMessageHandlerMutex()); + Q_ASSERT(QQmlTestMessageHandler::m_instance); + qInstallMessageHandler(m_oldHandler); + QQmlTestMessageHandler::m_instance = 0; +} diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h index 4a5c9176c6..eff54b30d9 100644 --- a/tests/auto/shared/util.h +++ b/tests/auto/shared/util.h @@ -45,6 +45,7 @@ #include <QtCore/QDir> #include <QtCore/QUrl> #include <QtCore/QCoreApplication> +#include <QtCore/QStringList> #include <QtTest/QTest> QT_FORWARD_DECLARE_CLASS(QQmlComponent) @@ -87,4 +88,24 @@ private: QString m_directory; }; +class QQmlTestMessageHandler +{ + Q_DISABLE_COPY(QQmlTestMessageHandler) +public: + QQmlTestMessageHandler(); + ~QQmlTestMessageHandler(); + + const QStringList &messages() const { return m_messages; } + const QString messageString() const { return m_messages.join(QLatin1Char('\n')); } + + void clear() { m_messages.clear(); } + +private: + static void messageHandler(QtMsgType, const QMessageLogContext &, const QString &message); + + static QQmlTestMessageHandler *m_instance; + QStringList m_messages; + QtMessageHandler m_oldHandler; +}; + #endif // QQMLTESTUTILS_H |