From a5ec12e3dfb1b8f236ca0140e97d9914c602b34b Mon Sep 17 00:00:00 2001 From: Magesh K <47920326+mahee96@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:14:54 +0530 Subject: [PATCH] - UITests: Setup for UI Tests --- AltStore.xcodeproj/project.pbxproj | 154 +++++++++++++++++- .../xcshareddata/xcschemes/SideStore.xcscheme | 21 ++- SideStore/Tests/SideStoreTests.xctestplan | 33 ++++ SideStore/Tests/UITests/UITests.swift | 44 +++++ .../Tests/UITests/UITestsLaunchTests.swift | 34 ++++ xcconfigs/UITests.xcconfig | 3 + 6 files changed, 282 insertions(+), 7 deletions(-) create mode 100644 SideStore/Tests/SideStoreTests.xctestplan create mode 100644 SideStore/Tests/UITests/UITests.swift create mode 100644 SideStore/Tests/UITests/UITestsLaunchTests.swift create mode 100644 xcconfigs/UITests.xcconfig diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index 6d8fea94..49adbfa0 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -89,6 +89,9 @@ A8C6D5182D1EE95B00DF01F1 /* OpenSSL.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A859ED5B2D1EE80D003DCC58 /* OpenSSL.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; A8D484D82D0CD306002C691D /* AltBackup.ipa in Resources */ = {isa = PBXBuildFile; fileRef = A8D484D72D0CD306002C691D /* AltBackup.ipa */; }; A8D49F532D3D2F9400844B92 /* ProcessInfo+AltStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8D49F522D3D2F9400844B92 /* ProcessInfo+AltStore.swift */; }; + A8E2DB312D684E2A009E5D31 /* UITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8E2DB2E2D684E2A009E5D31 /* UITests.swift */; }; + A8E2DB322D684E2A009E5D31 /* UITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8E2DB2F2D684E2A009E5D31 /* UITestsLaunchTests.swift */; }; + A8E2DB342D68507F009E5D31 /* SideStoreTests.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = A8E2DB332D68507F009E5D31 /* SideStoreTests.xctestplan */; }; A8EA195F2D4982D600DC6322 /* BaseEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8EA195E2D4982D600DC6322 /* BaseEntity.swift */; }; A8F838922D048E8F00ED425D /* libEmotionalDamage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19104DB22909C06C00C49C7B /* libEmotionalDamage.a */; }; A8F838932D048E8F00ED425D /* libminimuxer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 191E5FAB290A5D92001A3B7C /* libminimuxer.a */; }; @@ -504,6 +507,13 @@ remoteGlobalIDString = BF58047A246A28F7008AE704; remoteInfo = AltBackup; }; + A8E2DB272D684CBD009E5D31 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BFD247622284B9A500981D42 /* Project object */; + proxyType = 1; + remoteGlobalIDString = BFD247692284B9A500981D42; + remoteInfo = SideStore; + }; BF66EE832501AE50007EE018 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = BFD247622284B9A500981D42 /* Project object */; @@ -667,6 +677,11 @@ A8C38C372D2084D000E83DBD /* ConsoleLogView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsoleLogView.swift; sourceTree = ""; }; A8D484D72D0CD306002C691D /* AltBackup.ipa */ = {isa = PBXFileReference; lastKnownFileType = file; path = AltBackup.ipa; sourceTree = ""; }; A8D49F522D3D2F9400844B92 /* ProcessInfo+AltStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProcessInfo+AltStore.swift"; sourceTree = ""; }; + A8E2DB212D684CBD009E5D31 /* UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + A8E2DB2C2D684D39009E5D31 /* UITests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = UITests.xcconfig; sourceTree = ""; }; + A8E2DB2E2D684E2A009E5D31 /* UITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITests.swift; sourceTree = ""; }; + A8E2DB2F2D684E2A009E5D31 /* UITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITestsLaunchTests.swift; sourceTree = ""; }; + A8E2DB332D68507F009E5D31 /* SideStoreTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = SideStoreTests.xctestplan; sourceTree = ""; }; A8EA195E2D4982D600DC6322 /* BaseEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseEntity.swift; sourceTree = ""; }; A8F66C3C2D04D433009689E6 /* em_proxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = em_proxy.h; sourceTree = ""; }; A8F66C602D04D464009689E6 /* minimuxer.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = minimuxer.xcodeproj; sourceTree = ""; }; @@ -1066,6 +1081,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A8E2DB1E2D684CBD009E5D31 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; BF580478246A28F7008AE704 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1216,6 +1238,7 @@ A85ACB902D1F31C400AA3DE7 /* AltStore.release.xcconfig */, A85ACB8E2D1F31C400AA3DE7 /* AltBackup.xcconfig */, A85ACB932D1F31C400AA3DE7 /* AltWidgetExtension.xcconfig */, + A8E2DB2C2D684D39009E5D31 /* UITests.xcconfig */, ); path = xcconfigs; sourceTree = ""; @@ -1322,6 +1345,24 @@ path = common; sourceTree = ""; }; + A8E2DB302D684E2A009E5D31 /* UITests */ = { + isa = PBXGroup; + children = ( + A8E2DB2E2D684E2A009E5D31 /* UITests.swift */, + A8E2DB2F2D684E2A009E5D31 /* UITestsLaunchTests.swift */, + ); + path = UITests; + sourceTree = ""; + }; + A8E2DB352D6850A9009E5D31 /* Tests */ = { + isa = PBXGroup; + children = ( + A8E2DB302D684E2A009E5D31 /* UITests */, + A8E2DB332D68507F009E5D31 /* SideStoreTests.xctestplan */, + ); + path = Tests; + sourceTree = ""; + }; A8EA19602D4982E300DC6322 /* DatabaseManager */ = { isa = PBXGroup; children = ( @@ -1350,6 +1391,7 @@ A8F66C072D04C025009689E6 /* SideStore */ = { isa = PBXGroup; children = ( + A8E2DB352D6850A9009E5D31 /* Tests */, A8F66C5C2D04D433009689E6 /* minimuxer */, A8F66C602D04D464009689E6 /* minimuxer.xcodeproj */, A8F66C412D04D433009689E6 /* em_proxy */, @@ -1919,6 +1961,7 @@ 19104DB22909C06C00C49C7B /* libEmotionalDamage.a */, 191E5FAB290A5D92001A3B7C /* libminimuxer.a */, D586D39828EF58B0000E101F /* AltTests.xctest */, + A8E2DB212D684CBD009E5D31 /* UITests.xctest */, ); name = Products; sourceTree = ""; @@ -2399,6 +2442,26 @@ productReference = 191E5FAB290A5D92001A3B7C /* libminimuxer.a */; productType = "com.apple.product-type.library.static"; }; + A8E2DB202D684CBD009E5D31 /* UITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = A8E2DB292D684CBD009E5D31 /* Build configuration list for PBXNativeTarget "UITests" */; + buildPhases = ( + A8E2DB1D2D684CBD009E5D31 /* Sources */, + A8E2DB1E2D684CBD009E5D31 /* Frameworks */, + A8E2DB1F2D684CBD009E5D31 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + A8E2DB282D684CBD009E5D31 /* PBXTargetDependency */, + ); + name = UITests; + packageProductDependencies = ( + ); + productName = UITests; + productReference = A8E2DB212D684CBD009E5D31 /* UITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; BF45872A2298D31600BD7491 /* libimobiledevice */ = { isa = PBXNativeTarget; buildConfigurationList = BF4587332298D31600BD7491 /* Build configuration list for PBXNativeTarget "libimobiledevice" */; @@ -2510,7 +2573,7 @@ BFD247622284B9A500981D42 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1400; + LastSwiftUpdateCheck = 1620; LastUpgradeCheck = 1020; ORGANIZATIONNAME = SideStore; TargetAttributes = { @@ -2520,6 +2583,10 @@ 191E5FAA290A5D92001A3B7C = { CreatedOnToolsVersion = 14.0; }; + A8E2DB202D684CBD009E5D31 = { + CreatedOnToolsVersion = 16.2; + TestTargetID = BFD247692284B9A500981D42; + }; BF45872A2298D31600BD7491 = { CreatedOnToolsVersion = 10.2.1; }; @@ -2586,6 +2653,7 @@ BF989166250AABF3002ACF50 /* AltWidgetExtension */, 19104DB12909C06C00C49C7B /* EmotionalDamage */, 191E5FAA290A5D92001A3B7C /* minimuxer */, + A8E2DB202D684CBD009E5D31 /* UITests */, ); }; /* End PBXProject section */ @@ -2643,6 +2711,14 @@ /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ + A8E2DB1F2D684CBD009E5D31 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A8E2DB342D68507F009E5D31 /* SideStoreTests.xctestplan in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; BF580479246A28F7008AE704 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -2814,6 +2890,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A8E2DB1D2D684CBD009E5D31 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A8E2DB312D684E2A009E5D31 /* UITests.swift in Sources */, + A8E2DB322D684E2A009E5D31 /* UITestsLaunchTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; BF4587282298D31600BD7491 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3202,6 +3287,11 @@ target = BF58047A246A28F7008AE704 /* AltBackup */; targetProxy = A8E00D3D2D0C95B5000DD2C7 /* PBXContainerItemProxy */; }; + A8E2DB282D684CBD009E5D31 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = BFD247692284B9A500981D42 /* SideStore */; + targetProxy = A8E2DB272D684CBD009E5D31 /* PBXContainerItemProxy */; + }; BF66EE842501AE50007EE018 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = BF66EE7D2501AE50007EE018 /* AltStoreCore */; @@ -3365,6 +3455,59 @@ }; name = Release; }; + A8E2DB2A2D684CBD009E5D31 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A8E2DB2C2D684D39009E5D31 /* UITests.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "--PRODUCT-BUNDLE-IDENTIFIER-.UITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = SideStore; + }; + name = Debug; + }; + A8E2DB2B2D684CBD009E5D31 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A8E2DB2C2D684D39009E5D31 /* UITests.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "--PRODUCT-BUNDLE-IDENTIFIER-.UITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = SideStore; + }; + name = Release; + }; BF4587342298D31600BD7491 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -3900,6 +4043,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + A8E2DB292D684CBD009E5D31 /* Build configuration list for PBXNativeTarget "UITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A8E2DB2A2D684CBD009E5D31 /* Debug */, + A8E2DB2B2D684CBD009E5D31 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; BF4587332298D31600BD7491 /* Build configuration list for PBXNativeTarget "libimobiledevice" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/AltStore.xcodeproj/xcshareddata/xcschemes/SideStore.xcscheme b/AltStore.xcodeproj/xcshareddata/xcschemes/SideStore.xcscheme index 1a73712e..56b21a62 100644 --- a/AltStore.xcodeproj/xcshareddata/xcschemes/SideStore.xcscheme +++ b/AltStore.xcodeproj/xcshareddata/xcschemes/SideStore.xcscheme @@ -28,18 +28,27 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - + + + + + skipped = "NO"> + + + + diff --git a/SideStore/Tests/SideStoreTests.xctestplan b/SideStore/Tests/SideStoreTests.xctestplan new file mode 100644 index 00000000..d0177c64 --- /dev/null +++ b/SideStore/Tests/SideStoreTests.xctestplan @@ -0,0 +1,33 @@ +{ + "configurations" : [ + { + "id" : "93E5E265-DC67-47F3-A214-8082A3421288", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "targetForVariableExpansion" : { + "containerPath" : "container:AltStore.xcodeproj", + "identifier" : "BFD247692284B9A500981D42", + "name" : "SideStore" + } + }, + "testTargets" : [ + { + "skippedTests" : [ + "UITests\/testLaunchPerformance()", + "UITestsLaunchTests", + "UITestsLaunchTests\/testLaunch()" + ], + "target" : { + "containerPath" : "container:AltStore.xcodeproj", + "identifier" : "A8E2DB202D684CBD009E5D31", + "name" : "UITests" + } + } + ], + "version" : 1 +} diff --git a/SideStore/Tests/UITests/UITests.swift b/SideStore/Tests/UITests/UITests.swift new file mode 100644 index 00000000..694d99d6 --- /dev/null +++ b/SideStore/Tests/UITests/UITests.swift @@ -0,0 +1,44 @@ +// +// UITests.swift +// UITests +// +// Created by Magesh K on 21/02/25. +// Copyright © 2025 SideStore. All rights reserved. +// + +import XCTest + +final class UITests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + @MainActor + func testExample() throws { + // UI tests must launch the application that they test. + let app = XCUIApplication() + app.launch() + + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + +// @MainActor +// func testLaunchPerformance() throws { +// if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { +// // This measures how long it takes to launch your application. +// measure(metrics: [XCTApplicationLaunchMetric()]) { +// XCUIApplication().launch() +// } +// } +// } +} diff --git a/SideStore/Tests/UITests/UITestsLaunchTests.swift b/SideStore/Tests/UITests/UITestsLaunchTests.swift new file mode 100644 index 00000000..4ead3441 --- /dev/null +++ b/SideStore/Tests/UITests/UITestsLaunchTests.swift @@ -0,0 +1,34 @@ +// +// UITestsLaunchTests.swift +// UITests +// +// Created by Magesh K on 21/02/25. +// Copyright © 2025 SideStore. All rights reserved. +// + +import XCTest + +final class UITestsLaunchTests: XCTestCase { + + override class var runsForEachTargetApplicationUIConfiguration: Bool { + true + } + + override func setUpWithError() throws { + continueAfterFailure = false + } + +// @MainActor +// func testLaunch() throws { +// let app = XCUIApplication() +// app.launch() +// +// // Insert steps here to perform after app launch but before taking a screenshot, +// // such as logging into a test account or navigating somewhere in the app +// +// let attachment = XCTAttachment(screenshot: app.screenshot()) +// attachment.name = "Launch Screen" +// attachment.lifetime = .keepAlways +// add(attachment) +// } +} diff --git a/xcconfigs/UITests.xcconfig b/xcconfigs/UITests.xcconfig new file mode 100644 index 00000000..94c175d2 --- /dev/null +++ b/xcconfigs/UITests.xcconfig @@ -0,0 +1,3 @@ +#include "../Build.xcconfig" + +PRODUCT_BUNDLE_IDENTIFIER = $(PRODUCT_BUNDLE_IDENTIFIER).UITests