aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickimage
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-12-18 11:41:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-20 21:38:38 +0100
commit5fd1c5fbaf13195fed16ca171f4eac81be125e2b (patch)
treeec6a445f2f0367f7a5298274950750ad56e23c68 /tests/auto/quick/qquickimage
parent920b949e5185258baabfb3f738b660b3c0f002e3 (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/quick/qquickimage')
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp14
1 files changed, 3 insertions, 11 deletions
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;