@@ -276,9 +276,6 @@ extension EventDispatcherTests_Batch {
276
276
}
277
277
278
278
func testEventDiscardedWhenQueueIfFull( ) {
279
- // this tests timer-based dispatch, available for iOS 10+
280
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
281
-
282
279
eventDispatcher. maxQueueSize = 100
283
280
284
281
// illegal config batchSize cannot be bigger than maxQueueSize. just for testing
@@ -336,9 +333,6 @@ extension EventDispatcherTests_Batch {
336
333
extension EventDispatcherTests_Batch {
337
334
338
335
func testFlushEvents( ) {
339
- // this tests timer-based dispatch, available for iOS 10+
340
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
341
-
342
336
XCTAssert ( eventDispatcher. batchSize == 10 )
343
337
344
338
dispatchMultipleEvents ( [ ( kUrlA, batchEventA) ,
@@ -369,9 +363,6 @@ extension EventDispatcherTests_Batch {
369
363
}
370
364
371
365
func testFlushEventsWhenBatchFails( ) {
372
- // this tests timer-based dispatch, available for iOS 10+
373
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
374
-
375
366
XCTAssert ( eventDispatcher. batchSize == 10 )
376
367
377
368
dispatchMultipleEvents ( [ ( kUrlA, batchEventA) ,
@@ -416,9 +407,6 @@ extension EventDispatcherTests_Batch {
416
407
}
417
408
418
409
func testFlushEventsWhenBatchFailsWithInvalidEvent( ) {
419
- // this tests timer-based dispatch, available for iOS 10+
420
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
421
-
422
410
XCTAssert ( eventDispatcher. batchSize == 10 )
423
411
424
412
eventDispatcher. dispatchEvent ( event: makeEventForDispatch ( url: kUrlA, event: batchEventA) , completionHandler: nil )
@@ -467,9 +455,6 @@ extension EventDispatcherTests_Batch {
467
455
468
456
469
457
func testFlushEventsWhenSendEventFailsAndRecovers( ) {
470
- // this tests timer-based dispatch, available for iOS 10+
471
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
472
-
473
458
// (1) error injected - all event send fails
474
459
475
460
eventDispatcher. forceError = true
@@ -517,9 +502,6 @@ extension EventDispatcherTests_Batch {
517
502
extension EventDispatcherTests_Batch {
518
503
519
504
func testEventDispatchedOnTimer( ) {
520
- // this tests timer-based dispatch, available for iOS 10+
521
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
522
-
523
505
eventDispatcher. timerInterval = 2
524
506
525
507
eventDispatcher. exp = expectation ( description: " timer " )
@@ -545,9 +527,6 @@ extension EventDispatcherTests_Batch {
545
527
}
546
528
547
529
func testEventShouldNotBeSentUntilTimer( ) {
548
- // this tests timer-based dispatch, available for iOS 10+
549
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
550
-
551
530
eventDispatcher. timerInterval = 99999
552
531
553
532
eventDispatcher. exp = expectation ( description: " timer " )
@@ -562,9 +541,6 @@ extension EventDispatcherTests_Batch {
562
541
}
563
542
564
543
func testEventDispatchedOnTimer_ZeroInterval( ) {
565
- // this tests timer-based dispatch, available for iOS 10+
566
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
567
-
568
544
// zero-interval means that all events are sent out immediately
569
545
eventDispatcher. timerInterval = 0
570
546
@@ -599,9 +575,6 @@ extension EventDispatcherTests_Batch {
599
575
}
600
576
601
577
func testEventBatchedOnTimer_CheckNoRedundantSend( ) {
602
- // this tests timer-based dispatch, available for iOS 10+
603
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
604
-
605
578
eventDispatcher. timerInterval = 3
606
579
607
580
eventDispatcher. exp = expectation ( description: " timer " )
@@ -622,9 +595,6 @@ extension EventDispatcherTests_Batch {
622
595
}
623
596
624
597
func testEventBatchedAndErrorRecoveredOnTimer( ) {
625
- // this tests timer-based dispatch, available for iOS 10+
626
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
627
-
628
598
eventDispatcher. timerInterval = 5
629
599
630
600
// (1) inject error
@@ -658,9 +628,6 @@ extension EventDispatcherTests_Batch {
658
628
extension EventDispatcherTests_Batch {
659
629
660
630
func testEventsFlushedOnEventQueueSizeHit( ) {
661
- // this tests timer-based dispatch, available for iOS 10+
662
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
663
-
664
631
eventDispatcher. batchSize = 3
665
632
eventDispatcher. timerInterval = 99999 // timer is big, won't fire
666
633
@@ -686,9 +653,6 @@ extension EventDispatcherTests_Batch {
686
653
}
687
654
688
655
func testEventsFlushedOnRevisionChange( ) {
689
- // this tests timer-based dispatch, available for iOS 10+
690
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
691
-
692
656
self . eventDispatcher = TestEventDispatcher ( eventFileName: uniqueFileName, removeDatafileObserver: false )
693
657
694
658
eventDispatcher. batchSize = 1000 // big, won't flush
@@ -724,9 +688,6 @@ extension EventDispatcherTests_Batch {
724
688
}
725
689
726
690
func testEventsFlushedOnProjectIdChange( ) {
727
- // this tests timer-based dispatch, available for iOS 10+
728
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
729
-
730
691
self . eventDispatcher = TestEventDispatcher ( eventFileName: uniqueFileName, removeDatafileObserver: false )
731
692
732
693
eventDispatcher. batchSize = 1000 // big, won't flush
@@ -762,9 +723,6 @@ extension EventDispatcherTests_Batch {
762
723
}
763
724
764
725
func testEventsNotFlushedOnOtherDatafileChanges( ) {
765
- // this tests timer-based dispatch, available for iOS 10+
766
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
767
-
768
726
self . eventDispatcher = TestEventDispatcher ( eventFileName: uniqueFileName, removeDatafileObserver: false )
769
727
770
728
eventDispatcher. batchSize = 1000 // big, won't flush
@@ -801,9 +759,6 @@ extension EventDispatcherTests_Batch {
801
759
}
802
760
803
761
func testEventsNotFlushedOnFirstDatafileLoad( ) {
804
- // this tests timer-based dispatch, available for iOS 10+
805
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
806
-
807
762
self . eventDispatcher = TestEventDispatcher ( eventFileName: uniqueFileName, removeDatafileObserver: false )
808
763
809
764
eventDispatcher. batchSize = 1000 // big, won't flush
@@ -946,60 +901,11 @@ extension EventDispatcherTests_Batch {
946
901
947
902
}
948
903
949
- // MARK: - iOS9 Devices
950
-
951
- extension EventDispatcherTests_Batch {
952
-
953
- func testFlushEventsForIOS9Only( ) {
954
- // this tests iOS9 (no-timer)
955
- if #available( iOS 10 . 0 , tvOS 10 . 0 , * ) { return }
956
-
957
- dispatchMultipleEvents ( [ ( kUrlA, batchEventA) ] )
958
-
959
- eventDispatcher. dispatcher. sync { }
960
-
961
- XCTAssertEqual ( eventDispatcher. sendRequestedEvents. count, 1 )
962
- let batch = eventDispatcher. sendRequestedEvents [ 0 ]
963
- let batchedEvents = try ! JSONDecoder ( ) . decode ( BatchEvent . self, from: batch. body)
964
- XCTAssertEqual ( batch. url. absoluteString, kUrlA)
965
- XCTAssertEqual ( batchedEvents. revision, kRevisionA)
966
- XCTAssertEqual ( batchedEvents. accountID, kAccountId)
967
- XCTAssertEqual ( batchedEvents. projectID, kProjectIdA)
968
- XCTAssertEqual ( batchedEvents. clientVersion, kClientVersion)
969
- XCTAssertEqual ( batchedEvents. clientName, kClientName)
970
- XCTAssertEqual ( batchedEvents. anonymizeIP, kAnonymizeIP)
971
- XCTAssertEqual ( batchedEvents. enrichDecisions, kEnrichDecision)
972
- XCTAssertEqual ( batchedEvents. visitors [ 0 ] , visitorA)
973
- XCTAssertEqual ( eventDispatcher. dataStore. count, 0 )
974
- }
975
-
976
- func testFlushEventsForIOS9Only_ZeroInterval( ) {
977
- // this tests iOS9 (no-timer)
978
- if #available( iOS 10 . 0 , tvOS 10 . 0 , * ) { return }
979
-
980
- eventDispatcher. timerInterval = 0
981
-
982
- dispatchMultipleEvents ( [ ( kUrlA, batchEventA) ] )
983
- eventDispatcher. dispatcher. sync { }
984
-
985
- XCTAssertEqual ( eventDispatcher. sendRequestedEvents. count, 1 )
986
- let batch = eventDispatcher. sendRequestedEvents [ 0 ]
987
- let batchedEvents = try ! JSONDecoder ( ) . decode ( BatchEvent . self, from: batch. body)
988
- XCTAssertEqual ( batch. url. absoluteString, kUrlA)
989
- XCTAssertEqual ( batchedEvents. revision, kRevisionA)
990
- XCTAssertEqual ( eventDispatcher. dataStore. count, 0 )
991
- }
992
-
993
- }
994
-
995
904
// MARK: - OptimizleyClient: Close()
996
905
997
906
extension EventDispatcherTests_Batch {
998
907
999
908
func testCloseForOptimizleyClient( ) {
1000
- // this tests timer-based dispatch, available for iOS 10+
1001
- guard #available( iOS 10 . 0 , tvOS 10 . 0 , * ) else { return }
1002
-
1003
909
self . eventDispatcher = TestEventDispatcher ( eventFileName: uniqueFileName, removeDatafileObserver: false )
1004
910
1005
911
eventDispatcher. batchSize = 1000 // big, won't flush
0 commit comments