Skip to content

Commit

Permalink
Highlights user created activities
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneCheshire committed Nov 26, 2018
1 parent 0a4a892 commit e889dde
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions xcresult/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
8 changes: 7 additions & 1 deletion xcresult/ResultHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ struct ResultHandler {
}
displayableSummaries.forEach { activitySummaryLevel in
let indent = String(repeating: "  ", count: activitySummaryLevel.level)
html += "<p>\(indent)\(activitySummaryLevel.activity.title)</p>"
let cssClass = activitySummaryLevel.activity.activityType == .userCreated ? "user-activity" : ""
html += "<p class='\(cssClass)'>\(indent)\(activitySummaryLevel.activity.title)</p>"
if let attachment = activitySummaryLevel.activity.attachments?.first, let imagePath = imagePaths.first(where: { $0.contains(attachment.filename) }) {
let url = URL(fileURLWithPath: imagePath)
html += "<p>\(indent)<img class='screenshot' src='\(url.absoluteString)' width='256'/></p>"
Expand Down Expand Up @@ -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;
}
</style>
</head>
<body>
Expand Down

0 comments on commit e889dde

Please sign in to comment.