Skip to content

Commit 8626e31

Browse files
authored
C++ migration: port FSTRemoteEvent (#2320)
1 parent f08a8bc commit 8626e31

19 files changed

+279
-389
lines changed

Firestore/Example/Tests/Core/FSTQueryListenerTests.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#import "Firestore/Source/Core/FSTView.h"
2323
#import "Firestore/Source/Model/FSTDocument.h"
2424
#import "Firestore/Source/Model/FSTDocumentSet.h"
25-
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
2625
#import "Firestore/Source/Util/FSTAsyncQueryListener.h"
2726

2827
#import "Firestore/Example/Tests/Util/FSTHelpers.h"

Firestore/Example/Tests/Core/FSTViewTests.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#import "Firestore/Source/Model/FSTDocument.h"
2525
#import "Firestore/Source/Model/FSTDocumentSet.h"
2626
#import "Firestore/Source/Model/FSTFieldValue.h"
27-
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
2827

2928
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
3029

Firestore/Example/Tests/Integration/FSTDatastoreTests.mm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#import <XCTest/XCTest.h>
2121

2222
#include <memory>
23+
#include <vector>
2324

2425
#import "Firestore/Source/API/FIRDocumentReference+Internal.h"
2526
#import "Firestore/Source/API/FSTUserDataConverter.h"
@@ -29,7 +30,6 @@
2930
#import "Firestore/Source/Model/FSTFieldValue.h"
3031
#import "Firestore/Source/Model/FSTMutation.h"
3132
#import "Firestore/Source/Model/FSTMutationBatch.h"
32-
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
3333
#import "Firestore/Source/Remote/FSTRemoteStore.h"
3434

3535
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
@@ -40,6 +40,7 @@
4040
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
4141
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
4242
#include "Firestore/core/src/firebase/firestore/remote/datastore.h"
43+
#include "Firestore/core/src/firebase/firestore/remote/remote_event.h"
4344
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"
4445
#include "Firestore/core/src/firebase/firestore/util/executor_libdispatch.h"
4546
#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
@@ -57,6 +58,7 @@
5758
using firebase::firestore::model::TargetId;
5859
using firebase::firestore::remote::Datastore;
5960
using firebase::firestore::remote::GrpcConnection;
61+
using firebase::firestore::remote::RemoteEvent;
6062
using firebase::firestore::util::AsyncQueue;
6163
using firebase::firestore::util::ExecutorLibdispatch;
6264

@@ -79,17 +81,17 @@ - (void)expectListenEventWithDescription:(NSString *)description;
7981

8082
@property(nonatomic, weak, nullable) XCTestCase *testCase;
8183
@property(nonatomic, strong) NSMutableArray<NSObject *> *writeEvents;
82-
@property(nonatomic, strong) NSMutableArray<NSObject *> *listenEvents;
8384
@property(nonatomic, strong) NSMutableArray<XCTestExpectation *> *writeEventExpectations;
8485
@property(nonatomic, strong) NSMutableArray<XCTestExpectation *> *listenEventExpectations;
8586
@end
8687

87-
@implementation FSTRemoteStoreEventCapture
88+
@implementation FSTRemoteStoreEventCapture {
89+
std::vector<RemoteEvent> _listenEvents;
90+
}
8891

8992
- (instancetype)initWithTestCase:(XCTestCase *_Nullable)testCase {
9093
if (self = [super init]) {
9194
_writeEvents = [NSMutableArray array];
92-
_listenEvents = [NSMutableArray array];
9395
_testCase = testCase;
9496
_writeEventExpectations = [NSMutableArray array];
9597
_listenEventExpectations = [NSMutableArray array];
@@ -134,8 +136,8 @@ - (DocumentKeySet)remoteKeysForTarget:(TargetId)targetId {
134136
return DocumentKeySet{};
135137
}
136138

137-
- (void)applyRemoteEvent:(FSTRemoteEvent *)remoteEvent {
138-
[self.listenEvents addObject:remoteEvent];
139+
- (void)applyRemoteEvent:(const RemoteEvent &)remoteEvent {
140+
_listenEvents.push_back(remoteEvent);
139141
XCTestExpectation *expectation = [self.listenEventExpectations objectAtIndex:0];
140142
[self.listenEventExpectations removeObjectAtIndex:0];
141143
[expectation fulfill];

Firestore/Example/Tests/Local/FSTLocalStoreTests.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#import "Firestore/Source/Model/FSTDocumentSet.h"
2828
#import "Firestore/Source/Model/FSTMutation.h"
2929
#import "Firestore/Source/Model/FSTMutationBatch.h"
30-
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
3130
#import "Firestore/Source/Util/FSTClasses.h"
3231

3332
#import "Firestore/Example/Tests/Local/FSTLocalStoreTests.h"
@@ -51,6 +50,7 @@
5150
using firebase::firestore::model::MaybeDocumentMap;
5251
using firebase::firestore::model::SnapshotVersion;
5352
using firebase::firestore::model::TargetId;
53+
using firebase::firestore::remote::RemoteEvent;
5454
using firebase::firestore::remote::WatchChangeAggregator;
5555
using firebase::firestore::remote::WatchTargetChange;
5656
using firebase::firestore::remote::WatchTargetChangeState;
@@ -133,7 +133,7 @@ - (void)writeMutations:(NSArray<FSTMutation *> *)mutations {
133133
_lastChanges = result.changes;
134134
}
135135

136-
- (void)applyRemoteEvent:(FSTRemoteEvent *)event {
136+
- (void)applyRemoteEvent:(const RemoteEvent &)event {
137137
_lastChanges = [self.localStore applyRemoteEvent:event];
138138
}
139139

@@ -910,7 +910,7 @@ - (void)testPersistsResumeTokens {
910910
providerWithSingleResultForKey:testutil::Key("foo/bar")
911911
targets:{targetID}]};
912912
aggregator.HandleTargetChange(watchChange);
913-
FSTRemoteEvent *remoteEvent = aggregator.CreateRemoteEvent(testutil::Version(1000));
913+
RemoteEvent remoteEvent = aggregator.CreateRemoteEvent(testutil::Version(1000));
914914
[self applyRemoteEvent:remoteEvent];
915915

916916
// Stop listening so that the query should become inactive (but persistent)

0 commit comments

Comments
 (0)