From 5fd1c5fbaf13195fed16ca171f4eac81be125e2b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Dec 2012 11:41:06 +0100 Subject: 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 --- tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'tests/auto/quick/qquicklistview') 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; } -- cgit v1.2.3