Skip to content

Commit

Permalink
Update DarockBili_Watch_App_UI_Tests.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
WindowsMEMZ authored Nov 16, 2023
1 parent 5334b87 commit 9e90627
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ final class DarockBili_Watch_App_UI_Tests: XCTestCase {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

takeScreenshot(of: app, named: "Launch")

app.tabBars.buttons.element(boundBy: 1).tap()
app.tabBars["MainTabView"].swipeLeft()
sleep(1)
app.buttons["AppSettingsButton"].tap()
}

Expand All @@ -40,3 +43,21 @@ final class DarockBili_Watch_App_UI_Tests: XCTestCase {
}
}
}

extension XCTestCase {
/// Take a screenshot of a given app and add it to the test attachements.
/// - Parameters:
/// - app: The app to take a screenshot of.
/// - name: The name of the screenshot.
func takeScreenshot(of app: XCUIApplication, named name: String) {
let screenshot = app.windows.firstMatch.screenshot()
let attachment = XCTAttachment(screenshot: screenshot)
#if os(iOS)
attachment.name = "Screenshot-\(name)-\(UIDevice.current.name).png"
#else
attachment.name = "Screenshot-\(name)-macOS.png"
#endif
attachment.lifetime = .keepAlways
add(attachment)
}
}

0 comments on commit 9e90627

Please sign in to comment.