aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Example/Tests')
-rw-r--r--Firestore/Example/Tests/API/FIRTimestampTest.m102
-rw-r--r--Firestore/Example/Tests/Core/FSTTimestampTests.mm88
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm25
-rw-r--r--Firestore/Example/Tests/Integration/FSTDatastoreTests.mm4
-rw-r--r--Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm6
-rw-r--r--Firestore/Example/Tests/Local/FSTLocalStoreTests.mm6
-rw-r--r--Firestore/Example/Tests/Local/FSTMutationQueueTests.mm8
-rw-r--r--Firestore/Example/Tests/Model/FSTFieldValueTests.mm18
-rw-r--r--Firestore/Example/Tests/Model/FSTMutationTests.mm6
-rw-r--r--Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm4
-rw-r--r--Firestore/Example/Tests/Util/FSTHelpers.h6
-rw-r--r--Firestore/Example/Tests/Util/FSTHelpers.mm8
12 files changed, 159 insertions, 122 deletions
diff --git a/Firestore/Example/Tests/API/FIRTimestampTest.m b/Firestore/Example/Tests/API/FIRTimestampTest.m
new file mode 100644
index 0000000..070da96
--- /dev/null
+++ b/Firestore/Example/Tests/API/FIRTimestampTest.m
@@ -0,0 +1,102 @@
+/*
+ * 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 "Firestore/Source/API/FIRTimestamp+Internal.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface FIRTimestampTest : XCTestCase
+@end
+
+NSDate *TestDate(int year, int month, int day, int hour, int minute, int second) {
+ NSDateComponents *comps = [[NSDateComponents alloc] init];
+ comps.year = year;
+ comps.month = month;
+ comps.day = day;
+ comps.hour = hour;
+ comps.minute = minute;
+ comps.second = second;
+ // Force time zone to UTC to avoid these values changing due to daylight saving.
+ comps.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
+
+ return [[NSCalendar currentCalendar] dateFromComponents:comps];
+}
+
+@implementation FIRTimestampTest
+
+- (void)testFromDate {
+ // Use an NSDate such that its fractional seconds have an exact representation to avoid losing
+ // precision.
+ NSDate *input = [NSDate dateWithTimeIntervalSinceReferenceDate:1.5];
+
+ FIRTimestamp *actual = [FIRTimestamp timestampWithDate:input];
+ static const int64_t kSecondsFromEpochToReferenceDate = 978307200;
+ XCTAssertEqual(kSecondsFromEpochToReferenceDate + 1, actual.seconds);
+ XCTAssertEqual(500000000, actual.nanoseconds);
+
+ FIRTimestamp *expected =
+ [[FIRTimestamp alloc] initWithSeconds:(kSecondsFromEpochToReferenceDate + 1)
+ nanoseconds:500000000];
+ XCTAssertEqualObjects(expected, actual);
+}
+
+- (void)testSO8601String {
+ NSDate *date = TestDate(1912, 4, 14, 23, 40, 0);
+ FIRTimestamp *timestamp =
+ [[FIRTimestamp alloc] initWithSeconds:(int64_t)date.timeIntervalSince1970
+ nanoseconds:543000000];
+ XCTAssertEqualObjects(timestamp.ISO8601String, @"1912-04-14T23:40:00.543000000Z");
+}
+
+- (void)testISO8601String_withLowMilliseconds {
+ NSDate *date = TestDate(1912, 4, 14, 23, 40, 0);
+ FIRTimestamp *timestamp =
+ [[FIRTimestamp alloc] initWithSeconds:(int64_t)date.timeIntervalSince1970
+ nanoseconds:7000000];
+ XCTAssertEqualObjects(timestamp.ISO8601String, @"1912-04-14T23:40:00.007000000Z");
+}
+
+- (void)testISO8601String_withLowNanos {
+ FIRTimestamp *timestamp = [[FIRTimestamp alloc] initWithSeconds:0 nanoseconds:1];
+ XCTAssertEqualObjects(timestamp.ISO8601String, @"1970-01-01T00:00:00.000000001Z");
+}
+
+- (void)testISO8601String_withNegativeSeconds {
+ FIRTimestamp *timestamp = [[FIRTimestamp alloc] initWithSeconds:-1 nanoseconds:999999999];
+ XCTAssertEqualObjects(timestamp.ISO8601String, @"1969-12-31T23:59:59.999999999Z");
+}
+
+- (void)testCompare {
+ NSArray<FIRTimestamp *> *timestamps = @[
+ [[FIRTimestamp alloc] initWithSeconds:12344 nanoseconds:999999999],
+ [[FIRTimestamp alloc] initWithSeconds:12345 nanoseconds:0],
+ [[FIRTimestamp alloc] initWithSeconds:12345 nanoseconds:000000001],
+ [[FIRTimestamp alloc] initWithSeconds:12345 nanoseconds:99999999],
+ [[FIRTimestamp alloc] initWithSeconds:12345 nanoseconds:100000000],
+ [[FIRTimestamp alloc] initWithSeconds:12345 nanoseconds:100000001],
+ [[FIRTimestamp alloc] initWithSeconds:12346 nanoseconds:0],
+ ];
+ for (int i = 0; i < timestamps.count - 1; ++i) {
+ XCTAssertEqual(NSOrderedAscending, [timestamps[i] compare:timestamps[i + 1]]);
+ XCTAssertEqual(NSOrderedDescending, [timestamps[i + 1] compare:timestamps[i]]);
+ }
+}
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Example/Tests/Core/FSTTimestampTests.mm b/Firestore/Example/Tests/Core/FSTTimestampTests.mm
deleted file mode 100644
index a3765fe..0000000
--- a/Firestore/Example/Tests/Core/FSTTimestampTests.mm
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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 "Firestore/Source/Core/FSTTimestamp.h"
-
-#import <XCTest/XCTest.h>
-
-#import "Firestore/Source/Util/FSTAssert.h"
-
-#import "Firestore/Example/Tests/Util/FSTHelpers.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface FSTTimestampTests : XCTestCase
-@end
-
-@implementation FSTTimestampTests
-
-- (void)testFromDate {
- // Very carefully construct an NSDate that won't lose precision with its milliseconds.
- NSDate *input = [NSDate dateWithTimeIntervalSinceReferenceDate:1.5];
-
- FSTTimestamp *actual = [FSTTimestamp timestampWithDate:input];
- static const int64_t kSecondsFromEpochToReferenceDate = 978307200;
- XCTAssertEqual(kSecondsFromEpochToReferenceDate + 1, actual.seconds);
- XCTAssertEqual(500000000, actual.nanos);
-
- FSTTimestamp *expected =
- [[FSTTimestamp alloc] initWithSeconds:(kSecondsFromEpochToReferenceDate + 1) nanos:500000000];
- XCTAssertEqualObjects(expected, actual);
-}
-
-- (void)testSO8601String {
- NSDate *date = FSTTestDate(1912, 4, 14, 23, 40, 0);
- FSTTimestamp *timestamp =
- [[FSTTimestamp alloc] initWithSeconds:(int64_t)date.timeIntervalSince1970 nanos:543000000];
- XCTAssertEqualObjects(timestamp.ISO8601String, @"1912-04-14T23:40:00.543000000Z");
-}
-
-- (void)testISO8601String_withLowMilliseconds {
- NSDate *date = FSTTestDate(1912, 4, 14, 23, 40, 0);
- FSTTimestamp *timestamp =
- [[FSTTimestamp alloc] initWithSeconds:(int64_t)date.timeIntervalSince1970 nanos:7000000];
- XCTAssertEqualObjects(timestamp.ISO8601String, @"1912-04-14T23:40:00.007000000Z");
-}
-
-- (void)testISO8601String_withLowNanos {
- FSTTimestamp *timestamp = [[FSTTimestamp alloc] initWithSeconds:0 nanos:1];
- XCTAssertEqualObjects(timestamp.ISO8601String, @"1970-01-01T00:00:00.000000001Z");
-}
-
-- (void)testISO8601String_withNegativeSeconds {
- FSTTimestamp *timestamp = [[FSTTimestamp alloc] initWithSeconds:-1 nanos:999999999];
- XCTAssertEqualObjects(timestamp.ISO8601String, @"1969-12-31T23:59:59.999999999Z");
-}
-
-- (void)testCompare {
- NSArray<FSTTimestamp *> *timestamps = @[
- [[FSTTimestamp alloc] initWithSeconds:12344 nanos:999999999],
- [[FSTTimestamp alloc] initWithSeconds:12345 nanos:0],
- [[FSTTimestamp alloc] initWithSeconds:12345 nanos:000000001],
- [[FSTTimestamp alloc] initWithSeconds:12345 nanos:99999999],
- [[FSTTimestamp alloc] initWithSeconds:12345 nanos:100000000],
- [[FSTTimestamp alloc] initWithSeconds:12345 nanos:100000001],
- [[FSTTimestamp alloc] initWithSeconds:12346 nanos:0],
- ];
- for (int i = 0; i < timestamps.count - 1; ++i) {
- XCTAssertEqual(NSOrderedAscending, [timestamps[i] compare:timestamps[i + 1]]);
- XCTAssertEqual(NSOrderedDescending, [timestamps[i + 1] compare:timestamps[i]]);
- }
-}
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm b/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm
index 34bd87e..0e75b8e 100644
--- a/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#import <FirebaseFirestore/FIRTimestamp.h>
#import <FirebaseFirestore/FirebaseFirestore.h>
#import <XCTest/XCTest.h>
@@ -220,4 +221,28 @@
[self awaitExpectations];
}
+- (NSDictionary<NSString *, id> *)testDataWithTimestamp:(FIRTimestamp *)timestamp {
+ return @{
+ @"timestamp" : [timestamp approximateDateValue],
+ @"metadata" : @{@"nestedTimestamp" : [timestamp approximateDateValue]}
+ };
+}
+
+// This test should break once the default for how timestamps are returned changes.
+- (void)testThatDataContainsNativeDateType {
+ NSDate *date = [NSDate date];
+ FIRTimestamp *timestamp = [FIRTimestamp timestampWithDate:date];
+ FIRDocumentReference *doc = [self documentRef];
+ [self writeDocumentRef:doc data:[self testDataWithTimestamp:timestamp]];
+
+ FIRDocumentSnapshot *result = [self readDocumentForRef:doc];
+ NSDate *resultDate = result.data[@"timestamp"];
+ XCTAssertEqualWithAccuracy([resultDate timeIntervalSince1970], [date timeIntervalSince1970],
+ 0.000001);
+ XCTAssertEqualObjects(result.data[@"timestamp"], resultDate);
+ NSDate *resultNestedDate = result[@"metadata.nestedTimestamp"];
+ XCTAssertEqualWithAccuracy([resultNestedDate timeIntervalSince1970], [date timeIntervalSince1970],
+ 0.000001);
+}
+
@end
diff --git a/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm b/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
index 36b0494..b48e5d0 100644
--- a/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
+++ b/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
@@ -16,6 +16,7 @@
#import <FirebaseFirestore/FirebaseFirestore.h>
+#import <FirebaseFirestore/FIRTimestamp.h>
#import <GRPCClient/GRPCCall+ChannelCredentials.h>
#import <GRPCClient/GRPCCall+Tests.h>
#import <XCTest/XCTest.h>
@@ -26,7 +27,6 @@
#import "Firestore/Source/Core/FSTFirestoreClient.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Local/FSTQueryData.h"
#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
@@ -214,7 +214,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTSetMutation *mutation = [self setMutation];
FSTMutationBatch *batch = [[FSTMutationBatch alloc] initWithBatchID:23
- localWriteTime:[FSTTimestamp timestamp]
+ localWriteTime:[FIRTimestamp timestamp]
mutations:@[ mutation ]];
[_testWorkerQueue dispatchAsync:^{
[_remoteStore commitBatch:batch];
diff --git a/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm b/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm
index 1b55795..1793b23 100644
--- a/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm
+++ b/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm
@@ -16,6 +16,7 @@
#import "Firestore/Source/Local/FSTLocalSerializer.h"
+#import <FirebaseFirestore/FIRTimestamp.h>
#import <XCTest/XCTest.h>
#import "Firestore/Protos/objc/firestore/local/MaybeDocument.pbobjc.h"
@@ -29,7 +30,6 @@
#import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Local/FSTQueryData.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentKey.h"
@@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
@"num" : @1 })
precondition:[FSTPrecondition preconditionWithExists:YES]];
FSTMutation *del = FSTTestDeleteMutation(@"baz/quux");
- FSTTimestamp *writeTime = [FSTTimestamp timestamp];
+ FIRTimestamp *writeTime = [FIRTimestamp timestamp];
FSTMutationBatch *model = [[FSTMutationBatch alloc] initWithBatchID:42
localWriteTime:writeTime
mutations:@[ set, patch, del ]];
@@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
GPBTimestamp *writeTimeProto = [GPBTimestamp message];
writeTimeProto.seconds = writeTime.seconds;
- writeTimeProto.nanos = writeTime.nanos;
+ writeTimeProto.nanos = writeTime.nanoseconds;
FSTPBWriteBatch *batchProto = [FSTPBWriteBatch message];
batchProto.batchId = 42;
diff --git a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
index f3493ce..393f77b 100644
--- a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
+++ b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
@@ -16,10 +16,10 @@
#import "Firestore/Source/Local/FSTLocalStore.h"
+#import <FirebaseFirestore/FIRTimestamp.h>
#import <XCTest/XCTest.h>
#import "Firestore/Source/Core/FSTQuery.h"
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Local/FSTEagerGarbageCollector.h"
#import "Firestore/Source/Local/FSTLocalWriteResult.h"
#import "Firestore/Source/Local/FSTNoOpGarbageCollector.h"
@@ -127,7 +127,7 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTLocalWriteResult *result = [self.localStore locallyWriteMutations:mutations];
XCTAssertNotNil(result);
[self.batches addObject:[[FSTMutationBatch alloc] initWithBatchID:result.batchID
- localWriteTime:[FSTTimestamp timestamp]
+ localWriteTime:[FIRTimestamp timestamp]
mutations:mutations]];
self.lastChanges = result.changes;
}
@@ -228,7 +228,7 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTMutation *set1 = FSTTestSetMutation(@"foo/bar", @{@"foo" : @"bar"});
FSTMutation *set2 = FSTTestSetMutation(@"bar/baz", @{@"bar" : @"baz"});
FSTMutationBatch *batch = [[FSTMutationBatch alloc] initWithBatchID:1
- localWriteTime:[FSTTimestamp timestamp]
+ localWriteTime:[FIRTimestamp timestamp]
mutations:@[ set1, set2 ]];
FSTDocumentKeySet *keys = [batch keys];
XCTAssertEqual(keys.count, 2);
diff --git a/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm b/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm
index 62d30fb..7d305d0 100644
--- a/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm
+++ b/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm
@@ -16,8 +16,8 @@
#import "Firestore/Example/Tests/Local/FSTMutationQueueTests.h"
+#import <FirebaseFirestore/FIRTimestamp.h>
#import "Firestore/Source/Core/FSTQuery.h"
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Local/FSTEagerGarbageCollector.h"
#import "Firestore/Source/Local/FSTMutationQueue.h"
#import "Firestore/Source/Local/FSTPersistence.h"
@@ -258,7 +258,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTWriteGroup *group = [self.persistence startGroupWithAction:@"New mutation batch"];
for (FSTMutation *mutation in mutations) {
FSTMutationBatch *batch =
- [self.mutationQueue addMutationBatchWithWriteTime:[FSTTimestamp timestamp]
+ [self.mutationQueue addMutationBatchWithWriteTime:[FIRTimestamp timestamp]
mutations:@[ mutation ]
group:group];
[batches addObject:batch];
@@ -295,7 +295,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTWriteGroup *group = [self.persistence startGroupWithAction:@"New mutation batch"];
for (FSTMutation *mutation in mutations) {
FSTMutationBatch *batch =
- [self.mutationQueue addMutationBatchWithWriteTime:[FSTTimestamp timestamp]
+ [self.mutationQueue addMutationBatchWithWriteTime:[FIRTimestamp timestamp]
mutations:@[ mutation ]
group:group];
[batches addObject:batch];
@@ -440,7 +440,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTWriteGroup *group = [self.persistence startGroupWithAction:@"New mutation batch"];
FSTMutationBatch *batch =
- [self.mutationQueue addMutationBatchWithWriteTime:[FSTTimestamp timestamp]
+ [self.mutationQueue addMutationBatchWithWriteTime:[FIRTimestamp timestamp]
mutations:@[ mutation ]
group:group];
[self.persistence commitGroup:group];
diff --git a/Firestore/Example/Tests/Model/FSTFieldValueTests.mm b/Firestore/Example/Tests/Model/FSTFieldValueTests.mm
index 52d5a4e..c0fb188 100644
--- a/Firestore/Example/Tests/Model/FSTFieldValueTests.mm
+++ b/Firestore/Example/Tests/Model/FSTFieldValueTests.mm
@@ -17,11 +17,11 @@
#import "Firestore/Source/Model/FSTFieldValue.h"
#import <FirebaseFirestore/FIRGeoPoint.h>
+#import <FirebaseFirestore/FIRTimestamp.h>
#import <XCTest/XCTest.h>
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/API/FSTUserDataConverter.h"
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Model/FSTPath.h"
@@ -229,7 +229,7 @@ union DoubleBits {
XCTAssertEqualObjects([wrapped value], value);
XCTAssertEqualObjects(((FSTTimestampValue *)wrapped).internalValue,
- [FSTTimestamp timestampWithDate:value]);
+ [FIRTimestamp timestampWithDate:value]);
}
}
@@ -445,20 +445,20 @@ union DoubleBits {
@[ FSTTestFieldValue(@"\u00e9a") ], // latin small letter e with acute accent
@[
FSTTestFieldValue(date1),
- [FSTTimestampValue timestampValue:[FSTTimestamp timestampWithDate:date1]]
+ [FSTTimestampValue timestampValue:[FIRTimestamp timestampWithDate:date1]]
],
@[ FSTTestFieldValue(date2) ],
@[
// NOTE: ServerTimestampValues can't be parsed via FSTTestFieldValue().
[FSTServerTimestampValue
- serverTimestampValueWithLocalWriteTime:[FSTTimestamp timestampWithDate:date1]
+ serverTimestampValueWithLocalWriteTime:[FIRTimestamp timestampWithDate:date1]
previousValue:nil],
[FSTServerTimestampValue
- serverTimestampValueWithLocalWriteTime:[FSTTimestamp timestampWithDate:date1]
+ serverTimestampValueWithLocalWriteTime:[FIRTimestamp timestampWithDate:date1]
previousValue:nil]
],
@[ [FSTServerTimestampValue
- serverTimestampValueWithLocalWriteTime:[FSTTimestamp timestampWithDate:date2]
+ serverTimestampValueWithLocalWriteTime:[FIRTimestamp timestampWithDate:date2]
previousValue:nil] ],
@[
FSTTestFieldValue(FSTTestGeoPoint(0, 1)),
@@ -574,14 +574,12 @@ union DoubleBits {
{
XCTAssertTrue([output[@"array"][1] isKindOfClass:[NSDate class]]);
NSDate *actual = output[@"array"][1];
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970, actual.timeIntervalSince1970,
- 0.000000001);
+ XCTAssertEqualWithAccuracy(date.timeIntervalSince1970, actual.timeIntervalSince1970, 0.000001);
}
{
XCTAssertTrue([output[@"obj"][@"date"] isKindOfClass:[NSDate class]]);
NSDate *actual = output[@"obj"][@"date"];
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970, actual.timeIntervalSince1970,
- 0.000000001);
+ XCTAssertEqualWithAccuracy(date.timeIntervalSince1970, actual.timeIntervalSince1970, 0.000001);
}
}
diff --git a/Firestore/Example/Tests/Model/FSTMutationTests.mm b/Firestore/Example/Tests/Model/FSTMutationTests.mm
index 47fa9b3..1c1375c 100644
--- a/Firestore/Example/Tests/Model/FSTMutationTests.mm
+++ b/Firestore/Example/Tests/Model/FSTMutationTests.mm
@@ -16,9 +16,9 @@
#import "Firestore/Source/Model/FSTMutation.h"
+#import <FirebaseFirestore/FIRTimestamp.h>
#import <XCTest/XCTest.h>
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
@@ -30,11 +30,11 @@
@end
@implementation FSTMutationTests {
- FSTTimestamp *_timestamp;
+ FIRTimestamp *_timestamp;
}
- (void)setUp {
- _timestamp = [FSTTimestamp timestamp];
+ _timestamp = [FIRTimestamp timestamp];
}
- (void)testAppliesSetsToDocuments {
diff --git a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
index 48e5546..f7cc1b0 100644
--- a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
+++ b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
@@ -19,6 +19,7 @@
#import <FirebaseFirestore/FIRFieldPath.h>
#import <FirebaseFirestore/FIRFirestoreErrors.h>
#import <FirebaseFirestore/FIRGeoPoint.h>
+#import <FirebaseFirestore/FIRTimestamp.h>
#import <GRPCClient/GRPCCall.h>
#import <XCTest/XCTest.h>
@@ -33,7 +34,6 @@
#import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Local/FSTQueryData.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentKey.h"
@@ -380,7 +380,7 @@ NS_ASSUME_NONNULL_BEGIN
GCFSWrite *proto = [GCFSWrite message];
proto.update = [self.serializer encodedDocumentWithFields:mutation.value key:mutation.key];
proto.currentDocument.updateTime =
- [self.serializer encodedTimestamp:[[FSTTimestamp alloc] initWithSeconds:0 nanos:4000]];
+ [self.serializer encodedTimestamp:[[FIRTimestamp alloc] initWithSeconds:0 nanoseconds:4000]];
[self assertRoundTripForMutation:mutation proto:proto];
}
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.h b/Firestore/Example/Tests/Util/FSTHelpers.h
index 4dbf910..9ee9a0b 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.h
+++ b/Firestore/Example/Tests/Util/FSTHelpers.h
@@ -37,7 +37,7 @@
@class FSTSnapshotVersion;
@class FSTSortOrder;
@class FSTTargetChange;
-@class FSTTimestamp;
+@class FIRTimestamp;
@class FSTTransformMutation;
@class FSTView;
@class FSTViewSnapshot;
@@ -132,8 +132,8 @@ extern "C" {
XCTAssertTrue(__didThrow, ##__VA_ARGS__); \
})
-/** Creates a new FSTTimestamp from components. Note that year, month, and day are all one-based. */
-FSTTimestamp *FSTTestTimestamp(int year, int month, int day, int hour, int minute, int second);
+/** Creates a new FIRTimestamp from components. Note that year, month, and day are all one-based. */
+FIRTimestamp *FSTTestTimestamp(int year, int month, int day, int hour, int minute, int second);
/** Creates a new NSDate from components. Note that year, month, and day are all one-based. */
NSDate *FSTTestDate(int year, int month, int day, int hour, int minute, int second);
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm
index 452e9a6..586fdbc 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.mm
+++ b/Firestore/Example/Tests/Util/FSTHelpers.mm
@@ -21,12 +21,12 @@
#import <FirebaseFirestore/FIRFieldPath.h>
#import <FirebaseFirestore/FIRGeoPoint.h>
+#import <FirebaseFirestore/FIRTimestamp.h>
#import "Firestore/Source/API/FIRFieldPath+Internal.h"
#import "Firestore/Source/API/FSTUserDataConverter.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
-#import "Firestore/Source/Core/FSTTimestamp.h"
#import "Firestore/Source/Core/FSTView.h"
#import "Firestore/Source/Core/FSTViewSnapshot.h"
#import "Firestore/Source/Local/FSTLocalViewChanges.h"
@@ -55,9 +55,9 @@ static NSString *const kDeleteSentinel = @"<DELETE>";
static const int kMicrosPerSec = 1000000;
static const int kMillisPerSec = 1000;
-FSTTimestamp *FSTTestTimestamp(int year, int month, int day, int hour, int minute, int second) {
+FIRTimestamp *FSTTestTimestamp(int year, int month, int day, int hour, int minute, int second) {
NSDate *date = FSTTestDate(year, month, day, hour, minute, second);
- return [FSTTimestamp timestampWithDate:date];
+ return [FIRTimestamp timestampWithDate:date];
}
NSDate *FSTTestDate(int year, int month, int day, int hour, int minute, int second) {
@@ -140,7 +140,7 @@ FSTSnapshotVersion *FSTTestVersion(FSTTestSnapshotVersion versionMicroseconds) {
int64_t seconds = versionMicroseconds / kMicrosPerSec;
int32_t nanos = (int32_t)(versionMicroseconds % kMicrosPerSec) * kMillisPerSec;
- FSTTimestamp *timestamp = [[FSTTimestamp alloc] initWithSeconds:seconds nanos:nanos];
+ FIRTimestamp *timestamp = [[FIRTimestamp alloc] initWithSeconds:seconds nanoseconds:nanos];
return [FSTSnapshotVersion versionWithTimestamp:timestamp];
}