aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/shared/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/shared/util.h')
-rw-r--r--tests/auto/shared/util.h21
1 files changed, 21 insertions, 0 deletions
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