Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
d16f13c
Implement CoreDiagnostics interop
mikehaney24 May 25, 2019
31ac624
Add CoreDiagnosticsInterop to the Example Podfile
mikehaney24 May 27, 2019
559dab3
Style and xcodeproj updates
mikehaney24 May 27, 2019
abbb63e
Update Podfiles that dep on FirebaseCore
mikehaney24 Jun 3, 2019
7a9590e
ran pod deintegrate to remove unintended xcodeproj changes
mikehaney24 Jun 3, 2019
0bba31a
Fix Podfile paths
mikehaney24 Jun 4, 2019
2c4134c
Add FCD to if_changed and travis.yml
mikehaney24 Jun 4, 2019
b7d0d08
Fix building with Firestore
mikehaney24 Jun 4, 2019
d5608af
Style
mikehaney24 Jun 4, 2019
d5b9994
Whitespace
mikehaney24 Jun 4, 2019
669f559
Fix a changed internal API
mikehaney24 Jun 4, 2019
c08b8c8
Make pod paths consistent
mikehaney24 Jun 5, 2019
993c1c5
Merge branch 'master' into mph-master
mikehaney24 Jun 6, 2019
b24b109
Restore connectivity_monitor_noop.cc style
mikehaney24 Jun 7, 2019
06c1f6a
Remove logging prior to [FIRApp configure]
mikehaney24 Jun 12, 2019
13491b9
style
mikehaney24 Jun 12, 2019
488cade
Remove nil checks from diagnostics data
mikehaney24 Jun 12, 2019
e3e0cc5
Put back some deleted symbols
mikehaney24 Jun 12, 2019
ac3c700
Restore the sendLogsWithServiceName:version: method, but as a no-op
mikehaney24 Jun 12, 2019
9339939
Restore the original version of sendLogs...
mikehaney24 Jun 12, 2019
31b853e
Allow an unused parameter
mikehaney24 Jun 12, 2019
3a0e3ce
Remove obsolete nsnotificationcenter related stuff
mikehaney24 Jun 12, 2019
a17a79c
Whoops, missed the header change.
mikehaney24 Jun 12, 2019
c099b91
Final changes to support FIRCoreDiagnostics
mikehaney24 Jun 14, 2019
ea08328
Add nanopb and project generation infrastructure
mikehaney24 Jun 14, 2019
1e17441
Convert FIRCoreDiagnostics to canonical nanopb, and move to OSS.
mikehaney24 Jun 17, 2019
9adaaff
Remove custom build steps for CoreDiagnostics
mikehaney24 Jun 17, 2019
a3f621a
Addressing review comments
mikehaney24 Jun 17, 2019
ff5fcbc
Update versions, tags, and port the relevant unit tests for FIRCD
mikehaney24 Jun 19, 2019
120eb36
Version and platform fixes
mikehaney24 Jun 20, 2019
643f8ca
Fix podspec expected tags
mikehaney24 Jun 20, 2019
4106333
A hack to solve a chicken-and-egg problem with pod lib linting.
mikehaney24 Jun 20, 2019
95573be
Heartbeat implementation
maksymmalyhin Jun 20, 2019
8c5e98c
FIRDiagnosticsDateFileStorageTests
maksymmalyhin Jun 20, 2019
64bbb49
Fix tests for non-iOS platforms
mikehaney24 Jun 20, 2019
044b96f
Heartbeat tests
maksymmalyhin Jun 20, 2019
6c5aded
Fix initialization.
maksymmalyhin Jun 20, 2019
67090df
Cleanup Installation ID.
maksymmalyhin Jun 20, 2019
712ae83
Fix testProtoPopulation.
maksymmalyhin Jun 20, 2019
d803c7b
Merge branch 'mph-master6' into mm/cd-heartbeat-7
maksymmalyhin Jun 20, 2019
52a5349
Merge conflict fix
maksymmalyhin Jun 20, 2019
d7b4722
Typo fix.
maksymmalyhin Jun 20, 2019
928e7df
Remove FIRCore dep from FIRCD unit tests and move symbols to interop
mikehaney24 Jun 20, 2019
aaf48a8
Run ./scripts/style.sh
maksymmalyhin Jun 20, 2019
b6aec9a
Typo
maksymmalyhin Jun 20, 2019
bbd2722
Merge branch 'mph-master6' into mm/cd-heartbeat-7
maksymmalyhin Jun 20, 2019
106eea7
#ifdef comment
maksymmalyhin Jun 20, 2019
cc27324
File license header.
maksymmalyhin Jun 20, 2019
8b1b6f9
Import FIRDiagnosticsDateFileStorage.h using relative path.
maksymmalyhin Jun 20, 2019
c0902e9
FIRDiagnostics -> FIRCoreDiagnostics
maksymmalyhin Jun 20, 2019
1f60777
Docs syntax
maksymmalyhin Jun 20, 2019
9a8897e
Docs
maksymmalyhin Jun 20, 2019
7a5d6ee
Docs typo
maksymmalyhin Jun 20, 2019
e03f204
Add shared variables to the interop lib
mikehaney24 Jun 20, 2019
c0178e4
Fix comment
mikehaney24 Jun 20, 2019
9205321
Style
mikehaney24 Jun 20, 2019
4a0365c
Removed lib version passing.
mikehaney24 Jun 20, 2019
2173c96
Remove env checking for conditional deps
mikehaney24 Jun 20, 2019
3a407e2
Merge remote-tracking branch 'origin/mm/cd-heartbeat-7' into mph-master6
mikehaney24 Jun 21, 2019
0764f49
Merge branch 'mph-master5' into mph-master4
mikehaney24 Jun 21, 2019
19497b6
Merge branch 'mph-master4' into mph-master3
mikehaney24 Jun 21, 2019
a3adca1
Merge branch 'mph-master3' into mph-master2
mikehaney24 Jun 21, 2019
bdedb72
Merge branch 'master' into mph-master
mikehaney24 Jun 21, 2019
cf28e6a
Style
mikehaney24 Jun 21, 2019
ee86ff9
Address whitespace issues
mikehaney24 Jun 21, 2019
0902411
Add copyright notice
mikehaney24 Jun 21, 2019
174f787
Add new deps to Podfiles
mikehaney24 Jun 21, 2019
3e7f30f
Fix trailing space
mikehaney24 Jun 21, 2019
8fd0c16
Some changes to fix working in an extension.
mikehaney24 Jun 24, 2019
d4150af
Fix type in Podfile
mikehaney24 Jun 24, 2019
10e95ff
GDT: begin/end background task only for iOS and TVOS applications.
maksymmalyhin Jun 24, 2019
770cc1b
Fix typo
mikehaney24 Jun 24, 2019
d740533
Style
mikehaney24 Jun 24, 2019
59febdc
Stop sharing kFIRService strings across pods
paulb777 Jun 24, 2019
6e7655f
Travis test
paulb777 Jun 24, 2019
efb9fba
Change all TARGET_OS_TVOS macros to TARGET_OS_TV
mikehaney24 Jun 24, 2019
7f78f62
style
paulb777 Jun 24, 2019
458e220
Merge branch 'mph-master' into pb-cleanup-firservice
mikehaney24 Jun 25, 2019
fbc3dbc
Update all Podfiles with deps on FIRCore
mikehaney24 Jun 25, 2019
4e59eb9
Fix trailing whitespace
mikehaney24 Jun 25, 2019
a4cadc6
Merge branch 'pb-cleanup-firservice' into mph-master
mikehaney24 Jun 25, 2019
30f0a9d
Update Firestore cmake
mikehaney24 Jun 25, 2019
c796400
Fix FIAM build break (#3254)
paulb777 Jun 25, 2019
ea17e78
Additional cmake changes
mikehaney24 Jun 25, 2019
232b859
Fix linker issue with deprecated CoreDiagnostics (#3257)
paulb777 Jun 25, 2019
6fe1982
Adding more deps to cmake
mikehaney24 Jun 25, 2019
03824d8
Merge branch 'mph-master' of github.com:firebase/firebase-ios-sdk int…
mikehaney24 Jun 25, 2019
b4694d0
Fix linker error (#3266)
paulb777 Jun 26, 2019
2d26359
Add support for expanding PODS_TARGET_SRCROOT in CMake (#3267)
wilhuff Jun 26, 2019
af071cd
Merge branch 'master' into mph-master
mikehaney24 Jun 27, 2019
2cd11f9
Remove typed enum and fix a comment.
mikehaney24 Jun 27, 2019
0f4429f
Fix an import
mikehaney24 Jun 27, 2019
a248f45
Change a line so it's not altered by Copybara
mikehaney24 Jun 27, 2019
02db971
More changes to stop copybara from altering the wrong sources
mikehaney24 Jun 27, 2019
4a17d67
Remove trailing whitespace
mikehaney24 Jun 27, 2019
c11a30f
Fix copybara modifying python.
mikehaney24 Jun 27, 2019
8934d34
Merge branch 'master' into mph-master
mikehaney24 Jun 27, 2019
9788b8e
Add additional field in firebasecore.proto (#3273)
mikehaney24 Jun 27, 2019
5e68863
Merge branch 'master' into mph-master
mikehaney24 Jun 28, 2019
33079bf
Merge branch 'mph-master' of github.com:firebase/firebase-ios-sdk int…
mikehaney24 Jun 28, 2019
b01adee
Remove the dependency on interop to populate a shared variable.
mikehaney24 Jun 28, 2019
1b88ff1
style
mikehaney24 Jun 28, 2019
c855226
Merge branch 'master' into mph-master
mikehaney24 Jul 8, 2019
6e0b462
Create travis jobs for FirebaseCoreDiagnostics (#3245)
mikehaney24 Jul 10, 2019
d2b21a3
Merge branch 'mph-master' of github.com:firebase/firebase-ios-sdk int…
mikehaney24 Jul 10, 2019
c7a5303
Remove mph-master from travis
mikehaney24 Jul 10, 2019
f28f1db
Fix constant name conflic between old and new diagnostics (#3329)
maksymmalyhin Jul 10, 2019
3f0910c
Rempve mph-master again
mikehaney24 Jul 10, 2019
49f013a
Fix imports in FIRCDConnector
mikehaney24 Jul 10, 2019
56c9279
Fix another import
mikehaney24 Jul 10, 2019
ef521aa
Fix yet another import
mikehaney24 Jul 10, 2019
2842b24
Merge branch 'master' into mph-master
mikehaney24 Jul 11, 2019
da1c4ab
Attempt to read crashing test logs from disk
mikehaney24 Jul 11, 2019
9266085
Implement printing of failed/crashed test logs.
mikehaney24 Jul 12, 2019
40a85ba
Print only crashed tests, rmdir between runs
mikehaney24 Jul 12, 2019
1fedd3a
Revert reading crashing log changes
mikehaney24 Jul 16, 2019
cac286b
Write CHANGELOG for all new FIRCD associated libraries
mikehaney24 Jul 16, 2019
e258fce
Change all GUL deps to >= 6.2
mikehaney24 Jul 16, 2019
34f064c
Merge branch 'master' into mph-master
mikehaney24 Jul 17, 2019
c3059fe
Revert ZipBuilder changes and do some last bits of cleanup
mikehaney24 Jul 17, 2019
ad5071c
Remove an assertion and populate an error instead
mikehaney24 Jul 18, 2019
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
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,35 @@ podspec_framework(
SPECS Logger
)

podspec_framework(${FIREBASE_SOURCE_DIR}/GoogleDataTransport.podspec)

podspec_framework(${FIREBASE_SOURCE_DIR}/GoogleDataTransportCCTSupport.podspec)

podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseCore.podspec)

podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseCoreDiagnostics.podspec)

podspec_framework(
${FIREBASE_SOURCE_DIR}/FirebaseCoreDiagnosticsInterop.podspec
)

if(APPLE)
# FirebaseCoreDiagnosticsInterop has no source files but CMake can't build
# frameworks that don't have sources. Generate an inconsequential source
# file so that the library can be linked.
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/FirebaseCoreDiagnosticsInteropDummy.c
"// generated file for header-only CMake support.
__attribute__((unused))
static void FirebaseCoreDiagnosticsInteropFakeSymbol() {}
"
)
target_sources(
FirebaseCoreDiagnosticsInterop
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/FirebaseCoreDiagnosticsInteropDummy.c
)
endif()

podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseAuthInterop.podspec)

if(APPLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ target 'CocoapodsIntegrationTest' do
use_frameworks!

pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnostics', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FirebaseAuth', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseDatabase', :path => '../'
pod 'FirebaseDynamicLinks', :path => '../'
pod 'FirebaseFirestore', :path => '../'
Expand All @@ -15,5 +16,7 @@ target 'CocoapodsIntegrationTest' do
pod 'FirebaseInstanceID', :path => '../'
pod 'FirebaseMessaging', :path => '../'
pod 'FirebaseStorage', :path => '../'
pod 'GoogleDataTransport', :path => '../'
pod 'GoogleDataTransportCCTSupport', :path => '../'
pod 'GoogleUtilities', :path => '../'
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ platform :ios, '9.0'

target 'CocoapodsIntegrationTest' do
pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnostics', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FirebaseAuth', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseDatabase', :path => '../'
pod 'FirebaseDynamicLinks', :path => '../'
pod 'FirebaseFirestore', :path => '../'
Expand All @@ -13,5 +14,7 @@ target 'CocoapodsIntegrationTest' do
pod 'FirebaseInstanceID', :path => '../'
pod 'FirebaseMessaging', :path => '../'
pod 'FirebaseStorage', :path => '../'
pod 'GoogleDataTransport', :path => '../'
pod 'GoogleDataTransportCCTSupport', :path => '../'
pod 'GoogleUtilities', :path => '../'
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ target 'CocoapodsIntegrationTest' do
use_frameworks!

pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnostics', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FirebaseAuth', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseDatabase', :path => '../'
pod 'FirebaseDynamicLinks', :path => '../'
pod 'FirebaseFirestore', :path => '../'
Expand All @@ -15,5 +16,7 @@ target 'CocoapodsIntegrationTest' do
pod 'FirebaseInstanceID', :path => '../'
pod 'FirebaseMessaging', :path => '../'
pod 'FirebaseStorage', :path => '../'
pod 'GoogleDataTransport', :path => '../'
pod 'GoogleDataTransportCCTSupport', :path => '../'
pod 'GoogleUtilities', :path => '../'
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ target 'CocoapodsIntegrationTest' do
use_frameworks!

pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnostics', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FirebaseAuth', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseDatabase', :path => '../'
pod 'FirebaseDynamicLinks', :path => '../'
pod 'FirebaseFirestore', :path => '../'
Expand All @@ -16,6 +17,8 @@ target 'CocoapodsIntegrationTest' do
pod 'FirebaseInstanceID', :path => '../'
pod 'FirebaseMessaging', :path => '../'
pod 'FirebaseStorage', :path => '../'
pod 'GoogleDataTransport', :path => '../'
pod 'GoogleDataTransportCCTSupport', :path => '../'
pod 'GoogleUtilities', :path => '../'
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ platform :ios, '9.0'

target 'CocoapodsIntegrationTest' do
pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnostics', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FirebaseAuth', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseDatabase', :path => '../'
pod 'FirebaseDynamicLinks', :path => '../'
pod 'FirebaseFirestore', :path => '../'
Expand All @@ -13,6 +14,8 @@ target 'CocoapodsIntegrationTest' do
pod 'FirebaseInstanceID', :path => '../'
pod 'FirebaseMessaging', :path => '../'
pod 'FirebaseStorage', :path => '../'
pod 'GoogleDataTransport', :path => '../'
pod 'GoogleDataTransportCCTSupport', :path => '../'
pod 'GoogleUtilities', :path => '../'
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ platform :ios, '9.0'

target 'CocoapodsIntegrationTest' do
pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnostics', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FirebaseAuth', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseDatabase', :path => '../'
pod 'FirebaseDynamicLinks', :path => '../'
pod 'FirebaseFirestore', :path => '../'
Expand All @@ -13,5 +14,7 @@ target 'CocoapodsIntegrationTest' do
pod 'FirebaseInstanceID', :path => '../'
pod 'FirebaseMessaging', :path => '../'
pod 'FirebaseStorage', :path => '../'
pod 'GoogleDataTransport', :path => '../'
pod 'GoogleDataTransport', :path => '../'
pod 'GoogleUtilities', :path => '../'
end
5 changes: 4 additions & 1 deletion Example/Auth/AuthSample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ use_frameworks!
target 'AuthSample' do
platform :ios, '8.0'
pod 'FirebaseCore', :path => '../../../'
pod 'FirebaseCoreDiagnostics', :path => '../../../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../../../'
pod 'GoogleDataTransport', :path => '../../../'
pod 'GoogleDataTransportCCTSupport', :path => '../../../'
pod 'GoogleUtilities', :path => '../../../'
pod 'FirebaseAuth', :path => '../../../', :testspecs => ['unit']
pod 'FirebaseCore', :path => '../../../'
pod 'FirebaseInstanceID', :path => '../../..'
pod 'FBSDKLoginKit'
pod 'GoogleSignIn'
Expand Down
8 changes: 4 additions & 4 deletions Example/Core/Tests/FIRAppTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#import "FIRTestCase.h"
#import "FIRTestComponents.h"

#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsInterop.h>

#import <FirebaseCore/FIRAnalyticsConfiguration.h>
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIROptionsInternal.h>
Expand Down Expand Up @@ -262,7 +265,7 @@ - (void)testDeleteApp {
- (void)testErrorForSubspecConfigurationFailure {
NSError *error = [FIRApp errorForSubspecConfigurationFailureWithDomain:kFirebaseCoreErrorDomain
errorCode:-38
service:kFIRServiceAuth
service:@"Auth"
reason:@"some reason"];
XCTAssertNotNil(error);
XCTAssert([error.domain isEqualToString:kFirebaseCoreErrorDomain]);
Expand Down Expand Up @@ -632,9 +635,6 @@ - (void)testGlobalDataCollectionNoDiagnosticsSent {
// Ensure configure doesn't fire a notification.
[FIRApp configure];

NSError *error = [NSError errorWithDomain:@"com.firebase" code:42 userInfo:nil];
[app sendLogsWithServiceName:@"Service" version:@"Version" error:error];

// The observer mock is strict and will raise an exception when an unexpected notification is
// received.
OCMVerifyAll(self.observerMock);
Expand Down
48 changes: 48 additions & 0 deletions Example/Core/Tests/FIRDiagnosticsDataTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2019 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 <FirebaseCore/FIRDiagnosticsData.h>

@interface FIRDiagnosticsDataTest : XCTestCase

@end

@implementation FIRDiagnosticsDataTest

/** Tests initialization. */
- (void)testInit {
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
XCTAssertNotNil(data);
}

/** Tests that -diagnosticObjects returns a valid default dictionary. */
- (void)testFIRCoreDiagnosticsData {
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
XCTAssertNotNil(data.diagnosticObjects);
XCTAssertNotNil(data.diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey]);
XCTAssertNotNil(data.diagnosticObjects[kFIRCDllAppsCountKey]);
XCTAssertNotNil(data.diagnosticObjects[kFIRCDFirebaseUserAgentKey]);
}

/** Tests that setting diagnosticObjects throws. */
- (void)testSettingDiagnosticObjectsThrows {
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
XCTAssertThrows(data.diagnosticObjects = @{});
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright 2019 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 "FIRCDLibrary/FIRCoreDiagnosticsDateFileStorage.h"

@interface FIRCoreDiagnosticsDateFileStorageTests : XCTestCase
@property(nonatomic) NSURL *fileURL;
@property(nonatomic) FIRCoreDiagnosticsDateFileStorage *storage;
@end

@implementation FIRCoreDiagnosticsDateFileStorageTests

- (void)setUp {
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject];
XCTAssertNotNil(documentsPath);
NSURL *documentsURL = [NSURL fileURLWithPath:documentsPath];
self.fileURL = [documentsURL URLByAppendingPathComponent:@"FIRDiagnosticsDateFileStorageTests"
isDirectory:NO];

NSError *error;
if (![documentsURL checkResourceIsReachableAndReturnError:&error]) {
XCTAssert([[NSFileManager defaultManager] createDirectoryAtURL:documentsURL
withIntermediateDirectories:YES
attributes:nil
error:&error],
@"Error: %@", error);
}

self.storage = [[FIRCoreDiagnosticsDateFileStorage alloc] initWithFileURL:self.fileURL];
}

- (void)tearDown {
[[NSFileManager defaultManager] removeItemAtURL:self.fileURL error:nil];
self.fileURL = nil;
self.storage = nil;
}

- (void)testDateStorage {
NSDate *dateToSave = [NSDate date];

XCTAssertNil([self.storage date]);

NSError *error;
XCTAssertTrue([self.storage setDate:dateToSave error:&error]);

XCTAssertEqualObjects([self.storage date], dateToSave);

XCTAssertTrue([self.storage setDate:nil error:&error]);
XCTAssertNil([self.storage date]);
}

- (void)testDateIsStoredToFileSystem {
NSDate *date = [NSDate date];

NSError *error;
XCTAssert([self.storage setDate:date error:&error], @"Error: %@", error);

FIRCoreDiagnosticsDateFileStorage *anotherStorage =
[[FIRCoreDiagnosticsDateFileStorage alloc] initWithFileURL:self.fileURL];

XCTAssertEqualObjects([anotherStorage date], date);
}

@end
Loading