@@ -83,7 +83,6 @@ - (void)testStoreEvent {
83
83
@autoreleasepool {
84
84
GDTEvent *event = [[GDTEvent alloc ] initWithMappingID: @" 404" target: target];
85
85
event.dataObjectTransportBytes = [@" testString" dataUsingEncoding: NSUTF8StringEncoding];
86
- event.clockSnapshot = [GDTClock snapshot ];
87
86
XCTAssertNoThrow ([[GDTStorage sharedInstance ] storeEvent: event]);
88
87
}
89
88
dispatch_sync ([GDTStorage sharedInstance ].storageQueue , ^{
@@ -104,7 +103,6 @@ - (void)testRemoveEvent {
104
103
@autoreleasepool {
105
104
GDTEvent *event = [[GDTEvent alloc ] initWithMappingID: @" 404" target: target];
106
105
event.dataObjectTransportBytes = [@" testString" dataUsingEncoding: NSUTF8StringEncoding];
107
- event.clockSnapshot = [GDTClock snapshot ];
108
106
XCTAssertNoThrow ([[GDTStorage sharedInstance ] storeEvent: event]);
109
107
}
110
108
__block NSURL *eventFile;
@@ -225,7 +223,7 @@ - (void)testEventDeallocationIsEnforced {
225
223
GDTEvent *event = [[GDTEvent alloc ] initWithMappingID: @" 404" target: target];
226
224
weakEvent = event;
227
225
event.dataObjectTransportBytes = [@" testString" dataUsingEncoding: NSUTF8StringEncoding];
228
- event. clockSnapshot = [GDTClock snapshot ];
226
+
229
227
// Store the event and wait for the expectation.
230
228
[[GDTStorage sharedInstance ] storeEvent: event];
231
229
GDTDataFuture *dataFuture =
@@ -258,75 +256,38 @@ - (void)testEventDeallocationIsEnforced {
258
256
- (void )testNSSecureCoding {
259
257
XCTAssertTrue ([GDTStorage supportsSecureCoding ]);
260
258
GDTEvent *event = [[GDTEvent alloc ] initWithMappingID: @" 404" target: target];
261
- event.clockSnapshot = [GDTClock snapshot ];
262
259
event.dataObjectTransportBytes = [@" testString" dataUsingEncoding: NSUTF8StringEncoding];
263
260
XCTAssertNoThrow ([[GDTStorage sharedInstance ] storeEvent: event]);
264
261
event = nil ;
265
- NSData *storageData;
266
- if (@available (macOS 10.13 , iOS 11.0 , tvOS 11.0 , *)) {
267
- storageData = [NSKeyedArchiver archivedDataWithRootObject: [GDTStorage sharedInstance ]
268
- requiringSecureCoding: YES
269
- error: nil ];
270
- } else {
271
- #if !defined(TARGET_OS_MACCATALYST)
272
- storageData = [NSKeyedArchiver archivedDataWithRootObject: [GDTStorage sharedInstance ]];
273
- #endif
274
- }
262
+ NSData *storageData = [NSKeyedArchiver archivedDataWithRootObject: [GDTStorage sharedInstance ]];
275
263
dispatch_sync ([GDTStorage sharedInstance ].storageQueue , ^{
276
264
XCTAssertNotNil ([[GDTStorage sharedInstance ].storedEvents lastObject ]);
277
265
});
278
266
[[GDTStorage sharedInstance ] removeEvents: [GDTStorage sharedInstance ].storedEvents.set];
279
267
dispatch_sync ([GDTStorage sharedInstance ].storageQueue , ^{
280
268
XCTAssertNil ([[GDTStorage sharedInstance ].storedEvents lastObject ]);
281
269
});
282
- GDTStorage *unarchivedStorage;
283
- NSError *error;
284
- if (@available (macOS 10.13 , iOS 11.0 , tvOS 11.0 , *)) {
285
- unarchivedStorage = [NSKeyedUnarchiver unarchivedObjectOfClass: [GDTStorage class ]
286
- fromData: storageData
287
- error: &error];
288
- } else {
289
- #if !defined(TARGET_OS_MACCATALYST)
290
- unarchivedStorage = [NSKeyedUnarchiver unarchiveObjectWithData: storageData];
291
- #endif
292
- }
270
+
271
+ GDTStorage *unarchivedStorage = [NSKeyedUnarchiver unarchiveObjectWithData: storageData];
293
272
XCTAssertNotNil ([unarchivedStorage.storedEvents lastObject ]);
294
273
}
295
274
296
275
/* * Tests encoding and decoding the storage singleton when calling -sharedInstance. */
297
276
- (void )testNSSecureCodingWithSharedInstance {
298
277
GDTEvent *event = [[GDTEvent alloc ] initWithMappingID: @" 404" target: target];
299
278
event.dataObjectTransportBytes = [@" testString" dataUsingEncoding: NSUTF8StringEncoding];
300
- event.clockSnapshot = [GDTClock snapshot ];
301
279
XCTAssertNoThrow ([[GDTStorage sharedInstance ] storeEvent: event]);
302
280
event = nil ;
303
- NSData *storageData;
304
- if (@available (macOS 10.13 , iOS 11.0 , tvOS 11.0 , *)) {
305
- storageData = [NSKeyedArchiver archivedDataWithRootObject: [GDTStorage sharedInstance ]
306
- requiringSecureCoding: YES
307
- error: nil ];
308
- } else {
309
- #if !defined(TARGET_OS_MACCATALYST)
310
- storageData = [NSKeyedArchiver archivedDataWithRootObject: [GDTStorage sharedInstance ]];
311
- #endif
312
- }
281
+ NSData *storageData = [NSKeyedArchiver archivedDataWithRootObject: [GDTStorage sharedInstance ]];
313
282
dispatch_sync ([GDTStorage sharedInstance ].storageQueue , ^{
314
283
XCTAssertNotNil ([[GDTStorage sharedInstance ].storedEvents lastObject ]);
315
284
});
316
285
[[GDTStorage sharedInstance ] removeEvents: [GDTStorage sharedInstance ].storedEvents.set];
317
286
dispatch_sync ([GDTStorage sharedInstance ].storageQueue , ^{
318
287
XCTAssertNil ([[GDTStorage sharedInstance ].storedEvents lastObject ]);
319
288
});
320
- GDTStorage *unarchivedStorage;
321
- if (@available (macOS 10.13 , iOS 11.0 , tvOS 11.0 , *)) {
322
- unarchivedStorage = [NSKeyedUnarchiver unarchivedObjectOfClass: [GDTStorage class ]
323
- fromData: storageData
324
- error: nil ];
325
- } else {
326
- #if !defined(TARGET_OS_MACCATALYST)
327
- unarchivedStorage = [NSKeyedUnarchiver unarchiveObjectWithData: storageData];
328
- #endif
329
- }
289
+
290
+ GDTStorage *unarchivedStorage = [NSKeyedUnarchiver unarchiveObjectWithData: storageData];
330
291
XCTAssertNotNil ([unarchivedStorage.storedEvents lastObject ]);
331
292
}
332
293
@@ -337,7 +298,6 @@ - (void)testQoSTierFast {
337
298
GDTEvent *event = [[GDTEvent alloc ] initWithMappingID: @" 404" target: target];
338
299
event.dataObjectTransportBytes = [@" testString" dataUsingEncoding: NSUTF8StringEncoding];
339
300
event.qosTier = GDTEventQoSFast;
340
- event.clockSnapshot = [GDTClock snapshot ];
341
301
XCTAssertFalse (self.uploaderFake .forceUploadCalled );
342
302
XCTAssertNoThrow ([[GDTStorage sharedInstance ] storeEvent: event]);
343
303
}
0 commit comments