@@ -81,9 +81,9 @@ + (NSUserDefaults *)sharedUserDefaultsForBundleIdentifier:(NSString *)bundleIden
81
81
82
82
typedef NS_ENUM (NSInteger , RCNTestRCInstance) {
83
83
RCNTestRCInstanceDefault,
84
- RCNTestRCNumTotalInstances, // TODO(mandard): Remove once OCMock issue is resolved (#4877).
85
84
RCNTestRCInstanceSecondNamespace,
86
85
RCNTestRCInstanceSecondApp,
86
+ RCNTestRCNumTotalInstances
87
87
};
88
88
89
89
@interface RCNRemoteConfigTest : XCTestCase {
@@ -463,6 +463,54 @@ - (void)testEnumeratingConfigResults {
463
463
}];
464
464
}
465
465
466
+ - (void )testFetch3pNamespaceUpdatesExperiments {
467
+ [[_experimentMock expect ] updateExperimentsWithResponse: [OCMArg any ]];
468
+
469
+ XCTestExpectation *expectation = [self
470
+ expectationWithDescription:
471
+ [NSString
472
+ stringWithFormat: @" Fetch call for 'firebase' namespace updates experiment data" ]];
473
+ XCTAssertEqual (_configInstances[RCNTestRCInstanceDefault].lastFetchStatus ,
474
+ FIRRemoteConfigFetchStatusNoFetchYet);
475
+ FIRRemoteConfigFetchCompletion fetchCompletion =
476
+ ^void (FIRRemoteConfigFetchStatus status, NSError *error) {
477
+ XCTAssertEqual (self->_configInstances [RCNTestRCInstanceDefault].lastFetchStatus ,
478
+ FIRRemoteConfigFetchStatusSuccess);
479
+ XCTAssertNil (error);
480
+ [expectation fulfill ];
481
+ };
482
+ [_configInstances[RCNTestRCInstanceDefault] fetchWithExpirationDuration: 43200
483
+ completionHandler: fetchCompletion];
484
+ [self waitForExpectationsWithTimeout: _expectationTimeout
485
+ handler: ^(NSError *error) {
486
+ XCTAssertNil (error);
487
+ }];
488
+ }
489
+
490
+ - (void )testFetchOtherNamespaceDoesntUpdateExperiments {
491
+ [[_experimentMock reject ] updateExperimentsWithResponse: [OCMArg any ]];
492
+
493
+ XCTestExpectation *expectation =
494
+ [self expectationWithDescription:
495
+ [NSString stringWithFormat: @" Fetch call for namespace other than 'firebase' "
496
+ @" doesn't update experiment data" ]];
497
+ XCTAssertEqual (_configInstances[RCNTestRCInstanceSecondNamespace].lastFetchStatus ,
498
+ FIRRemoteConfigFetchStatusNoFetchYet);
499
+ FIRRemoteConfigFetchCompletion fetchCompletion =
500
+ ^void (FIRRemoteConfigFetchStatus status, NSError *error) {
501
+ XCTAssertEqual (self->_configInstances [RCNTestRCInstanceSecondNamespace].lastFetchStatus ,
502
+ FIRRemoteConfigFetchStatusSuccess);
503
+ XCTAssertNil (error);
504
+ [expectation fulfill ];
505
+ };
506
+ [_configInstances[RCNTestRCInstanceSecondNamespace] fetchWithExpirationDuration: 43200
507
+ completionHandler: fetchCompletion];
508
+ [self waitForExpectationsWithTimeout: _expectationTimeout
509
+ handler: ^(NSError *error) {
510
+ XCTAssertNil (error);
511
+ }];
512
+ }
513
+
466
514
- (void )testFetchConfigsFailed {
467
515
// Override the setup values to return back an error status.
468
516
RCNConfigContent *configContent = [[RCNConfigContent alloc ] initWithDBManager: _DBManager];
@@ -1323,10 +1371,12 @@ - (FIROptions *)firstAppOptions {
1323
1371
}
1324
1372
1325
1373
- (FIROptions *)secondAppOptions {
1326
- FIROptions *options =
1327
- [[FIROptions alloc ] initWithContentsOfFile: [[NSBundle bundleForClass: [self class ]]
1328
- pathForResource: @" SecondApp-GoogleService-Info"
1329
- ofType: @" plist" ]];
1374
+ NSBundle *bundle = [NSBundle bundleForClass: [self class ]];
1375
+ #if SWIFT_PACKAGE
1376
+ bundle = Firebase_RemoteConfigUnit_SWIFTPM_MODULE_BUNDLE ();
1377
+ #endif
1378
+ NSString *plistPath = [bundle pathForResource: @" SecondApp-GoogleService-Info" ofType: @" plist" ];
1379
+ FIROptions *options = [[FIROptions alloc ] initWithContentsOfFile: plistPath];
1330
1380
XCTAssertNotNil (options);
1331
1381
return options;
1332
1382
}
0 commit comments