diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caa31eb..9b3b7cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,3 +28,19 @@ jobs: - name: Build run: set -o pipefail && make build-ui-preview | xcpretty + test-ui-preview: + runs-on: macOS-13 + + steps: + - uses: actions/checkout@main + - name: UI test + run: set -o pipefail && make test-ui-preview | xcpretty + + - name: Archive xcresult + uses: actions/upload-artifact@v3 + if: success() || failure() + with: + name: xcresult-uitest + path: /tmp/*.xcresult + if-no-files-found: error + diff --git a/Makefile b/Makefile index 13ab4b3..a5c41e9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: test-package build-ui-preview +all: test-package build-ui-preview test-ui-preview test-package: cd app/xcode && swift test @@ -6,3 +6,6 @@ test-package: build-ui-preview: cd app/xcode/App && xcodebuild -project VCam.xcodeproj -scheme VCamUIPreview -derivedDataPath /tmp/build clean build +test-ui-preview: + cd app/xcode/App && xcodebuild -project VCam.xcodeproj -scheme VCamUIPreviewUITests -derivedDataPath /tmp/build -resultBundlePath /tmp/UITestResults test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO + diff --git a/app/xcode/App/VCam.xcodeproj/project.pbxproj b/app/xcode/App/VCam.xcodeproj/project.pbxproj index 8dbc05f..ae5ca92 100644 --- a/app/xcode/App/VCam.xcodeproj/project.pbxproj +++ b/app/xcode/App/VCam.xcodeproj/project.pbxproj @@ -14,8 +14,21 @@ 061238752ADE9C6D00B67618 /* xcode in Resources */ = {isa = PBXBuildFile; fileRef = 061238742ADE9C6D00B67618 /* xcode */; }; 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 /* LaunchScreenshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06EC61212AE016C300D2A5C9 /* LaunchScreenshotTests.swift */; }; + 06EC61292AE0296600D2A5C9 /* VCamLocalization in Frameworks */ = {isa = PBXBuildFile; productRef = 06EC61282AE0296600D2A5C9 /* VCamLocalization */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 06EC61232AE016C300D2A5C9 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0612385A2ADE9A8300B67618 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 061238612ADE9A8300B67618; + remoteInfo = VCamUIPreview; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ 061238622ADE9A8300B67618 /* VCamUIPreview.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VCamUIPreview.app; sourceTree = BUILT_PRODUCTS_DIR; }; 061238652ADE9A8300B67618 /* VCamUIPreviewApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VCamUIPreviewApp.swift; sourceTree = ""; }; @@ -24,6 +37,9 @@ 0612386C2ADE9A8400B67618 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 0612386E2ADE9A8400B67618 /* VCamUIPreview.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = VCamUIPreview.entitlements; sourceTree = ""; }; 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 /* LaunchScreenshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenshotTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -36,6 +52,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 06EC611A2AE016C300D2A5C9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 06EC61292AE0296600D2A5C9 /* VCamLocalization in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -44,6 +68,7 @@ children = ( 061238742ADE9C6D00B67618 /* xcode */, 061238642ADE9A8300B67618 /* VCamUIPreview */, + 06EC611E2AE016C300D2A5C9 /* VCamUIPreviewUITests */, 061238632ADE9A8300B67618 /* Products */, 061238762ADE9CEE00B67618 /* Frameworks */, ); @@ -53,6 +78,7 @@ isa = PBXGroup; children = ( 061238622ADE9A8300B67618 /* VCamUIPreview.app */, + 06EC611D2AE016C300D2A5C9 /* VCamUIPreviewUITests.xctest */, ); name = Products; sourceTree = ""; @@ -84,6 +110,15 @@ name = Frameworks; sourceTree = ""; }; + 06EC611E2AE016C300D2A5C9 /* VCamUIPreviewUITests */ = { + isa = PBXGroup; + children = ( + 06EC611F2AE016C300D2A5C9 /* VCamUIPreviewUITests.swift */, + 06EC61212AE016C300D2A5C9 /* LaunchScreenshotTests.swift */, + ); + path = VCamUIPreviewUITests; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -108,6 +143,27 @@ productReference = 061238622ADE9A8300B67618 /* VCamUIPreview.app */; productType = "com.apple.product-type.application"; }; + 06EC611C2AE016C300D2A5C9 /* VCamUIPreviewUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 06EC61272AE016C300D2A5C9 /* Build configuration list for PBXNativeTarget "VCamUIPreviewUITests" */; + buildPhases = ( + 06EC61192AE016C300D2A5C9 /* Sources */, + 06EC611A2AE016C300D2A5C9 /* Frameworks */, + 06EC611B2AE016C300D2A5C9 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 06EC61242AE016C300D2A5C9 /* PBXTargetDependency */, + ); + name = VCamUIPreviewUITests; + packageProductDependencies = ( + 06EC61282AE0296600D2A5C9 /* VCamLocalization */, + ); + productName = VCamUIPreviewUITests; + productReference = 06EC611D2AE016C300D2A5C9 /* VCamUIPreviewUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -121,6 +177,10 @@ 061238612ADE9A8300B67618 = { CreatedOnToolsVersion = 15.0; }; + 06EC611C2AE016C300D2A5C9 = { + CreatedOnToolsVersion = 15.0; + TestTargetID = 061238612ADE9A8300B67618; + }; }; }; buildConfigurationList = 0612385D2ADE9A8300B67618 /* Build configuration list for PBXProject "VCam" */; @@ -137,6 +197,7 @@ projectRoot = ""; targets = ( 061238612ADE9A8300B67618 /* VCamUIPreview */, + 06EC611C2AE016C300D2A5C9 /* VCamUIPreviewUITests */, ); }; /* End PBXProject section */ @@ -152,6 +213,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 06EC611B2AE016C300D2A5C9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -164,8 +232,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 06EC61192AE016C300D2A5C9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 06EC61222AE016C300D2A5C9 /* LaunchScreenshotTests.swift in Sources */, + 06EC61202AE016C300D2A5C9 /* VCamUIPreviewUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 06EC61242AE016C300D2A5C9 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 061238612ADE9A8300B67618 /* VCamUIPreview */; + targetProxy = 06EC61232AE016C300D2A5C9 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ 0612386F2ADE9A8400B67618 /* Debug */ = { isa = XCBuildConfiguration; @@ -343,6 +428,40 @@ }; name = Release; }; + 06EC61252AE016C300D2A5C9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.vcamapp.example.VCamUIPreviewUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TEST_TARGET_NAME = VCamUIPreview; + }; + name = Debug; + }; + 06EC61262AE016C300D2A5C9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.vcamapp.example.VCamUIPreviewUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TEST_TARGET_NAME = VCamUIPreview; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -364,6 +483,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 06EC61272AE016C300D2A5C9 /* Build configuration list for PBXNativeTarget "VCamUIPreviewUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 06EC61252AE016C300D2A5C9 /* Debug */, + 06EC61262AE016C300D2A5C9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ @@ -375,6 +503,10 @@ isa = XCSwiftPackageProductDependency; productName = VCamStub; }; + 06EC61282AE0296600D2A5C9 /* VCamLocalization */ = { + isa = XCSwiftPackageProductDependency; + productName = VCamLocalization; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 0612385A2ADE9A8300B67618 /* Project object */; diff --git a/app/xcode/App/VCam.xcodeproj/xcshareddata/xcschemes/VCamUIPreview.xcscheme b/app/xcode/App/VCam.xcodeproj/xcshareddata/xcschemes/VCamUIPreview.xcscheme new file mode 100644 index 0000000..b2ef361 --- /dev/null +++ b/app/xcode/App/VCam.xcodeproj/xcshareddata/xcschemes/VCamUIPreview.xcscheme @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/xcode/App/VCam.xcodeproj/xcshareddata/xcschemes/VCamUIPreviewUITests.xcscheme b/app/xcode/App/VCam.xcodeproj/xcshareddata/xcschemes/VCamUIPreviewUITests.xcscheme new file mode 100644 index 0000000..4cf8864 --- /dev/null +++ b/app/xcode/App/VCam.xcodeproj/xcshareddata/xcschemes/VCamUIPreviewUITests.xcscheme @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/xcode/App/VCamUIPreviewUITests/LaunchScreenshotTests.swift b/app/xcode/App/VCamUIPreviewUITests/LaunchScreenshotTests.swift new file mode 100644 index 0000000..29c4037 --- /dev/null +++ b/app/xcode/App/VCamUIPreviewUITests/LaunchScreenshotTests.swift @@ -0,0 +1,57 @@ +// +// 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() + + // 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: "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, quality: .low) + 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 new file mode 100644 index 0000000..fabf288 --- /dev/null +++ b/app/xcode/App/VCamUIPreviewUITests/VCamUIPreviewUITests.swift @@ -0,0 +1,35 @@ +// +// VCamUIPreviewUITests.swift +// VCamUIPreviewUITests +// +// Created by Tatsuya Tanaka on 2023/10/18. +// + +import XCTest +import VCamLocalization + +final class VCamUIPreviewUITests: XCTestCase { + + override func setUpWithError() throws { + continueAfterFailure = false + LocalizationEnvironment.currentLocale = { "en_US" } + } + + override func tearDownWithError() throws { + } + + func testLaunchApp() throws { + let app = XCUIApplication() + app.launch() + + // 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 + XCTAssertTrue(app.buttons[L10n.main.text].exists) + } + } +} diff --git a/app/xcode/Package.swift b/app/xcode/Package.swift index ae5bedc..76371a2 100644 --- a/app/xcode/Package.swift +++ b/app/xcode/Package.swift @@ -13,6 +13,7 @@ let package = Package( .library(name: "VCamDefaults", targets: ["VCamDefaults"]), .library(name: "VCamAppExtension", targets: ["VCamAppExtension"]), + .library(name: "VCamLocalization", targets: ["VCamLocalization"]), .library(name: "VCamStub", targets: ["VCamStub"]), ],