mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-10 22:45:59 +05:45
* Register Database with Interop
+ Add AuthInterop dependency
+ Have Database register with Interop component container
+ Add weak dependency on Auth
~ Cleaned up imports
* Use Interop for Auth token fetching
+ Use macro to get auth component
~ Change `getTokenForcingRefresh:withCallback:` call to use Interop component version of Auth
~ Clean up imports
* Implement necessary protocols
+ Added FIRComponentRegistrant and FIRDatabaseNilProtocol to FIRDatabase
* Squash of my previous local commits for Database Interop
Register Database with Interop:
+ Add AuthInterop dependency
+ Have Database register with Interop component container
+ Add weak dependency on Auth
~ Cleaned up imports
Use Interop for Auth token fetching:
+ Use macro to get auth component
~ Change `getTokenForcingRefresh:withCallback:` call to use Interop component version of Auth
~ Clean up imports
Implement necessary protocols:
+ Added FIRComponentRegistrant and FIRDatabaseNilProtocol to FIRDatabase
Clean up Database tests:
- Removed all unnecessary header files
~ Ran style.sh across all the tests
Cleaned Up project file:
Some header removals were missed in the last commit.
Sorted some test files
Fix Database Fake App Tests:
+ Added container property
+ Added an Auth fake in the container
+ Added the Shared utils files to the necessary targets
+ Added a missing XCTest reference in a test that didn't compile for me
* Revert "Squash of my previous local commits for Database Interop"
This reverts commit c0d0421237.
* Cleaned Up project file
Some header removals were missed in the last commit.
* Sorted some test files
* Fix Database Fake App Tests
+ Added container property
+ Added an Auth fake in the container
+ Added the Shared utils files to the necessary targets
+ Added a missing XCTest reference in a test that didn't compile for me
* PR Feedback Changes
+ Created new FIRDatabaseComponent class to encapsulate instance creation
+ Updated FAuthTokenProvider to only use an auth instance rather than an app.
* PR Feedback Follow-Up
- Removed FIRDatabase registration code
* pod deintegrate
* Move instance management
Somes tests may still be out of date.
* Fix Auth integration test
* pod deintegrate -- again
* PR Feedback
* PR Feedback
Added the FIRComponentLifecycleMaintainer protocol to FIRDatabaseComponent
* Update Firebase/Database/Api/FIRDatabaseComponent.m
Missed some small changes
* Get integration tests compiling
* Fix some tests
* Fixed more tests
Component needs to be cacheable in order to get the appWIllBeDeleted callback.
* Update target memberships
* Revert project file changes
* Add FIRAuthInteropFake for broken targets
* PR feedback
* Spacing and Style
* Moved `instances` to ivar
* Simplify FIRDatabaseDictionary
It's now keyed on the URL with the app being implied since each app will get its own `FIRDatabaseComponent`
* Fix Database Integration Tests
Have the FakeApp cache DB instances
Use the Full host/URL path to cache DB instances
Simplified shared scheme
```
Test Suite 'Database_IntegrationTests_iOS.xctest' passed at 2018-11-20 07:09:30.520.
Executed 326 tests, with 0 failures (0 unexpected) in 66.251 (66.528) seconds
Test Suite 'All tests' passed at 2018-11-20 07:09:30.522.
Executed 326 tests, with 0 failures (0 unexpected) in 66.251 (66.530) seconds
```
* Clarify defaultApp use
117 lines
4.7 KiB
Objective-C
117 lines
4.7 KiB
Objective-C
/*
|
|
* Copyright 2017 Google
|
|
*
|
|
* 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 <XCTest/XCTest.h>
|
|
#import "FUtilities.h"
|
|
#import "FIRDatabase_Private.h"
|
|
#import "FIRDatabaseReference_Private.h"
|
|
#import "FClock.h"
|
|
#import "FIRDatabaseConfig_Private.h"
|
|
#import "FWebSocketConnection.h"
|
|
#import "FConstants.h"
|
|
#import "FTestHelpers.h"
|
|
|
|
@interface FWebSocketConnection (Tests)
|
|
- (NSString*)userAgent;
|
|
@end
|
|
|
|
@interface FUtilitiesTest : XCTestCase
|
|
|
|
@end
|
|
|
|
@implementation FUtilitiesTest
|
|
|
|
- (void)testUrlWithSchema {
|
|
FParsedUrl *parsedUrl = [FUtilities parseUrl:@"https://repo.firebaseio.com"];
|
|
XCTAssertEqualObjects(parsedUrl.repoInfo.host, @"repo.firebaseio.com");
|
|
XCTAssertEqualObjects(parsedUrl.repoInfo.namespace, @"repo");
|
|
XCTAssertTrue(parsedUrl.repoInfo.secure);
|
|
XCTAssertEqualObjects(parsedUrl.path, [FPath empty]);
|
|
}
|
|
|
|
- (void)testUrlParsedWithoutSchema {
|
|
FParsedUrl *parsedUrl = [FUtilities parseUrl:@"repo.firebaseio.com"];
|
|
XCTAssertEqualObjects(parsedUrl.repoInfo.host, @"repo.firebaseio.com");
|
|
XCTAssertEqualObjects(parsedUrl.repoInfo.namespace, @"repo");
|
|
XCTAssertTrue(parsedUrl.repoInfo.secure);
|
|
XCTAssertEqualObjects(parsedUrl.path, [FPath empty]);
|
|
}
|
|
|
|
- (void)testDefaultCacheSizeIs10MB {
|
|
XCTAssertEqual([FTestHelpers defaultConfig].persistenceCacheSizeBytes, (NSUInteger)10*1024*1024);
|
|
XCTAssertEqual([FTestHelpers configForName:@"test-config"].persistenceCacheSizeBytes, (NSUInteger)10*1024*1024);
|
|
}
|
|
|
|
- (void)testSettingCacheSizeToHighOrToLowThrows {
|
|
FIRDatabaseConfig *config = [FTestHelpers configForName:@"config-tests-config"];
|
|
config.persistenceCacheSizeBytes = 5*1024*1024; // Works fine
|
|
XCTAssertThrows(config.persistenceCacheSizeBytes = (1024*1024-1));
|
|
XCTAssertThrows(config.persistenceCacheSizeBytes = 100*1024*1024+1);
|
|
}
|
|
|
|
- (void)testSystemClockMatchesCurrentTime {
|
|
NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970];
|
|
// Accuracy within 10ms
|
|
XCTAssertEqualWithAccuracy(currentTime, [[FSystemClock clock] currentTime], 0.010);
|
|
}
|
|
|
|
// This test is here for a lack of a better place to put it
|
|
- (void)testUserAgentString {
|
|
FWebSocketConnection *conn = [[FWebSocketConnection alloc] init];
|
|
|
|
NSString *agent = [conn performSelector:@selector(userAgent) withObject:nil];
|
|
|
|
NSArray *parts = [agent componentsSeparatedByString:@"/"];
|
|
XCTAssertEqual(parts.count, (NSUInteger)5);
|
|
XCTAssertEqualObjects(parts[0], @"Firebase");
|
|
XCTAssertEqualObjects(parts[1], kWebsocketProtocolVersion); // Wire protocol version
|
|
XCTAssertEqualObjects(parts[2], [FIRDatabase buildVersion]); // Build version
|
|
#if TARGET_OS_IPHONE
|
|
XCTAssertEqualObjects(parts[3], [[UIDevice currentDevice] systemVersion]); // iOS Version
|
|
NSString *deviceName = [UIDevice currentDevice].model;
|
|
XCTAssertEqualObjects([parts[4] componentsSeparatedByString:@"_"][0], deviceName);
|
|
#endif
|
|
|
|
}
|
|
|
|
- (void)testKeyComparison {
|
|
NSArray *order = @[
|
|
@"-2147483648", @"0", @"1", @"2", @"10", @"2147483647", // Treated as integers
|
|
@"-2147483649", @"-2147483650", @"-a", @"2147483648", @"21474836480", @"2147483649", @"a" // treated as strings
|
|
];
|
|
for (NSInteger i = 0; i < order.count; i++) {
|
|
for (NSInteger j = i + 1; j < order.count; j++) {
|
|
NSString *first = order[i];
|
|
NSString *second = order[j];
|
|
XCTAssertEqual([FUtilities compareKey:first toKey:second], NSOrderedAscending,
|
|
@"Expected %@ < %@", first, second);
|
|
XCTAssertEqual([FUtilities compareKey:first toKey:first], NSOrderedSame,
|
|
@"Expected %@ == %@", first, first);
|
|
XCTAssertEqual([FUtilities compareKey:second toKey:first], NSOrderedDescending,
|
|
@"Expected %@ > %@", second, first);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Enforce a > b, b < a, a != b, because this is apparently something that happens semi-regularly
|
|
- (void)testUnicodeKeyComparison {
|
|
XCTAssertEqual([FUtilities compareKey:@"유주연" toKey:@"윤규완오빠"], NSOrderedAscending);
|
|
XCTAssertEqual([FUtilities compareKey:@"윤규완오빠" toKey:@"유주연"], NSOrderedDescending);
|
|
XCTAssertNotEqual([FUtilities compareKey:@"윤규완오빠" toKey:@"유주연"], NSOrderedSame);
|
|
}
|
|
|
|
@end
|