From f816f2e3c9dc7735eff35175c05a50446d389935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 24 Jan 2018 16:38:43 +0100 Subject: Allow log messages to be grouped by activity on Apple OSes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Useful for making sense of the event dispatcher, especially when running tests. Change-Id: Iea84bcfb40d4954439c2e31ffc0197c64907e800 Reviewed-by: Morten Johan Sørvig --- src/testlib/qappletestlogger.cpp | 11 +++++++++++ src/testlib/qappletestlogger_p.h | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/testlib') 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 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; -- cgit v1.2.3