21
21
#import " FEventTester.h"
22
22
#import " FIRDatabaseConfig_Private.h"
23
23
#import " FIRDatabaseQuery_Private.h"
24
- #import " FIRServerValue_unreleased.h"
25
24
#import " FRepo_Private.h"
26
25
#import " FTestHelpers.h"
27
26
#import " FTupleEventTypeString.h"
@@ -2572,7 +2571,7 @@ - (void)testParentDeleteShadowsChildListenersWithNonDefaultQuery {
2572
2571
WAIT_FOR (done);
2573
2572
}
2574
2573
2575
- - (void )testLocalServerTimestampEventuallyButNotImmediatelyMatchServer {
2574
+ - (void )testLocalServerValuesEventuallyButNotImmediatelyMatchServer {
2576
2575
FTupleFirebase *refs = [FTestHelpers getRandomNodePair ];
2577
2576
FIRDatabaseReference *writer = refs.one ;
2578
2577
FIRDatabaseReference *reader = refs.two ;
@@ -2636,7 +2635,7 @@ - (void)testLocalServerTimestampEventuallyButNotImmediatelyMatchServer {
2636
2635
@" Eventual reader and writer priorities should be equal" );
2637
2636
}
2638
2637
2639
- - (void )testServerTimestampSetWithPriorityRemoteEvents {
2638
+ - (void )testServerValuesSetWithPriorityRemoteEvents {
2640
2639
FTupleFirebase *refs = [FTestHelpers getRandomNodePair ];
2641
2640
FIRDatabaseReference *writer = refs.one ;
2642
2641
FIRDatabaseReference *reader = refs.two ;
@@ -2677,7 +2676,7 @@ - (void)testServerTimestampSetWithPriorityRemoteEvents {
2677
2676
}];
2678
2677
}
2679
2678
2680
- - (void )testServerTimestampSetPriorityRemoteEvents {
2679
+ - (void )testServerValuesSetPriorityRemoteEvents {
2681
2680
FTupleFirebase *refs = [FTestHelpers getRandomNodePair ];
2682
2681
FIRDatabaseReference *writer = refs.one ;
2683
2682
FIRDatabaseReference *reader = refs.two ;
@@ -2709,7 +2708,7 @@ - (void)testServerTimestampSetPriorityRemoteEvents {
2709
2708
@" Number should be no more than 2 seconds ago" );
2710
2709
}
2711
2710
2712
- - (void )testServerTimestampUpdateRemoteEvents {
2711
+ - (void )testServerValuesUpdateRemoteEvents {
2713
2712
FTupleFirebase *refs = [FTestHelpers getRandomNodePair ];
2714
2713
FIRDatabaseReference *writer = refs.one ;
2715
2714
FIRDatabaseReference *reader = refs.two ;
@@ -2739,7 +2738,7 @@ - (void)testServerTimestampUpdateRemoteEvents {
2739
2738
@" Number should be no more than 2 seconds ago" );
2740
2739
}
2741
2740
2742
- - (void )testServerTimestampSetWithPriorityLocalEvents {
2741
+ - (void )testServerValuesSetWithPriorityLocalEvents {
2743
2742
FIRDatabaseReference *node = [FTestHelpers getRandomNode ];
2744
2743
2745
2744
NSDictionary *data = @{
@@ -2784,7 +2783,7 @@ - (void)testServerTimestampSetWithPriorityLocalEvents {
2784
2783
}];
2785
2784
}
2786
2785
2787
- - (void )testServerTimestampSetPriorityLocalEvents {
2786
+ - (void )testServerValuesSetPriorityLocalEvents {
2788
2787
FIRDatabaseReference *node = [FTestHelpers getRandomNode ];
2789
2788
2790
2789
__block FIRDataSnapshot *snap = nil ;
@@ -2813,7 +2812,7 @@ - (void)testServerTimestampSetPriorityLocalEvents {
2813
2812
@" Number should be no more than 2 seconds ago" );
2814
2813
}
2815
2814
2816
- - (void )testServerTimestampUpdateLocalEvents {
2815
+ - (void )testServerValuesUpdateLocalEvents {
2817
2816
FIRDatabaseReference *node1 = [FTestHelpers getRandomNode ];
2818
2817
2819
2818
__block FIRDataSnapshot *snap1 = nil ;
@@ -2850,7 +2849,7 @@ - (void)testServerTimestampUpdateLocalEvents {
2850
2849
@" Number should be no more than 2 seconds ago" );
2851
2850
}
2852
2851
2853
- - (void )testServerTimestampTransactionLocalEvents {
2852
+ - (void )testServerValuesTransactionLocalEvents {
2854
2853
FIRDatabaseReference *node = [FTestHelpers getRandomNode ];
2855
2854
2856
2855
__block FIRDataSnapshot *snap = nil ;
@@ -2874,137 +2873,6 @@ - (void)testServerTimestampTransactionLocalEvents {
2874
2873
@" Number should be no more than 2 seconds ago" );
2875
2874
}
2876
2875
2877
- - (void )testServerIncrementOverwritesExistingData {
2878
- FIRDatabaseReference *ref = [FTestHelpers getRandomNode ];
2879
- __block NSMutableArray *found = [NSMutableArray new ];
2880
- NSMutableArray *expected = [NSMutableArray new ];
2881
- [ref observeEventType: FIRDataEventTypeValue
2882
- withBlock: ^(FIRDataSnapshot *snap) {
2883
- [found addObject: snap.value];
2884
- }];
2885
-
2886
- // Going offline ensures that local events get queued up before server events
2887
- [ref.repo interrupt ];
2888
-
2889
- // null + incr
2890
- [ref setValue: [FIRServerValue increment: @1 ]];
2891
- [expected addObject: @1 ];
2892
-
2893
- // number + incr
2894
- [ref setValue: @5 ];
2895
- [ref setValue: [FIRServerValue increment: @1 ]];
2896
- [expected addObject: @5 ];
2897
- [expected addObject: @6 ];
2898
-
2899
- // string + incr
2900
- [ref setValue: @" hello" ];
2901
- [ref setValue: [FIRServerValue increment: @1 ]];
2902
- [expected addObject: @" hello" ];
2903
- [expected addObject: @1 ];
2904
-
2905
- // object + incr
2906
- [ref setValue: @{@" hello" : @" world" }];
2907
- [ref setValue: [FIRServerValue increment: @1 ]];
2908
- [expected addObject: @{@" hello" : @" world" }];
2909
- [expected addObject: @1 ];
2910
-
2911
- [self waitUntil: ^BOOL {
2912
- return found.count == expected.count ;
2913
- }];
2914
- XCTAssertEqualObjects (expected, found);
2915
- [ref.repo resume ];
2916
- }
2917
-
2918
- - (void )testServerIncrementPriority {
2919
- FIRDatabaseReference *ref = [FTestHelpers getRandomNode ];
2920
- __block NSMutableArray *found = [NSMutableArray new ];
2921
- NSMutableArray *expected = [NSMutableArray new ];
2922
- [ref observeEventType: FIRDataEventTypeValue
2923
- withBlock: ^(FIRDataSnapshot *snap) {
2924
- [found addObject: snap.priority];
2925
- }];
2926
-
2927
- // Going offline ensures that local events get queued up before server events
2928
- // Also necessary because increment may not be live yet in the server.
2929
- [ref.repo interrupt ];
2930
-
2931
- // null + incr
2932
- [ref setValue: @0 andPriority: [FIRServerValue increment: @1 ]];
2933
- [expected addObject: @1 ];
2934
- [ref setValue: @0 andPriority: [FIRServerValue increment: @1.5 ]];
2935
- [expected addObject: @2.5 ];
2936
-
2937
- [self waitUntil: ^BOOL {
2938
- return found.count == expected.count ;
2939
- }];
2940
- XCTAssertEqualObjects (expected, found);
2941
- [ref.repo resume ];
2942
- }
2943
-
2944
- - (void )testServerIncrementOverflowAndTypeCoercion {
2945
- FIRDatabaseReference *ref = [FTestHelpers getRandomNode ];
2946
- __block NSMutableArray *found = [NSMutableArray new ];
2947
- __block NSMutableArray *foundTypes = [NSMutableArray new ];
2948
- NSMutableArray *expected = [NSMutableArray new ];
2949
- NSMutableArray *expectedTypes = [NSMutableArray new ];
2950
- [ref observeEventType: FIRDataEventTypeValue
2951
- withBlock: ^(FIRDataSnapshot *snap) {
2952
- [found addObject: snap.value];
2953
- [foundTypes addObject: @([(NSNumber *)snap.value objCType ])];
2954
- }];
2955
-
2956
- // Going offline ensures that local events get queued up before server events
2957
- // Also necessary because increment may not be live yet in the server.
2958
- [ref.repo interrupt ];
2959
-
2960
- // long + double = double
2961
- [ref setValue: @1 ];
2962
- [ref setValue: [FIRServerValue increment: @1.0 ]];
2963
- [expected addObject: @1 ];
2964
- [expected addObject: @2.0 ];
2965
- [expectedTypes addObject: @(@encode (int ))];
2966
- [expectedTypes addObject: @(@encode (double ))];
2967
-
2968
- // double + long = double
2969
- [ref setValue: @1.5 ];
2970
- [ref setValue: [FIRServerValue increment: @1 ]];
2971
- [expected addObject: @1.5 ];
2972
- [expected addObject: @2.5 ];
2973
- [expectedTypes addObject: @(@encode (double ))];
2974
- [expectedTypes addObject: @(@encode (double ))];
2975
-
2976
- // long overflow = double
2977
- [ref setValue: @(1 )];
2978
- [ref setValue: [FIRServerValue increment: @(LONG_MAX)]];
2979
- [expected addObject: @(1 )];
2980
- [expected addObject: @(LONG_MAX + 1.0 )];
2981
- [expectedTypes addObject: @(@encode (int ))];
2982
- [expectedTypes addObject: @(@encode (double ))];
2983
-
2984
- // unsigned long long overflow = double
2985
- [ref setValue: @1 ];
2986
- [ref setValue: [FIRServerValue increment: @((unsigned long long )ULLONG_MAX)]];
2987
- [expected addObject: @1 ];
2988
- [expected addObject: @((double )ULLONG_MAX + 1 )];
2989
- [expectedTypes addObject: @(@encode (int ))];
2990
- [expectedTypes addObject: @(@encode (double ))];
2991
-
2992
- // long underflow = double
2993
- [ref setValue: @(-1 )];
2994
- [ref setValue: [FIRServerValue increment: @(LONG_MIN)]];
2995
- [expected addObject: @(-1 )];
2996
- [expected addObject: @(LONG_MIN - 1.0 )];
2997
- [expectedTypes addObject: @(@encode (int ))];
2998
- [expectedTypes addObject: @(@encode (double ))];
2999
-
3000
- [self waitUntil: ^BOOL {
3001
- return found.count == expected.count && foundTypes.count == expectedTypes.count ;
3002
- }];
3003
- XCTAssertEqualObjects (expectedTypes, foundTypes);
3004
- XCTAssertEqualObjects (expected, found);
3005
- [ref.repo resume ];
3006
- }
3007
-
3008
2876
- (void )testUpdateAfterChildSet {
3009
2877
FIRDatabaseReference *node = [FTestHelpers getRandomNode ];
3010
2878
@@ -3081,7 +2949,7 @@ - (void)testDeltaSyncNoDataUpdatesAfterReconnect {
3081
2949
[FRepoManager disposeRepos: cfg];
3082
2950
}
3083
2951
3084
- - (void )testServerTimestampEventualConsistencyBetweenLocalAndRemote {
2952
+ - (void )testServerValuesEventualConsistencyBetweenLocalAndRemote {
3085
2953
FTupleFirebase *refs = [FTestHelpers getRandomNodePair ];
3086
2954
FIRDatabaseReference *writer = refs.one ;
3087
2955
FIRDatabaseReference *reader = refs.two ;
0 commit comments