From e889dde9b02fdc106917816631ea3cf6362fe3ec Mon Sep 17 00:00:00 2001 From: Kane Cheshire Date: Mon, 26 Nov 2018 22:55:41 +0000 Subject: [PATCH] Highlights user created activities --- xcresult/Result.swift | 12 ++++++++++++ xcresult/ResultHandler.swift | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/xcresult/Result.swift b/xcresult/Result.swift index 96af737..ae5e5e8 100644 --- a/xcresult/Result.swift +++ b/xcresult/Result.swift @@ -80,16 +80,28 @@ struct ActivitySummary: Codable { typealias ActivityLevel = (activity: ActivitySummary, level: Int) + enum ActivityType: String, Codable { + case userCreated = "com.apple.dt.xctest.activity-type.userCreated" + case attachmentContainer = "com.apple.dt.xctest.activity-type.attachmentContainer" + case assertionFailure = "com.apple.dt.xctest.activity-type.testAssertionFailure" + case appleInternal = "com.apple.dt.xctest.activity-type.internal" + case deletedAttachment = "com.apple.dt.xctest.activity-type.deletedAttachment" + } + + let activityType: ActivityType let subActivities: [ActivitySummary]? let attachments: [Attachment]? let uuid: UUID let title: String + let startTimeInterval: TimeInterval enum CodingKeys: String, CodingKey { case subActivities = "SubActivities" case attachments = "Attachments" case uuid = "UUID" case title = "Title" + case startTimeInterval = "StartTimeInterval" + case activityType = "ActivityType" } func allSummaryLevels(from level: Int = 0) -> [ActivityLevel] { diff --git a/xcresult/ResultHandler.swift b/xcresult/ResultHandler.swift index 6c1f631..8687980 100644 --- a/xcresult/ResultHandler.swift +++ b/xcresult/ResultHandler.swift @@ -64,7 +64,8 @@ struct ResultHandler { } displayableSummaries.forEach { activitySummaryLevel in let indent = String(repeating: "  ", count: activitySummaryLevel.level) - html += "

\(indent)\(activitySummaryLevel.activity.title)

" + let cssClass = activitySummaryLevel.activity.activityType == .userCreated ? "user-activity" : "" + html += "

\(indent)\(activitySummaryLevel.activity.title)

" if let attachment = activitySummaryLevel.activity.attachments?.first, let imagePath = imagePaths.first(where: { $0.contains(attachment.filename) }) { let url = URL(fileURLWithPath: imagePath) html += "

\(indent)

" @@ -143,6 +144,11 @@ struct ResultHandler { img.screenshot { border-radius:20pt; } + p.user-activity { + background:rgb(42, 42, 42); + border-radius:5pt; + padding-left:8pt !important; + }