@@ -6,37 +6,21 @@ import XCTest
66
77class ProfilingUITests : BaseUITest {
88 override var automaticallyLaunchAndTerminateApp : Bool { false }
9-
10- func testAppLaunchesWithTraceProfiler( ) throws {
11- guard #available( iOS 16 , * ) else {
12- throw XCTSkip ( " Only run for latest iOS version we test; we've had issues with prior versions in SauceLabs " )
13- }
14-
15- try performTest ( profileType: . trace)
16- }
17-
18- func testAppLaunchesWithContinuousProfilerV1( ) throws {
19- guard #available( iOS 16 , * ) else {
20- throw XCTSkip ( " Only run for latest iOS version we test; we've had issues with prior versions in SauceLabs " )
21- }
22-
23- try performTest ( profileType: . continuous)
24- }
259
2610 func testAppLaunchesWithContinuousProfilerV2TraceLifecycle( ) throws {
2711 guard #available( iOS 16 , * ) else {
2812 throw XCTSkip ( " Only run for latest iOS version we test; we've had issues with prior versions in SauceLabs " )
2913 }
3014
31- try performTest ( profileType : . ui , lifecycle: . trace)
15+ try performTest ( lifecycle: . trace)
3216 }
3317
3418 func testAppLaunchesWithContinuousProfilerV2ManualLifeCycle( ) throws {
3519 guard #available( iOS 16 , * ) else {
3620 throw XCTSkip ( " Only run for latest iOS version we test; we've had issues with prior versions in SauceLabs " )
3721 }
3822
39- try performTest ( profileType : . ui , lifecycle: . manual)
23+ try performTest ( lifecycle: . manual)
4024 }
4125
4226 /**
@@ -131,18 +115,12 @@ extension ProfilingUITests {
131115 app. buttons [ " io.sentry.ios-swift.ui-test.button.stop-continuous-profiler " ] . afterWaitingForExistence ( " Couldn't find button to stop continuous profiler " ) . tap ( )
132116 }
133117
134- enum ProfilingType {
135- case trace
136- case continuous // aka "continuous beta"
137- case ui // aka "continuous v2"
118+ func performTest( lifecycle: SentryProfileOptions . SentryProfileLifecycle ? = nil ) throws {
119+ try launchAndConfigureSubsequentLaunches ( shouldProfileThisLaunch: false , shouldProfileNextLaunch: true , lifecycle: lifecycle)
120+ try launchAndConfigureSubsequentLaunches ( terminatePriorSession: true , shouldProfileThisLaunch: true , shouldProfileNextLaunch: false , lifecycle: lifecycle)
138121 }
139122
140- func performTest( profileType: ProfilingType , lifecycle: SentryProfileOptions . SentryProfileLifecycle ? = nil ) throws {
141- try launchAndConfigureSubsequentLaunches ( shouldProfileThisLaunch: false , shouldProfileNextLaunch: true , profileType: profileType, lifecycle: lifecycle)
142- try launchAndConfigureSubsequentLaunches ( terminatePriorSession: true , shouldProfileThisLaunch: true , shouldProfileNextLaunch: false , profileType: profileType, lifecycle: lifecycle)
143- }
144-
145- fileprivate func setAppLaunchParameters( _ profileType: ProfilingUITests . ProfilingType , _ lifecycle: SentryProfileOptions . SentryProfileLifecycle ? , _ shouldProfileNextLaunch: Bool ) {
123+ fileprivate func setAppLaunchParameters( _ lifecycle: SentryProfileOptions . SentryProfileLifecycle ? , _ shouldProfileNextLaunch: Bool ) {
146124 app. launchArguments. append ( contentsOf: [
147125 // these help avoid other profiles that'd be taken automatically, that interfere with the checking we do for the assertions later in the tests
148126 SentrySDKOverrides . Other. disableSwizzling. rawValue,
@@ -156,23 +134,15 @@ extension ProfilingUITests {
156134 // override full chunk completion before stoppage introduced in https://github.com/getsentry/sentry-cocoa/pull/4214
157135 SentrySDKOverrides . Profiling. immediateStop. rawValue
158136 ] )
159-
160- switch profileType {
161- case . ui:
162- app. launchEnvironment [ SentrySDKOverrides . Profiling. sessionSampleRate. rawValue] = " 1 "
163- switch lifecycle {
164- case . none:
165- fatalError ( " Misconfigured test case. Must provide a lifecycle for UI profiling. " )
166- case . trace:
167- break
168- case . manual:
169- app. launchArguments. append ( SentrySDKOverrides . Profiling. manualLifecycle. rawValue)
170- }
171- case . continuous:
172- app. launchArguments. append ( SentrySDKOverrides . Profiling. disableUIProfiling. rawValue)
137+
138+ app. launchEnvironment [ SentrySDKOverrides . Profiling. sessionSampleRate. rawValue] = " 1 "
139+ switch lifecycle {
140+ case . none:
141+ fatalError ( " Misconfigured test case. Must provide a lifecycle for UI profiling. " )
173142 case . trace:
174- app. launchArguments. append ( SentrySDKOverrides . Profiling. disableUIProfiling. rawValue)
175- app. launchEnvironment [ SentrySDKOverrides . Profiling. sampleRate. rawValue] = " 1 "
143+ break
144+ case . manual:
145+ app. launchArguments. append ( SentrySDKOverrides . Profiling. manualLifecycle. rawValue)
176146 }
177147
178148 if !shouldProfileNextLaunch {
@@ -192,15 +162,14 @@ extension ProfilingUITests {
192162 terminatePriorSession: Bool = false ,
193163 shouldProfileThisLaunch: Bool ,
194164 shouldProfileNextLaunch: Bool ,
195- profileType: ProfilingType ,
196165 lifecycle: SentryProfileOptions . SentryProfileLifecycle ?
197166 ) throws {
198167 if terminatePriorSession {
199168 app. terminate ( )
200169 app = newAppSession ( )
201170 }
202171
203- setAppLaunchParameters ( profileType , lifecycle, shouldProfileNextLaunch)
172+ setAppLaunchParameters ( lifecycle, shouldProfileNextLaunch)
204173
205174 launchApp ( activateBeforeLaunch: false )
206175 goToProfiling ( )
@@ -217,14 +186,10 @@ extension ProfilingUITests {
217186 return
218187 }
219188
220- if profileType == . trace {
221- retrieveLastProfileData ( )
222- } else {
223- if profileType == . continuous || ( profileType == . ui && lifecycle == . manual) {
224- stopContinuousProfiler ( )
225- }
226- retrieveFirstProfileChunkData ( )
189+ if lifecycle == . manual {
190+ stopContinuousProfiler ( )
227191 }
192+ retrieveFirstProfileChunkData ( )
228193
229194 try assertProfileContents ( )
230195 }
0 commit comments