|
65 | 65 | using firebase::firestore::remote::GrpcConnection;
|
66 | 66 | using firebase::firestore::remote::RemoteEvent;
|
67 | 67 | using firebase::firestore::remote::RemoteStore;
|
| 68 | +using firebase::firestore::remote::RemoteStoreCallback; |
68 | 69 | using firebase::firestore::testutil::Map;
|
69 | 70 | using firebase::firestore::testutil::WrapObject;
|
70 | 71 | using firebase::firestore::util::AsyncQueue;
|
|
75 | 76 |
|
76 | 77 | #pragma mark - FSTRemoteStoreEventCapture
|
77 | 78 |
|
78 |
| -@interface FSTRemoteStoreEventCapture : NSObject <FSTRemoteSyncer> |
| 79 | +@interface FSTRemoteStoreEventCapture : NSObject |
79 | 80 |
|
80 | 81 | - (instancetype)init __attribute__((unavailable("Use initWithTestCase:")));
|
81 | 82 |
|
@@ -153,6 +154,48 @@ - (void)rejectListenWithTargetID:(const TargetId)targetID error:(NSError *)error
|
153 | 154 |
|
154 | 155 | @end
|
155 | 156 |
|
| 157 | +class RemoteStoreEventCapture : public RemoteStoreCallback { |
| 158 | + public: |
| 159 | + explicit RemoteStoreEventCapture(XCTestCase *test_case) { |
| 160 | + underlying_capture_ = [[FSTRemoteStoreEventCapture alloc] initWithTestCase:test_case]; |
| 161 | + } |
| 162 | + |
| 163 | + void ExpectWriteEvent(NSString *description) { |
| 164 | + [underlying_capture_ expectWriteEventWithDescription:description]; |
| 165 | + } |
| 166 | + |
| 167 | + void ExpectListenEvent(NSString *description) { |
| 168 | + [underlying_capture_ expectListenEventWithDescription:description]; |
| 169 | + } |
| 170 | + |
| 171 | + void ApplyRemoteEvent(const RemoteEvent &remote_event) override { |
| 172 | + [underlying_capture_ applyRemoteEvent:remote_event]; |
| 173 | + } |
| 174 | + |
| 175 | + void HandleRejectedListen(TargetId target_id, Status error) override { |
| 176 | + [underlying_capture_ rejectListenWithTargetID:target_id error:error.ToNSError()]; |
| 177 | + } |
| 178 | + |
| 179 | + void HandleSuccessfulWrite(const MutationBatchResult &batch_result) override { |
| 180 | + [underlying_capture_ applySuccessfulWriteWithResult:batch_result]; |
| 181 | + } |
| 182 | + |
| 183 | + void HandleRejectedWrite(BatchId batch_id, Status error) override { |
| 184 | + [underlying_capture_ rejectFailedWriteWithBatchID:batch_id error:error.ToNSError()]; |
| 185 | + } |
| 186 | + |
| 187 | + void HandleOnlineStateChange(OnlineState online_state) override { |
| 188 | + HARD_FAIL("Not implemented"); |
| 189 | + } |
| 190 | + |
| 191 | + model::DocumentKeySet GetRemoteKeys(TargetId target_id) const override { |
| 192 | + return [underlying_capture_ remoteKeysForTarget:target_id]; |
| 193 | + } |
| 194 | + |
| 195 | + private: |
| 196 | + FSTRemoteStoreEventCapture *underlying_capture_; |
| 197 | +}; |
| 198 | + |
156 | 199 | #pragma mark - FSTDatastoreTests
|
157 | 200 |
|
158 | 201 | @interface FSTDatastoreTests : XCTestCase
|
@@ -217,10 +260,10 @@ - (void)testCommit {
|
217 | 260 | }
|
218 | 261 |
|
219 | 262 | - (void)testStreamingWrite {
|
220 |
| - FSTRemoteStoreEventCapture *capture = [[FSTRemoteStoreEventCapture alloc] initWithTestCase:self]; |
221 |
| - [capture expectWriteEventWithDescription:@"write mutations"]; |
| 263 | + RemoteStoreEventCapture capture = RemoteStoreEventCapture(self); |
| 264 | + capture.ExpectWriteEvent(@"write mutations"); |
222 | 265 |
|
223 |
| - _remoteStore->set_sync_engine(capture); |
| 266 | + _remoteStore->set_sync_engine(&capture); |
224 | 267 |
|
225 | 268 | auto mutation = testutil::SetMutation("rooms/eros", Map("name", "Eros"));
|
226 | 269 | MutationBatch batch = MutationBatch(23, Timestamp::Now(), {}, {mutation});
|
|
0 commit comments