From 7da540cc55b7a3e7723b401684278637530e6a0e Mon Sep 17 00:00:00 2001 From: WindowsMEMZ <45706356+WindowsMEMZ@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:36:00 +0800 Subject: [PATCH] Update DarockBili_Watch_App_UI_Tests.swift --- .../DarockBili_Watch_App_UI_Tests.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift b/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift index 7f71474f4..84a9639c4 100644 --- a/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift +++ b/DarockBili Watch App UI Tests/DarockBili_Watch_App_UI_Tests.swift @@ -55,11 +55,26 @@ extension XCTestCase { let screenshot = app.windows.firstMatch.screenshot() let attachment = XCTAttachment(screenshot: screenshot) #if os(iOS) - attachment.name = "Screenshot-\(name)-\(UIDevice.current.name).png" + let name = "Screenshot-\(name)-\(UIDevice.current.name).png" #else - attachment.name = "Screenshot-\(name)-macOS.png" + let name = "Screenshot-\(name)-watchOS.png" #endif + attachment.name = name attachment.lifetime = .keepAlways add(attachment) + + let url = downloadsFolder.appendingPathComponent("appshot.png") + try! appshot.pngRepresentation.write(to: url) } } + +var downloadsFolder: URL = { + let fm = FileManager.default + let folder = fm.urls(for: .downloadsDirectory, in: .userDomainMask)[0] + + var isDirectory: ObjCBool = false + if !(fm.fileExists(atPath: folder.path, isDirectory: &isDirectory) && isDirectory.boolValue) { + try! fm.createDirectory(at: folder, withIntermediateDirectories: false, attributes: nil) + } + return folder +}()