diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-12-18 11:41:06 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-20 21:38:38 +0100 |
commit | 5fd1c5fbaf13195fed16ca171f4eac81be125e2b (patch) | |
tree | ec6a445f2f0367f7a5298274950750ad56e23c68 /tests/auto/qml/qqmlpropertymap | |
parent | 920b949e5185258baabfb3f738b660b3c0f002e3 (diff) |
Quick tests: Introduce QQmlMessageHandler.
Add QQmlMessageHandler class that can be used to record messages
into a QStringList. It also makes sure that the old message
handler is reinstalled if the test fails.
Task-number: QTBUG-28611
Change-Id: I0fff7bc11e188cf47178d9573e5f2eead693bc10
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlpropertymap')
-rw-r--r-- | tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp | 17 |
2 files changed, 5 insertions, 14 deletions
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) |