Skip to content

Import Spec tests #6525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
14 changes: 14 additions & 0 deletions Firestore/Example/Firestore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
21836C4D9D48F962E7A3A244 /* ordered_code_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB380D03201BC6E400D97691 /* ordered_code_test.cc */; };
21A2A881F71CB825299DF06E /* hard_assert_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */; };
21C17F15579341289AD01051 /* persistence_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9113B6F513D0473AEABBAF1F /* persistence_testing.cc */; };
226574601C3F6D14DF14C16B /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; };
227CFA0B2A01884C277E4F1D /* hashing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54511E8D209805F8005BD28F /* hashing_test.cc */; };
229D1A9381F698D71F229471 /* string_win_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 79507DF8378D3C42F5B36268 /* string_win_test.cc */; };
22A00AC39CAB3426A943E037 /* query.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 544129D621C2DDC800EFB9CC /* query.pb.cc */; };
Expand Down Expand Up @@ -233,6 +234,7 @@
342724CA250A65E23CB133AC /* async_queue_std_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB4681208EA0BE00554BA2 /* async_queue_std_test.cc */; };
3451DC1712D7BF5D288339A2 /* view_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = A5466E7809AD2871FFDE6C76 /* view_testing.cc */; };
34D69886DAD4A2029BFC5C63 /* precondition_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA5520A36E1F00BCEB75 /* precondition_test.cc */; };
34E866DB52AAB7DB76B69A91 /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; };
353E47129584B8DDF10138BD /* stream_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5B5414D28802BC76FDADABD6 /* stream_test.cc */; };
355A9171EF3F7AD44A9C60CB /* document_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB6B908320322E4D00CC290A /* document_test.cc */; };
358DBA8B2560C65D9EB23C35 /* Pods_Firestore_IntegrationTests_macOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39B832380209CC5BAF93BC52 /* Pods_Firestore_IntegrationTests_macOS.framework */; };
Expand Down Expand Up @@ -507,6 +509,7 @@
5E6F9184B271F6D5312412FF /* mutation_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = C8522DE226C467C54E6788D8 /* mutation_test.cc */; };
5E7812753D960FBB373435BD /* defer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8ABAC2E0402213D837F73DC3 /* defer_test.cc */; };
5E89B1A5A5430713C79C4854 /* FirestoreEncoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1235769422B86E65007DDFA9 /* FirestoreEncoderTests.swift */; };
5EA75A5DE1A705BE77BB8768 /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; };
5ECE040F87E9FCD0A5D215DB /* pretty_printing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB323F9553050F4F6490F9FF /* pretty_printing_test.cc */; };
5EDF0D63EAD6A65D4F8CDF45 /* schedule_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B005A79E765AF02793DCE /* schedule_test.cc */; };
5EE21E86159A1911E9503BC1 /* transform_operation_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 33607A3AE91548BD219EC9C6 /* transform_operation_test.cc */; };
Expand Down Expand Up @@ -822,6 +825,7 @@
AB6B908820322E8800CC290A /* no_document_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB6B908720322E8800CC290A /* no_document_test.cc */; };
AB7BAB342012B519001E0872 /* geo_point_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB7BAB332012B519001E0872 /* geo_point_test.cc */; };
AB8209455BAA17850D5E196D /* http.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE9720B89AAC00B5BCE7 /* http.pb.cc */; };
AB9FF792C60FC581909EF381 /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; };
ABA495BB202B7E80008A7851 /* snapshot_version_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABA495B9202B7E79008A7851 /* snapshot_version_test.cc */; };
ABC1D7DC2023A04B00BA84F0 /* credentials_provider_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D9342023966E000A432D /* credentials_provider_test.cc */; };
ABC1D7DD2023A04F00BA84F0 /* empty_credentials_provider_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D93620239689000A432D /* empty_credentials_provider_test.cc */; };
Expand Down Expand Up @@ -1071,6 +1075,7 @@
E375FBA0632EFB4D14C4E5A9 /* FSTGoogleTestTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 54764FAE1FAA21B90085E60A /* FSTGoogleTestTests.mm */; };
E434ACDF63F219F3031F292E /* ConditionalConformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3228F51DCDC2E90D5C58F97 /* ConditionalConformanceTests.swift */; };
E435450184AEB51EE8435F66 /* write.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 544129D921C2DDC800EFB9CC /* write.pb.cc */; };
E441A53D035479C53C74A0E6 /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; };
E4A573B7C9227C3C24661B5B /* ordered_code_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB380D03201BC6E400D97691 /* ordered_code_test.cc */; };
E4EEF6AAFCD33303CE9E5408 /* field_value_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB356EF6200EA5EB0089B766 /* field_value_test.cc */; };
E500AB82DF2E7F3AFDB1AB3F /* to_string_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B696858D2214B53900271095 /* to_string_test.cc */; };
Expand All @@ -1089,6 +1094,7 @@
E82F8EBBC8CC37299A459E73 /* hashing_test_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = B69CF3F02227386500B281C8 /* hashing_test_apple.mm */; };
E8495A8D1E11C0844339CCA3 /* database_info_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D92E20235D22000A432D /* database_info_test.cc */; };
E884336B43BBD1194C17E3C4 /* status_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3CAA33F964042646FDDAF9F9 /* status_testing.cc */; };
E8BA7055EDB8B03CC99A528F /* recovery_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */; };
E9430D3EBDAE12E9016B708F /* no_document_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB6B908720322E8800CC290A /* no_document_test.cc */; };
E9B704651F9783B70F2D5E86 /* FSTUserDataConverterTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 548180A4228DEF1A004F70CD /* FSTUserDataConverterTests.mm */; };
EA38690795FBAA182A9AA63E /* FIRDatabaseTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06C202154D500B64F25 /* FIRDatabaseTests.mm */; };
Expand Down Expand Up @@ -1459,6 +1465,7 @@
98366480BD1FD44A1FEDD982 /* Pods-Firestore_Example_macOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_macOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_macOS/Pods-Firestore_Example_macOS.debug.xcconfig"; sourceTree = "<group>"; };
99434327614FEFF7F7DC88EC /* counting_query_engine.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = counting_query_engine.cc; sourceTree = "<group>"; };
9B0B005A79E765AF02793DCE /* schedule_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = schedule_test.cc; sourceTree = "<group>"; };
9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */ = {isa = PBXFileReference; includeInIndex = 1; path = recovery_spec_test.json; sourceTree = "<group>"; };
9CFD366B783AE27B9E79EE7A /* string_format_apple_test.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = string_format_apple_test.mm; sourceTree = "<group>"; };
A5466E7809AD2871FFDE6C76 /* view_testing.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = view_testing.cc; sourceTree = "<group>"; };
A5FA86650A18F3B7A8162287 /* Pods-Firestore_Benchmarks_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Benchmarks_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Benchmarks_iOS/Pods-Firestore_Benchmarks_iOS.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2352,6 +2359,7 @@
D5B2593BCB52957D62F1C9D3 /* perf_spec_test.json */,
54DA12A31F315EE100DD57A1 /* persistence_spec_test.json */,
731541602214AFFA0037F4DC /* query_spec_test.json */,
9C1AFCC9E616EC33D6E169CF /* recovery_spec_test.json */,
3B843E4A1F3930A400548890 /* remote_store_spec_test.json */,
54DA12A41F315EE100DD57A1 /* resume_token_spec_test.json */,
54DA12A51F315EE100DD57A1 /* write_spec_test.json */,
Expand Down Expand Up @@ -2734,6 +2742,7 @@
546877DC2248206A005E3DE0 /* perf_spec_test.json in Resources */,
546877DD2248206A005E3DE0 /* persistence_spec_test.json in Resources */,
546877DE2248206A005E3DE0 /* query_spec_test.json in Resources */,
5EA75A5DE1A705BE77BB8768 /* recovery_spec_test.json in Resources */,
546877DF2248206A005E3DE0 /* remote_store_spec_test.json in Resources */,
546877E02248206A005E3DE0 /* resume_token_spec_test.json in Resources */,
546877E12248206A005E3DE0 /* write_spec_test.json in Resources */,
Expand Down Expand Up @@ -2764,6 +2773,7 @@
54ACB6D0224C11F400172E69 /* perf_spec_test.json in Resources */,
54ACB6D1224C11F400172E69 /* persistence_spec_test.json in Resources */,
54ACB6D2224C11F400172E69 /* query_spec_test.json in Resources */,
226574601C3F6D14DF14C16B /* recovery_spec_test.json in Resources */,
54ACB6D3224C11F400172E69 /* remote_store_spec_test.json in Resources */,
54ACB6D4224C11F400172E69 /* resume_token_spec_test.json in Resources */,
54ACB6D5224C11F400172E69 /* write_spec_test.json in Resources */,
Expand All @@ -2785,6 +2795,7 @@
66DFEA9E324797E6EA81CBA9 /* perf_spec_test.json in Resources */,
32F8B4652010E8224E353041 /* persistence_spec_test.json in Resources */,
B0B779769926304268200015 /* query_spec_test.json in Resources */,
E8BA7055EDB8B03CC99A528F /* recovery_spec_test.json in Resources */,
E21D819A06D9691A4B313440 /* remote_store_spec_test.json in Resources */,
B43014A0517F31246419E08A /* resume_token_spec_test.json in Resources */,
9382BE7190E7750EE7CCCE7C /* write_spec_test.json in Resources */,
Expand All @@ -2806,6 +2817,7 @@
ABFD599019CF312CFF96B3EC /* perf_spec_test.json in Resources */,
D143FBD057481C1A59B27E5E /* persistence_spec_test.json in Resources */,
4CDFF1AE3D639AA89C5C4411 /* query_spec_test.json in Resources */,
34E866DB52AAB7DB76B69A91 /* recovery_spec_test.json in Resources */,
AF81B6A91987826426F18647 /* remote_store_spec_test.json in Resources */,
CC94A33318F983907E9ED509 /* resume_token_spec_test.json in Resources */,
2DB56B6DED2C93014AE5C51A /* write_spec_test.json in Resources */,
Expand Down Expand Up @@ -2845,6 +2857,7 @@
D5B25CBF07F65E885C9D68AB /* perf_spec_test.json in Resources */,
54DA12AD1F315EE100DD57A1 /* persistence_spec_test.json in Resources */,
731541612214AFFA0037F4DC /* query_spec_test.json in Resources */,
AB9FF792C60FC581909EF381 /* recovery_spec_test.json in Resources */,
3B843E4C1F3A182900548890 /* remote_store_spec_test.json in Resources */,
54DA12AE1F315EE100DD57A1 /* resume_token_spec_test.json in Resources */,
54DA12AF1F315EE100DD57A1 /* write_spec_test.json in Resources */,
Expand Down Expand Up @@ -2884,6 +2897,7 @@
CFCDC4670C61E034021F400B /* perf_spec_test.json in Resources */,
45FF545C6421398E9E1D647E /* persistence_spec_test.json in Resources */,
7AA8771FE1F048D012E5E317 /* query_spec_test.json in Resources */,
E441A53D035479C53C74A0E6 /* recovery_spec_test.json in Resources */,
022BA1619A576F6818B212C5 /* remote_store_spec_test.json in Resources */,
9EE81B1FB9B7C664B7B0A904 /* resume_token_spec_test.json in Resources */,
E6688C8E524770A3C6EBB33A /* write_spec_test.json in Resources */,
Expand Down
14 changes: 14 additions & 0 deletions Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ - (void)doDelete:(NSString *)key {
[self.driver writeUserMutation:FSTTestDeleteMutation(key)];
}

