@@ -31,7 +31,7 @@ class CoreBeaconFactoryTests: InstanaTestCase {
3131 let mfs = CoreBeaconFactory ( mfSession)
3232
3333 // Then
34- AssertEqualAndNotNil ( mfs. mobileFeatures!, " \( mobileFeatureCrash ) , \( mobileFeatureAutoScreenNameCapture ) " )
34+ AssertEqualAndNotNil ( mfs. mobileFeatures!, " c,lm,sn " )
3535 }
3636
3737 func test_mobileFeatures_autoCaptureScreenNames_disabled( ) {
@@ -43,7 +43,7 @@ class CoreBeaconFactoryTests: InstanaTestCase {
4343 let mfs = CoreBeaconFactory ( mfSession)
4444
4545 // Then
46- AssertEqualAndNotNil ( mfs. mobileFeatures!, " \( mobileFeatureCrash ) " )
46+ AssertEqualAndNotNil ( mfs. mobileFeatures!, " c,lm " )
4747 }
4848
4949 func test_map_beacon( ) {
@@ -65,7 +65,7 @@ class CoreBeaconFactoryTests: InstanaTestCase {
6565 AssertEqualAndNotNil ( sut. k, key)
6666 AssertEqualAndNotNil ( sut. ti, " \( beacon. timestamp) " )
6767 AssertEqualAndNotNil ( sut. bid, " \( beacon. id) " )
68- AssertEqualAndNotNil ( sut. uf, mobileFeatureCrash )
68+ AssertEqualAndNotNil ( sut. uf, " c,lm " )
6969 AssertEqualAndNotNil ( sut. bi, " \( InstanaSystemUtils . applicationBundleIdentifier) " )
7070 AssertEqualAndNotNil ( sut. ul, " en " )
7171 AssertEqualAndNotNil ( sut. agv, InstanaSystemUtils . agentVersion)
@@ -99,10 +99,7 @@ class CoreBeaconFactoryTests: InstanaTestCase {
9999 let factory = CoreBeaconFactory ( session)
100100
101101 // When
102- guard let sut = try ? factory. map ( beacon) else {
103- XCTFail ( " Could not map Beacon to CoreBeacon " )
104- return
105- }
102+ let sut = try ! factory. map ( beacon)
106103
107104 // Then
108105 AssertEqualAndNotNil ( sut. v, viewName)
@@ -119,10 +116,7 @@ class CoreBeaconFactoryTests: InstanaTestCase {
119116 let factory = CoreBeaconFactory ( session)
120117
121118 // When
122- guard let sut = try ? factory. map ( beacon) else {
123- XCTFail ( " Could not map Beacon to CoreBeacon " )
124- return
125- }
119+ let sut = try ! factory. map ( beacon)
126120
127121 // Then
128122 AssertEqualAndNotNil ( sut. v, " Background " )
@@ -137,16 +131,112 @@ class CoreBeaconFactoryTests: InstanaTestCase {
137131 let factory = CoreBeaconFactory ( . mock)
138132
139133 // When
140- guard let sut = try ? factory. map ( beacon) else {
141- XCTFail ( " Could not map CustomBeacon to CoreBeacon " )
142- return
143- }
134+ let sut = try ! factory. map ( beacon)
144135
145136 // Then
146137 let internalMetaEventType = sut. im![ internalMetaDataKeyCustom_eventType]
147138 AssertEqualAndNotNil ( internalMetaEventType, eventType)
148139 }
149140
141+ func test_map_ViewChangeBeacon_autoScreenNameCapture1( ) {
142+ // Given
143+ let beacon = ViewChange ( viewName: " testViewName " ,
144+ accessibilityLabel: " testAccessibilityLabelValue " ,
145+ navigationItemTitle: " testNavigationItemTitle " ,
146+ className: " testClassName " , isSwiftUI: true )
147+ let factory = CoreBeaconFactory ( . mock)
148+
149+ // When
150+ let sut = try ! factory. map ( beacon)
151+
152+ // Then
153+ AssertTrue ( sut. im![ " view.clsName " ] == " testClassName " )
154+ AssertTrue ( sut. im![ " view.accLabel " ] == " testAccessibilityLabelValue " )
155+ }
156+
157+ func test_map_ViewChangeBeacon_autoScreenNameCapture2( ) {
158+ // Given
159+ let beacon = ViewChange ( viewName: " testViewName " ,
160+ navigationItemTitle: " testNavigationItemTitle " ,
161+ className: " testClassName " , isSwiftUI: true ,
162+ viewInternalCPMetaMap: [ " testKey " : " testValue " ] )
163+ let factory = CoreBeaconFactory ( . mock)
164+
165+ // When
166+ let sut = try ! factory. map ( beacon)
167+
168+ // Then
169+ AssertTrue ( sut. im![ " view.clsName " ] == " testClassName " )
170+ AssertTrue ( sut. im![ " view.navItemTitle " ] == " testNavigationItemTitle " )
171+ AssertTrue ( sut. im![ " testKey " ] == " testValue " )
172+ }
173+
174+ func test_map_droppedBeacons( ) {
175+ // Given
176+ let beaconsMap : [ String : String ] = [ " droppedBeaconKey " : " droppedBeaconValue " ]
177+ let beacon = DroppedBeacons ( beaconsMap: beaconsMap,
178+ timestamp: Date ( ) . millisecondsSince1970,
179+ viewName: " TestViewName " )
180+ let factory = CoreBeaconFactory ( session)
181+
182+ // When
183+ let sut = try ! factory. map ( beacon)
184+
185+ // Then
186+ AssertTrue ( sut. im![ " droppedBeaconKey " ] == " droppedBeaconValue " )
187+ }
188+
189+ func test_map_performanceBeacon_appLaunch_cold( ) {
190+ // Given
191+ let beacon = PerfAppLaunchBeacon ( appColdStartTime: 12345 )
192+ let factory = CoreBeaconFactory ( . mock)
193+
194+ // When
195+ let sut = try ! factory. map ( beacon)
196+
197+ // Then
198+ AssertTrue ( sut. acs == " 12345 " )
199+ }
200+
201+ func test_map_performanceBeacon_appLaunch_warm( ) {
202+ // Given
203+ let beacon = PerfAppLaunchBeacon ( appWarmStartTime: 678 )
204+ let factory = CoreBeaconFactory ( . mock)
205+
206+ // When
207+ let sut = try ! factory. map ( beacon)
208+
209+ // Then
210+ AssertTrue ( sut. aws == " 678 " )
211+ }
212+
213+ func test_map_performanceBeacon_appLaunch_hot( ) {
214+ // Given
215+ let beacon = PerfAppLaunchBeacon ( appHotStartTime: 9 )
216+ let factory = CoreBeaconFactory ( . mock)
217+
218+ // When
219+ let sut = try ! factory. map ( beacon)
220+
221+ // Then
222+ AssertTrue ( sut. ahs == " 9 " )
223+ }
224+
225+ func test_mobileFeatures( ) {
226+ // Given
227+ let config = InstanaConfiguration . default ( key: " key " , reportingURL: URL ( string: " http://localhost:3000 " ) !,
228+ enableCrashReporting: true , perfConfig: InstanaPerformanceConfig ( enableAppStartTimeReport: true ,
229+ enableAnrReport: true , anrThreshold: 4.0 , enableLowMemoryReport: true ) )
230+ let session = InstanaSession ( configuration: config, propertyHandler: InstanaPropertyHandler ( ) ,
231+ collectionEnabled: true , autoCaptureScreenNames: true , debugAllScreenNames: true ,
232+ dropBeaconReporting: true )
233+ // When
234+ let factory = CoreBeaconFactory ( session)
235+
236+ // Then
237+ AssertTrue ( factory. mobileFeatures! == " c,lm,anr,sn,db " )
238+ }
239+
150240 func test_create_from_string( ) {
151241 // Given
152242 let httpBody = " ab \t 15702 \n av \t unknown-version \n bid \t B5FAF31C-FE37-482E-97F2-20D49C506586 \n bt \t BackendTracingID \n bi \t com.apple.dt.xctest.tool \n cn \t None \n ct \t Wifi \n d \t 1578569955952 \n dma \t Apple \n dmo \t x86_64 \n ec \t 1 \n em \t A client or server connection was severed in the middle of an in-progress load. \n et \t Network Connection Lost \n hm \t POST \n hs \t 200 \n hu \t https://www.example.com \n k \t KEY \n p \t iOS \n osn \t iOS \n osv \t 13.3 \n agv \t 1.0.4 \n ro \t \( String ( InstanaSystemUtils . isDeviceJailbroken) ) \n sid \t 70BED140-D947-4EC7-ADE9-8F1F7C6955D0 \n usi \t 70BED140-D947-4EC7-ADE9-8F1F7C6955D0 \n t \t httpRequest \n ti \t 1578569955952 \n uf \t c \n ul \t en \n vh \t 1792 \n vw \t 828 \n m_meta1 \t V \n m_meta2 \t L \n h_X_K \t V "
0 commit comments