diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e463b36..9b3b7cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,8 +30,6 @@ jobs: test-ui-preview: runs-on: macOS-13 - permissions: - checks: write steps: - uses: actions/checkout@main @@ -40,8 +38,9 @@ jobs: - name: Archive xcresult uses: actions/upload-artifact@v3 + if: success() || failure() with: - name: xcresults-uitest + name: xcresult-uitest path: /tmp/*.xcresult if-no-files-found: error diff --git a/app/xcode/App/VCam.xcodeproj/project.pbxproj b/app/xcode/App/VCam.xcodeproj/project.pbxproj index 85bff44..ae5ca92 100644 --- a/app/xcode/App/VCam.xcodeproj/project.pbxproj +++ b/app/xcode/App/VCam.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 061238782ADE9CEE00B67618 /* VCam in Frameworks */ = {isa = PBXBuildFile; productRef = 061238772ADE9CEE00B67618 /* VCam */; }; 06EC61182ADEE7A900D2A5C9 /* VCamStub in Frameworks */ = {isa = PBXBuildFile; productRef = 06EC61172ADEE7A900D2A5C9 /* VCamStub */; }; 06EC61202AE016C300D2A5C9 /* VCamUIPreviewUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06EC611F2AE016C300D2A5C9 /* VCamUIPreviewUITests.swift */; }; - 06EC61222AE016C300D2A5C9 /* VCamUIPreviewUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06EC61212AE016C300D2A5C9 /* VCamUIPreviewUITestsLaunchTests.swift */; }; + 06EC61222AE016C300D2A5C9 /* LaunchScreenshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06EC61212AE016C300D2A5C9 /* LaunchScreenshotTests.swift */; }; 06EC61292AE0296600D2A5C9 /* VCamLocalization in Frameworks */ = {isa = PBXBuildFile; productRef = 06EC61282AE0296600D2A5C9 /* VCamLocalization */; }; /* End PBXBuildFile section */ @@ -39,7 +39,7 @@ 061238742ADE9C6D00B67618 /* xcode */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = xcode; path = ..; sourceTree = ""; }; 06EC611D2AE016C300D2A5C9 /* VCamUIPreviewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VCamUIPreviewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 06EC611F2AE016C300D2A5C9 /* VCamUIPreviewUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VCamUIPreviewUITests.swift; sourceTree = ""; }; - 06EC61212AE016C300D2A5C9 /* VCamUIPreviewUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VCamUIPreviewUITestsLaunchTests.swift; sourceTree = ""; }; + 06EC61212AE016C300D2A5C9 /* LaunchScreenshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenshotTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -114,7 +114,7 @@ isa = PBXGroup; children = ( 06EC611F2AE016C300D2A5C9 /* VCamUIPreviewUITests.swift */, - 06EC61212AE016C300D2A5C9 /* VCamUIPreviewUITestsLaunchTests.swift */, + 06EC61212AE016C300D2A5C9 /* LaunchScreenshotTests.swift */, ); path = VCamUIPreviewUITests; sourceTree = ""; @@ -236,7 +236,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 06EC61222AE016C300D2A5C9 /* VCamUIPreviewUITestsLaunchTests.swift in Sources */, + 06EC61222AE016C300D2A5C9 /* LaunchScreenshotTests.swift in Sources */, 06EC61202AE016C300D2A5C9 /* VCamUIPreviewUITests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/app/xcode/App/VCamUIPreviewUITests/LaunchScreenshotTests.swift b/app/xcode/App/VCamUIPreviewUITests/LaunchScreenshotTests.swift new file mode 100644 index 0000000..fa3b850 --- /dev/null +++ b/app/xcode/App/VCamUIPreviewUITests/LaunchScreenshotTests.swift @@ -0,0 +1,51 @@ +// +// LaunchScreenshotTests.swift +// VCamUIPreviewUITests +// +// Created by Tatsuya Tanaka on 2023/10/18. +// + +import XCTest +import VCamLocalization + +final class LaunchScreenshotTests: XCTestCase { + + override class var runsForEachTargetApplicationUIConfiguration: Bool { + true + } + + override func setUpWithError() throws { + continueAfterFailure = false + LocalizationEnvironment.currentLocale = { "en_US" } + } + + func testLaunch() throws { + let app = XCUIApplication() + app.launch() + + XCTContext.runActivity(named: "Launch Screen") { activity in + add(.keepAlways(screenshot: app.screenshot(), activity: activity)) + } + + XCTContext.runActivity(named: "\(L10n.recording.text) Screen") { activity in + app.buttons[L10n.recording.text].click() + _ = app.staticTexts[L10n.whiteBalance.text].waitForExistence(timeout: 5) + add(.keepAlways(screenshot: app.screenshot(), activity: activity)) + } + + XCTContext.runActivity(named: "\(L10n.screenEffect.text) Screen") { activity in + app.buttons[L10n.screenEffect.text].click() + _ = app.staticTexts[L10n.startRecording.text].waitForExistence(timeout: 5) + add(.keepAlways(screenshot: app.screenshot(), activity: activity)) + } + } +} + +private extension XCTAttachment { + static func keepAlways(screenshot: XCUIScreenshot, activity: XCTActivity) -> XCTAttachment { + let attachment = XCTAttachment(screenshot: screenshot) + attachment.name = activity.name + attachment.lifetime = .keepAlways + return attachment + } +} diff --git a/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITests.swift b/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITests.swift index 824b4df..fabf288 100644 --- a/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITests.swift +++ b/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITests.swift @@ -22,11 +22,10 @@ final class VCamUIPreviewUITests: XCTestCase { let app = XCUIApplication() app.launch() - XCTContext.runActivity(named: "Close the alert about the virtual camera if needed") { _ in - if app.staticTexts[L10n.installVirtualCamera.text].exists { - app.buttons["OK"].click() - app.buttons["OK"].click() - } + // Close the alert about the virtual camera if needed" + if app.staticTexts[L10n.installVirtualCamera.text].exists { + app.buttons["OK"].click() + app.buttons["OK"].click() } XCTContext.runActivity(named: "Check VCamUI") { _ in diff --git a/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITestsLaunchTests.swift b/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITestsLaunchTests.swift deleted file mode 100644 index d671f71..0000000 --- a/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITestsLaunchTests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// VCamUIPreviewUITestsLaunchTests.swift -// VCamUIPreviewUITests -// -// Created by Tatsuya Tanaka on 2023/10/18. -// - -import XCTest - -final class VCamUIPreviewUITestsLaunchTests: XCTestCase { - - override class var runsForEachTargetApplicationUIConfiguration: Bool { - true - } - - override func setUpWithError() throws { - continueAfterFailure = false - } - - func testLaunch() throws { - let app = XCUIApplication() - app.launch() - - let attachment = XCTAttachment(screenshot: app.screenshot()) - attachment.name = "Launch Screen" - attachment.lifetime = .keepAlways - add(attachment) - } -}