- (void)doWaitForPendingWrites {
[self.driver waitForPendingWrites];
}

- (void)doAddSnapshotsInSyncListener {
[self.driver addSnapshotsInSyncListener];
}
Expand Down Expand Up @@ -593,6 +597,8 @@ - (void)doStep:(NSDictionary *)step {
[self doWriteAck:step[@"writeAck"]];
} else if (step[@"failWrite"]) {
[self doFailWrite:step[@"failWrite"]];
} else if (step[@"waitForPendingWrites"]) {
[self doWaitForPendingWrites];
} else if (step[@"runTimer"]) {
[self doRunTimer:step[@"runTimer"]];
} else if (step[@"enableNetwork"]) {
Expand Down Expand Up @@ -756,6 +762,11 @@ - (void)validateExpectedState:(nullable NSDictionary *)expectedState {
[self validateActiveTargets];
}

- (void)validateWaitForPendingWritesEvents:(int)expectedWaitForPendingWritesEvents {
XCTAssertEqual(expectedWaitForPendingWritesEvents, [self.driver waitForPendingWritesEvents]);
[self.driver resetWaitForPendingWritesEvents];
}

- (void)validateSnapshotsInSyncEvents:(int)expectedSnapshotInSyncEvents {
XCTAssertEqual(expectedSnapshotInSyncEvents, [self.driver snapshotsInSyncEvents]);
[self.driver resetSnapshotsInSyncEvents];
Expand Down Expand Up @@ -869,6 +880,9 @@ - (void)runSpecTestSteps:(NSArray *)steps config:(NSDictionary *)config {
[self validateExpectedState:step[@"expectedState"]];
int expectedSnapshotsInSyncEvents = [step[@"expectedSnapshotsInSyncEvents"] intValue];
[self validateSnapshotsInSyncEvents:expectedSnapshotsInSyncEvents];
int expectedWaitForPendingWritesEvents =
[step[@"expectedWaitForPendingWritesEvents"] intValue];
[self validateWaitForPendingWritesEvents:expectedWaitForPendingWritesEvents];
}
[self.driver validateUsage];
} @finally {
Expand Down
14 changes: 14 additions & 0 deletions Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,20 @@ typedef std::unordered_map<auth::User, NSMutableArray<FSTOutstandingWrite *> *,
/** The current user for the FSTSyncEngine; determines which mutation queue is active. */
@property(nonatomic, assign, readonly) const auth::User &currentUser;

/**
* The number of waitForPendingWrites events that have been received.
*/
@property(nonatomic, readonly) int waitForPendingWritesEvents;

- (void)incrementWaitForPendingWritesEvents;

- (void)resetWaitForPendingWritesEvents;

/**
* Register a new waitForPendingWrites() callback.
*/
- (void)waitForPendingWrites;

/**
* The number of snapshots-in-sync events that have been received.
*/
Expand Down
22 changes: 22 additions & 0 deletions Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ @implementation FSTSyncEngineTestDriver {
IndexFreeQueryEngine _queryEngine;

int _snapshotsInSyncEvents;
int _waitForPendingWritesEvents;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this variable should be initialized to 0 in the init function, similar to _snapshotsInSyncEvents.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (but I didn't see the other initialization, so I added that as well)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I mistakenly thought line 289 was part of the initialization, but it's actually in its own reset function. My Objective-C knowledge is poor -- it could be the case that primitives are set to 0 automatically, I'm not sure (it wouldn't be the case in C++). So this initialization could be redundant (though shouldn't hurt).

Copy link
Contributor

Choose a reason for hiding this comment

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

Objective-C defaults all members to zero, so explicitly making that initialization is redundant.

https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/Initialization/Initialization.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, Gil! Sebastian, sorry for the redundant comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed again.

}

- (instancetype)initWithPersistence:(std::unique_ptr<Persistence>)persistence
Expand Down Expand Up @@ -244,6 +245,10 @@ - (instancetype)initWithPersistence:(std::unique_ptr<Persistence>)persistence
_acknowledgedDocs = [NSMutableArray array];

_rejectedDocs = [NSMutableArray array];

_waitForPendingWritesEvents = 0;

_snapshotsInSyncEvents = 0;
}
return self;
}
Expand Down Expand Up @@ -284,6 +289,19 @@ - (void)resetSnapshotsInSyncEvents {
_snapshotsInSyncEvents = 0;
}

- (void)incrementWaitForPendingWritesEvents {
_waitForPendingWritesEvents += 1;
}

- (void)resetWaitForPendingWritesEvents {
_waitForPendingWritesEvents = 0;
}

- (void)waitForPendingWrites {
_syncEngine->RegisterPendingWritesCallback(
[self](const Status &) { [self incrementWaitForPendingWritesEvents]; });
}

- (void)addSnapshotsInSyncListener {
std::shared_ptr<EventListener<Empty>> eventListener = EventListener<Empty>::Create(
[self](const StatusOr<Empty> &) { [self incrementSnapshotsInSyncEvents]; });
Expand All @@ -300,6 +318,10 @@ - (void)removeSnapshotsInSyncListener {
}
}

- (int)waitForPendingWritesEvents {
return _waitForPendingWritesEvents;
}

- (int)snapshotsInSyncEvents {
return _snapshotsInSyncEvents;
}
Expand Down
Loading