@@ -105,11 +105,6 @@ class SessionStartEventTests: XCTestCase {
105
105
expected: MockApplicationInfo . testDeviceModel,
106
106
fieldName: " device_model "
107
107
)
108
- assertEqualProtoString (
109
- proto. application_info. apple_app_info. mcc_mnc,
110
- expected: MockApplicationInfo . testMCCMNC,
111
- fieldName: " mcc_mnc "
112
- )
113
108
114
109
// Ensure we convert the test OS name into the enum.
115
110
XCTAssertEqual (
@@ -215,6 +210,75 @@ class SessionStartEventTests: XCTestCase {
215
210
}
216
211
}
217
212
213
+ func test_newtworkInfo_onlyPresentWhenPerformanceInstalled( ) {
214
+ let mockNetworkInfo = MockNetworkInfo ( )
215
+ mockNetworkInfo. networkType = . mobile
216
+ // Mobile Subtypes are always empty on non-iOS platforms, and
217
+ // Performance doesn't support those platforms anyways
218
+ #if os(iOS) && !targetEnvironment(macCatalyst)
219
+ mockNetworkInfo. mobileSubtype = CTRadioAccessTechnologyHSUPA
220
+ #else
221
+ mockNetworkInfo. mobileSubtype = " "
222
+ #endif
223
+ appInfo. networkInfo = mockNetworkInfo
224
+
225
+ let sessionInfo = SessionInfo (
226
+ sessionId: " session_id " ,
227
+ previousSessionId: " previous_session_id " ,
228
+ dispatchEvents: true
229
+ )
230
+ let event = SessionStartEvent ( sessionInfo: sessionInfo, appInfo: appInfo, time: time)
231
+
232
+ // These fields will not be filled in when Crashlytics is installed
233
+ event. setRestrictedFields ( subscriber: . Crashlytics, appInfo: appInfo)
234
+
235
+ // Expect empty because Crashlytics is installed, but not Perf
236
+ testProtoAndDecodedProto ( sessionEvent: event) { proto in
237
+ XCTAssertEqual (
238
+ event. proto. application_info. apple_app_info. network_connection_info. network_type,
239
+ firebase_appquality_sessions_NetworkConnectionInfo_NetworkType_DUMMY
240
+ )
241
+ XCTAssertEqual (
242
+ event. proto. application_info. apple_app_info. network_connection_info. mobile_subtype,
243
+ firebase_appquality_sessions_NetworkConnectionInfo_MobileSubtype_UNKNOWN_MOBILE_SUBTYPE
244
+ )
245
+ assertEqualProtoString (
246
+ proto. application_info. apple_app_info. mcc_mnc,
247
+ expected: " " ,
248
+ fieldName: " mcc_mnc "
249
+ )
250
+ }
251
+
252
+ // These fields will only be filled in when the Perf SDK is installed
253
+ event. setRestrictedFields ( subscriber: . Performance, appInfo: appInfo)
254
+
255
+ // Now the field should be set with the real thing
256
+ testProtoAndDecodedProto ( sessionEvent: event) { proto in
257
+ XCTAssertEqual (
258
+ event. proto. application_info. apple_app_info. network_connection_info. network_type,
259
+ firebase_appquality_sessions_NetworkConnectionInfo_NetworkType_MOBILE
260
+ )
261
+ // Mobile Subtypes are always empty on non-iOS platforms, and
262
+ // Performance doesn't support those platforms anyways
263
+ #if os(iOS) && !targetEnvironment(macCatalyst)
264
+ XCTAssertEqual (
265
+ event. proto. application_info. apple_app_info. network_connection_info. mobile_subtype,
266
+ firebase_appquality_sessions_NetworkConnectionInfo_MobileSubtype_HSUPA
267
+ )
268
+ #else
269
+ XCTAssertEqual (
270
+ event. proto. application_info. apple_app_info. network_connection_info. mobile_subtype,
271
+ firebase_appquality_sessions_NetworkConnectionInfo_MobileSubtype_UNKNOWN_MOBILE_SUBTYPE
272
+ )
273
+ #endif
274
+ assertEqualProtoString (
275
+ proto. application_info. apple_app_info. mcc_mnc,
276
+ expected: MockApplicationInfo . testMCCMNC,
277
+ fieldName: " mcc_mnc "
278
+ )
279
+ }
280
+ }
281
+
218
282
func test_convertNetworkType_convertsCorrectly( ) {
219
283
let expectations : [ (
220
284
given: GULNetworkType ,
@@ -249,6 +313,9 @@ class SessionStartEventTests: XCTestCase {
249
313
)
250
314
let event = SessionStartEvent ( sessionInfo: sessionInfo, appInfo: appInfo, time: time)
251
315
316
+ // These fields will only be filled in when the Perf SDK is installed
317
+ event. setRestrictedFields ( subscriber: . Performance, appInfo: appInfo)
318
+
252
319
testProtoAndDecodedProto ( sessionEvent: event) { proto in
253
320
XCTAssertEqual (
254
321
event. proto. application_info. apple_app_info. network_connection_info. network_type,
@@ -331,6 +398,9 @@ class SessionStartEventTests: XCTestCase {
331
398
)
332
399
let event = SessionStartEvent ( sessionInfo: sessionInfo, appInfo: appInfo, time: time)
333
400
401
+ // These fields will only be filled in when the Perf SDK is installed
402
+ event. setRestrictedFields ( subscriber: . Performance, appInfo: appInfo)
403
+
334
404
testProtoAndDecodedProto ( sessionEvent: event) { proto in
335
405
XCTAssertEqual (
336
406
event. proto. application_info. apple_app_info. network_connection_info. mobile_subtype,
@@ -422,6 +492,9 @@ class SessionStartEventTests: XCTestCase {
422
492
)
423
493
let event = SessionStartEvent ( sessionInfo: sessionInfo, appInfo: appInfo, time: time)
424
494
495
+ // These fields will only be filled in when the Perf SDK is installed
496
+ event. setRestrictedFields ( subscriber: . Performance, appInfo: appInfo)
497
+
425
498
testProtoAndDecodedProto ( sessionEvent: event) { proto in
426
499
XCTAssertEqual (
427
500
event. proto. application_info. apple_app_info. network_connection_info. mobile_subtype,
0 commit comments