@@ -259,7 +259,10 @@ - (void)testFetchConfigsSuccessfully {
259
259
^void (FIRRemoteConfigFetchStatus status, NSError *error) {
260
260
XCTAssertEqual (_configInstances[i].lastFetchStatus , FIRRemoteConfigFetchStatusSuccess);
261
261
XCTAssertNil (error);
262
+ #pragma clang diagnostic push
263
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
262
264
XCTAssertTrue ([_configInstances[i] activateFetched ]);
265
+ #pragma clang diagnostic pop
263
266
NSString *key1 = [NSString stringWithFormat: @" key1-%d " , i];
264
267
NSString *key2 = [NSString stringWithFormat: @" key2-%d " , i];
265
268
NSString *value1 = [NSString stringWithFormat: @" value1-%d " , i];
@@ -388,7 +391,10 @@ - (void)testEnumeratingConfigResults {
388
391
^void (FIRRemoteConfigFetchStatus status, NSError *error) {
389
392
XCTAssertEqual (_configInstances[i].lastFetchStatus , FIRRemoteConfigFetchStatusSuccess);
390
393
XCTAssertNil (error);
394
+ #pragma clang diagnostic push
395
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
391
396
XCTAssertTrue ([_configInstances[i] activateFetched ]);
397
+ #pragma clang diagnostic pop
392
398
NSString *key5 = [NSString stringWithFormat: @" key5-%d " , i];
393
399
NSString *key19 = [NSString stringWithFormat: @" key19-%d " , i];
394
400
NSString *value5 = [NSString stringWithFormat: @" value5-%d " , i];
@@ -515,7 +521,8 @@ - (void)testFetchConfigsFailed {
515
521
configSettings: settings
516
522
configExperiment: nil ];
517
523
}
518
-
524
+ #pragma clang diagnostic push
525
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
519
526
// Make the fetch calls for all instances.
520
527
NSMutableArray <XCTestExpectation *> *expectations =
521
528
[[NSMutableArray alloc ] initWithCapacity: RCNTestRCNumTotalInstances];
@@ -601,7 +608,6 @@ - (void)testFetchConfigWithDefaultSets {
601
608
NSString *key0 = [NSString stringWithFormat: @" key0-%d " , i];
602
609
NSString *value1 = [NSString stringWithFormat: @" value1-%d " , i];
603
610
NSString *value2 = [NSString stringWithFormat: @" value2-%d " , i];
604
- NSString *value0 = [NSString stringWithFormat: @" value0-%d " , i];
605
611
606
612
XCTestExpectation *fetchConfigsExpectation =
607
613
[self expectationWithDescription: @" Test fetch configs with defaults set." ];
@@ -615,15 +621,20 @@ - (void)testFetchConfigWithDefaultSets {
615
621
XCTAssertNil (error);
616
622
XCTAssertEqualObjects (_configInstances[i][key1].stringValue , @" default key1" );
617
623
XCTAssertEqual (_configInstances[i][key1].source , FIRRemoteConfigSourceDefault);
624
+ #pragma clang diagnostic push
625
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
618
626
XCTAssertTrue ([_configInstances[i] activateFetched ]);
627
+ #pragma clang diagnostic pop
619
628
XCTAssertEqualObjects (_configInstances[i][key1].stringValue , value1);
620
629
XCTAssertEqual (_configInstances[i][key1].source , FIRRemoteConfigSourceRemote);
621
630
XCTAssertEqualObjects ([_configInstances[i] defaultValueForKey: key1].stringValue ,
622
631
@" default key1" );
623
632
XCTAssertEqualObjects (_configInstances[i][key2].stringValue , value2);
624
633
XCTAssertEqualObjects (_configInstances[i][key0].stringValue , @" value0-0" );
634
+ #pragma clang diagnostic push
635
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
625
636
XCTAssertNil ([_configInstances[i] defaultValueForKey: nil namespace: nil ]);
626
-
637
+ # pragma clang diagnostic pop
627
638
OCMVerify ([_configInstances[i] objectForKeyedSubscript: key1]);
628
639
XCTAssertEqual (status, FIRRemoteConfigFetchStatusSuccess,
629
640
@" Callback of first successful config "
@@ -828,11 +839,24 @@ - (void)testInvalidKeyOrNamespace {
828
839
}
829
840
}
830
841
842
+ // Remote Config converts UTC times in the plists to local times. This utility function makes it
843
+ // possible to check the times when running the tests in any timezone.
844
+ static NSString *UTCToLocal (NSString *utcTime) {
845
+ // Create a UTC dateFormatter.
846
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc ] init ];
847
+ [dateFormatter setDateFormat: @" yyyy-MM-dd HH:mm:ss" ];
848
+ [dateFormatter setTimeZone: [NSTimeZone timeZoneWithAbbreviation: @" UTC" ]];
849
+ NSDate *date = [dateFormatter dateFromString: utcTime];
850
+ [dateFormatter setTimeZone: [NSTimeZone localTimeZone ]];
851
+ return [dateFormatter stringFromDate: date];
852
+ }
853
+
831
854
- (void )testSetDefaultsFromPlist {
832
855
for (int i = 0 ; i < RCNTestRCNumTotalInstances; i++) {
833
- [_configInstances[i] setDefaultsFromPlistFileName: @" Defaults-testInfo" ];
856
+ FIRRemoteConfig *config = _configInstances[i];
857
+ [config setDefaultsFromPlistFileName: @" Defaults-testInfo" ];
834
858
XCTAssertEqualObjects (_configInstances[i][@" lastCheckTime" ].stringValue ,
835
- @" 2016-02-28 10 :33:31" );
859
+ UTCToLocal ( @" 2016-02-28 18 :33:31" ) );
836
860
XCTAssertEqual (_configInstances[i][@" isPaidUser" ].boolValue , YES );
837
861
XCTAssertEqualObjects (_configInstances[i][@" dataValue" ].stringValue , @" 2.4" );
838
862
XCTAssertEqualObjects (_configInstances[i][@" New item" ].numberValue , @(2.4 ));
@@ -844,7 +868,7 @@ - (void)testSetDefaultsFromPlist {
844
868
// If given a wrong file name, the default will not be set and kept as previous results.
845
869
[_configInstances[i] setDefaultsFromPlistFileName: @" " ];
846
870
XCTAssertEqualObjects (_configInstances[i][@" lastCheckTime" ].stringValue ,
847
- @" 2016-02-28 10 :33:31" );
871
+ UTCToLocal ( @" 2016-02-28 18 :33:31" ) );
848
872
[_configInstances[i] setDefaultsFromPlistFileName: @" non-existed_file" ];
849
873
XCTAssertEqualObjects (_configInstances[i][@" dataValue" ].stringValue , @" 2.4" );
850
874
[_configInstances[i] setDefaultsFromPlistFileName: nil namespace: nil ];
@@ -862,7 +886,7 @@ - (void)testSetDefaultsAndNamespaceFromPlist {
862
886
XCTAssertEqualObjects ([_configInstances[i] configValueForKey: @" lastCheckTime"
863
887
namespace: RCNTestsPerfNamespace]
864
888
.stringValue ,
865
- @" 2016-02-28 10 :33:31" );
889
+ UTCToLocal ( @" 2016-02-28 18 :33:31" ) );
866
890
XCTAssertEqual ([_configInstances[i] configValueForKey: @" isPaidUser"
867
891
namespace: RCNTestsPerfNamespace]
868
892
.boolValue ,
@@ -890,7 +914,7 @@ - (void)testSetDefaultsAndNamespaceFromPlist {
890
914
} else {
891
915
[_configInstances[i] setDefaultsFromPlistFileName: @" Defaults-testInfo" ];
892
916
XCTAssertEqualObjects ([_configInstances[i] configValueForKey: @" lastCheckTime" ].stringValue ,
893
- @" 2016-02-28 10 :33:31" );
917
+ UTCToLocal ( @" 2016-02-28 18 :33:31" ) );
894
918
XCTAssertEqual ([_configInstances[i] configValueForKey: @" isPaidUser" ].boolValue , YES );
895
919
XCTAssertEqualObjects ([_configInstances[i] configValueForKey: @" dataValue" ].stringValue ,
896
920
@" 2.4" );
@@ -991,6 +1015,8 @@ - (void)testAllKeysWithPrefix {
991
1015
XCTAssertEqual (status, FIRRemoteConfigFetchStatusSuccess);
992
1016
XCTAssertNil (error);
993
1017
NSLog (@" Testing _configInstances %d " , i);
1018
+ #pragma clang diagnostic push
1019
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
994
1020
XCTAssertTrue ([_configInstances[i] activateFetched ]);
995
1021
996
1022
// Test keysWithPrefix:namespace: method.
@@ -1010,6 +1036,7 @@ - (void)testAllKeysWithPrefix {
1010
1036
1011
1037
XCTAssertNotNil ([_configInstances[i] keysWithPrefix: nil namespace: nil ]);
1012
1038
XCTAssertEqual ([_configInstances[i] keysWithPrefix: nil namespace: nil ].count , 0 );
1039
+ #pragma clang diagnostic pop
1013
1040
1014
1041
// Test keysWithPrefix: method.
1015
1042
XCTAssertEqual ([_configInstances[i] keysWithPrefix: @" key1" ].count , 12 );
@@ -1031,6 +1058,8 @@ - (void)testAllKeysWithPrefix {
1031
1058
1032
1059
- (void )testSetDeveloperModeConfigSetting {
1033
1060
for (int i = 0 ; i < RCNTestRCNumTotalInstances; i++) {
1061
+ #pragma clang diagnostic push
1062
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
1034
1063
FIRRemoteConfigSettings *settings =
1035
1064
[[FIRRemoteConfigSettings alloc ] initWithDeveloperModeEnabled: YES ];
1036
1065
[_configInstances[i] setConfigSettings: settings];
@@ -1039,6 +1068,7 @@ - (void)testSetDeveloperModeConfigSetting {
1039
1068
settings = [[FIRRemoteConfigSettings alloc ] initWithDeveloperModeEnabled: NO ];
1040
1069
[_configInstances[i] setConfigSettings: settings];
1041
1070
XCTAssertFalse ([_configInstances[i] configSettings ].isDeveloperModeEnabled );
1071
+ #pragma clang diagnostic pop
1042
1072
}
1043
1073
}
1044
1074
0 commit comments