Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style and changelog
  • Loading branch information
paulb777 committed May 21, 2020
commit 0809e79b79c928d4f8d989f4aaaa4906dac4f422
1 change: 1 addition & 0 deletions FirebaseRemoteConfig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased
- [changed] Updated `fetchAndActivateWithCompletionHandler:` implementation to activate asynchronously. (#5617)
- [fixed] Remove undefined class via removing unused proto generated source files. (#4334)
- [added] Private API for a Fake Remote Config to enable testing without a backend. (#5633)

# v4.4.11
- [fixed] Fixed a bug where settings updates weren't applied before fetches. (#4740)
Expand Down
34 changes: 17 additions & 17 deletions FirebaseRemoteConfig/Sources/Private/RCNFakeFetch.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <Foundation/Foundation.h>

Expand All @@ -21,11 +21,11 @@ NS_SWIFT_NAME(FakeFetch)
@interface RCNFakeFetch : NSObject

/// Holds the current fake config.
@property (class, nonatomic, copy) NSMutableDictionary<NSString *, id> *config;
@property(class, nonatomic, copy) NSMutableDictionary<NSString *, id> *config;

/// Returns the config and additional metadata.
+(NSDictionary<NSString *, id> *) get;
+ (NSDictionary<NSString *, id> *)get;

/// If the Fake Fetcher is activated.
+(BOOL)active;
+ (BOOL)active;
@end
16 changes: 8 additions & 8 deletions FirebaseRemoteConfig/Sources/RCNFakeFetch.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@
* limitations under the License.
*/

#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
#import "FirebaseRemoteConfig/Sources/Private/RCNFakeFetch.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"

@implementation RCNFakeFetch
static NSMutableDictionary<NSString *, id> *_config = nil;

+(NSDictionary<NSString *, id> *)config {
+ (NSDictionary<NSString *, id> *)config {
return _config;
}

+(void)setConfig:(NSDictionary<NSString *, id> *)newConfig {
+ (void)setConfig:(NSDictionary<NSString *, id> *)newConfig {
_config = [newConfig mutableCopy];
}

+(BOOL)active {
+ (BOOL)active {
return RCNFakeFetch.config && [RCNFakeFetch.config count] > 0;
}

+(NSDictionary<NSString *, id> *) get {
+ (NSDictionary<NSString *, id> *)get {
static NSDictionary<NSString *, id> *last = nil;
if (_config == nil || _config.count == 0) {
last = nil;
return @{RCNFetchResponseKeyState : RCNFetchResponseKeyStateEmptyConfig};
}
NSString *state = [_config isEqualToDictionary:last] ? RCNFetchResponseKeyStateNoChange :
RCNFetchResponseKeyStateUpdate;
NSString *state = [_config isEqualToDictionary:last] ? RCNFetchResponseKeyStateNoChange
: RCNFetchResponseKeyStateUpdate;
last = _config;
return @{RCNFetchResponseKeyState : state, RCNFetchResponseKeyEntries: _config};
return @{RCNFetchResponseKeyState : state, RCNFetchResponseKeyEntries : _config};
}

@end
8 changes: 4 additions & 4 deletions FirebaseRemoteConfig/Sources/RCNFetch.m
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ - (void)refreshInstallationsTokenWithCompletionHandler:

- (void)doFetchCall:(FIRRemoteConfigFetchCompletion)completionHandler {
[self getAnalyticsUserPropertiesWithCompletionHandler:^(NSDictionary *userProperties) {
dispatch_async(self->_lockQueue, ^{
[self fetchWithUserProperties:userProperties completionHandler:completionHandler];
});
}];
dispatch_async(self->_lockQueue, ^{
[self fetchWithUserProperties:userProperties completionHandler:completionHandler];
});
}];
}

- (void)getAnalyticsUserPropertiesWithCompletionHandler:
Expand Down
8 changes: 4 additions & 4 deletions FirebaseRemoteConfig/Tests/HermeticAPI/APITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class APITests: XCTestCase {
settings.minimumFetchInterval = 0
config.configSettings = settings

FakeFetch.config = [ "Key1": "Value1"]
FakeFetch.config = ["Key1": "Value1"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialize the fake console.


// Uncomment for verbose debug logging.
FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.debug)
// Uncomment for verbose debug logging.
FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.debug)
}

override func tearDown() {
Expand Down Expand Up @@ -148,7 +148,7 @@ class APITests: XCTestCase {
waitForExpectations()

// Simulate updating console.
FakeFetch.config = [ "Key1": "Value2"]
FakeFetch.config = ["Key1": "Value2"]

let expectation2 = self.expectation(description: #function + "2")
config.fetch { status, error in
Expand Down