summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-01-24 16:38:43 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-03-15 23:01:03 +0000
commitf816f2e3c9dc7735eff35175c05a50446d389935 (patch)
treec0acf73447fc6b3df5d235b9c98c5255c4af143f /src/testlib
parent8264e495fa9220c101a8a913701a0b8834a6d58b (diff)
Allow log messages to be grouped by activity on Apple OSes
Useful for making sense of the event dispatcher, especially when running tests. Change-Id: Iea84bcfb40d4954439c2e31ffc0197c64907e800 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qappletestlogger.cpp11
-rw-r--r--src/testlib/qappletestlogger_p.h3
2 files changed, 12 insertions, 2 deletions
diff --git a/src/testlib/qappletestlogger.cpp b/src/testlib/qappletestlogger.cpp
index 2009595904..c8778fe207 100644
--- a/src/testlib/qappletestlogger.cpp
+++ b/src/testlib/qappletestlogger.cpp
@@ -62,8 +62,13 @@ QAppleTestLogger::QAppleTestLogger(QAbstractTestLogger *logger)
{
}
+static QAppleLogActivity testFunctionActivity;
+
void QAppleTestLogger::enterTestFunction(const char *function)
{
+ // Re-create activity each time
+ testFunctionActivity = QT_APPLE_LOG_ACTIVITY("Running test function").enter();
+
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
QTestCharBuffer testIdentifier;
QTestPrivate::generateTestIdentifier(&testIdentifier);
@@ -77,6 +82,12 @@ void QAppleTestLogger::enterTestFunction(const char *function)
m_logger->enterTestFunction(function);
}
+void QAppleTestLogger::leaveTestFunction()
+{
+ m_logger->leaveTestFunction();
+ testFunctionActivity.leave();
+}
+
typedef QPair<QtMsgType, const char *> IncidentClassification;
static IncidentClassification incidentTypeToClassification(QAbstractTestLogger::IncidentTypes type)
{
diff --git a/src/testlib/qappletestlogger_p.h b/src/testlib/qappletestlogger_p.h
index 83bc679e03..5a45fad7a0 100644
--- a/src/testlib/qappletestlogger_p.h
+++ b/src/testlib/qappletestlogger_p.h
@@ -71,8 +71,7 @@ public:
{ m_logger->stopLogging(); }
void enterTestFunction(const char *function) override;
- void leaveTestFunction() override
- { m_logger->leaveTestFunction(); }
+ void leaveTestFunction() override;
void addIncident(IncidentTypes type, const char *description,
const char *file = 0, int line = 0) override;