22
22
#import " Firestore/Source/Local/FSTPersistence.h"
23
23
#import " Firestore/Source/Local/FSTQueryData.h"
24
24
#import " Firestore/Source/Local/FSTWriteGroup.h"
25
- #import " Firestore/Source/Model/FSTDocumentKey.h"
26
25
27
26
#import " Firestore/Example/Tests/Util/FSTHelpers.h"
28
27
#import " Firestore/third_party/Immutable/Tests/FSTImmutableSortedSet+Testing.h"
29
28
29
+ #include " Firestore/core/src/firebase/firestore/model/document_key.h"
30
+ #include " Firestore/core/test/firebase/firestore/testutil/testutil.h"
31
+
32
+ namespace testutil = firebase::firestore::testutil;
33
+ using firebase::firestore::model::DocumentKey;
34
+
30
35
NS_ASSUME_NONNULL_BEGIN
31
36
32
37
@implementation FSTQueryCacheTests {
@@ -164,8 +169,8 @@ - (void)testRemoveQueryRemovesMatchingKeysToo {
164
169
FSTQueryData *rooms = [self queryDataWithQuery: _queryRooms];
165
170
[self .queryCache addQueryData: rooms group: group];
166
171
167
- FSTDocumentKey * key1 = FSTTestDocKey ( @ " rooms/foo" );
168
- FSTDocumentKey * key2 = FSTTestDocKey ( @ " rooms/bar" );
172
+ DocumentKey key1 = testutil::Key ( " rooms/foo" );
173
+ DocumentKey key2 = testutil::Key ( " rooms/bar" );
169
174
[self addMatchingKey: key1 forTargetID: rooms.targetID group: group];
170
175
[self addMatchingKey: key2 forTargetID: rooms.targetID group: group];
171
176
@@ -182,7 +187,7 @@ - (void)testAddOrRemoveMatchingKeys {
182
187
if ([self isTestBaseClass ]) return ;
183
188
184
189
FSTWriteGroup *group = [self .persistence startGroupWithAction: @" AddOrRemoveMatchingKeys" ];
185
- FSTDocumentKey * key = FSTTestDocKey ( @ " foo/bar" );
190
+ DocumentKey key = testutil::Key ( " foo/bar" );
186
191
187
192
XCTAssertFalse ([self .queryCache containsKey: key]);
188
193
@@ -204,9 +209,9 @@ - (void)testRemoveMatchingKeysForTargetID {
204
209
if ([self isTestBaseClass ]) return ;
205
210
206
211
FSTWriteGroup *group = [self .persistence startGroupWithAction: @" RemoveMatchingKeysForTargetID" ];
207
- FSTDocumentKey * key1 = FSTTestDocKey ( @ " foo/bar" );
208
- FSTDocumentKey * key2 = FSTTestDocKey ( @ " foo/baz" );
209
- FSTDocumentKey * key3 = FSTTestDocKey ( @ " foo/blah" );
212
+ DocumentKey key1 = testutil::Key ( " foo/bar" );
213
+ DocumentKey key2 = testutil::Key ( " foo/baz" );
214
+ DocumentKey key3 = testutil::Key ( " foo/blah" );
210
215
211
216
[self addMatchingKey: key1 forTargetID: 1 group: group];
212
217
[self addMatchingKey: key2 forTargetID: 1 group: group];
@@ -233,42 +238,42 @@ - (void)testRemoveEmitsGarbageEvents {
233
238
FSTWriteGroup *group = [self .persistence startGroupWithAction: @" RemoveEmitsGarbageEvents" ];
234
239
FSTEagerGarbageCollector *garbageCollector = [[FSTEagerGarbageCollector alloc ] init ];
235
240
[garbageCollector addGarbageSource: self .queryCache];
236
- FSTAssertEqualSets ([garbageCollector collectGarbage ], @[] );
241
+ XCTAssertEqual ([garbageCollector collectGarbage ], std::set<DocumentKey>({}) );
237
242
238
243
FSTQueryData *rooms = [self queryDataWithQuery: FSTTestQuery (" rooms" )];
239
- FSTDocumentKey * room1 = FSTTestDocKey ( @ " rooms/bar" );
240
- FSTDocumentKey * room2 = FSTTestDocKey ( @ " rooms/foo" );
244
+ DocumentKey room1 = testutil::Key ( " rooms/bar" );
245
+ DocumentKey room2 = testutil::Key ( " rooms/foo" );
241
246
[self .queryCache addQueryData: rooms group: group];
242
247
[self addMatchingKey: room1 forTargetID: rooms.targetID group: group];
243
248
[self addMatchingKey: room2 forTargetID: rooms.targetID group: group];
244
249
245
250
FSTQueryData *halls = [self queryDataWithQuery: FSTTestQuery (" halls" )];
246
- FSTDocumentKey * hall1 = FSTTestDocKey ( @ " halls/bar" );
247
- FSTDocumentKey * hall2 = FSTTestDocKey ( @ " halls/foo" );
251
+ DocumentKey hall1 = testutil::Key ( " halls/bar" );
252
+ DocumentKey hall2 = testutil::Key ( " halls/foo" );
248
253
[self .queryCache addQueryData: halls group: group];
249
254
[self addMatchingKey: hall1 forTargetID: halls.targetID group: group];
250
255
[self addMatchingKey: hall2 forTargetID: halls.targetID group: group];
251
256
252
- FSTAssertEqualSets ([garbageCollector collectGarbage ], @[] );
257
+ XCTAssertEqual ([garbageCollector collectGarbage ], std::set<DocumentKey>({}) );
253
258
254
259
[self removeMatchingKey: room1 forTargetID: rooms.targetID group: group];
255
- FSTAssertEqualSets ([garbageCollector collectGarbage ], @[ room1 ] );
260
+ XCTAssertEqual ([garbageCollector collectGarbage ], std::set<DocumentKey>({ room1}) );
256
261
257
262
[self .queryCache removeQueryData: rooms group: group];
258
- FSTAssertEqualSets ([garbageCollector collectGarbage ], @[ room2 ] );
263
+ XCTAssertEqual ([garbageCollector collectGarbage ], std::set<DocumentKey>({ room2}) );
259
264
260
265
[self .queryCache removeMatchingKeysForTargetID: halls.targetID group: group];
261
- FSTAssertEqualSets ([garbageCollector collectGarbage ], (@[ hall1, hall2 ] ));
266
+ XCTAssertEqual ([garbageCollector collectGarbage ], std::set<DocumentKey>({ hall1, hall2} ));
262
267
[self .persistence commitGroup: group];
263
268
}
264
269
265
270
- (void )testMatchingKeysForTargetID {
266
271
if ([self isTestBaseClass ]) return ;
267
272
268
273
FSTWriteGroup *group = [self .persistence startGroupWithAction: @" MatchingKeysForTargetID" ];
269
- FSTDocumentKey * key1 = FSTTestDocKey ( @ " foo/bar" );
270
- FSTDocumentKey * key2 = FSTTestDocKey ( @ " foo/baz" );
271
- FSTDocumentKey * key3 = FSTTestDocKey ( @ " foo/blah" );
274
+ DocumentKey key1 = testutil::Key ( " foo/bar" );
275
+ DocumentKey key2 = testutil::Key ( " foo/baz" );
276
+ DocumentKey key3 = testutil::Key ( " foo/blah" );
272
277
273
278
[self addMatchingKey: key1 forTargetID: 1 group: group];
274
279
[self addMatchingKey: key2 forTargetID: 1 group: group];
@@ -335,8 +340,8 @@ - (void)testHighestTargetID {
335
340
targetID: 1
336
341
listenSequenceNumber: 10
337
342
purpose: FSTQueryPurposeListen];
338
- FSTDocumentKey * key1 = FSTTestDocKey ( @ " rooms/bar" );
339
- FSTDocumentKey * key2 = FSTTestDocKey ( @ " rooms/foo" );
343
+ DocumentKey key1 = testutil::Key ( " rooms/bar" );
344
+ DocumentKey key2 = testutil::Key ( " rooms/foo" );
340
345
[self .queryCache addQueryData: query1 group: group];
341
346
[self addMatchingKey: key1 forTargetID: 1 group: group];
342
347
[self addMatchingKey: key2 forTargetID: 1 group: group];
@@ -345,7 +350,7 @@ - (void)testHighestTargetID {
345
350
targetID: 2
346
351
listenSequenceNumber: 20
347
352
purpose: FSTQueryPurposeListen];
348
- FSTDocumentKey * key3 = FSTTestDocKey ( @ " halls/foo" );
353
+ DocumentKey key3 = testutil::Key ( " halls/foo" );
349
354
[self .queryCache addQueryData: query2 group: group];
350
355
[self addMatchingKey: key3 forTargetID: 2 group: group];
351
356
XCTAssertEqual ([self .queryCache highestTargetID ], 2 );
@@ -419,15 +424,15 @@ - (FSTQueryData *)queryDataWithQuery:(FSTQuery *)query
419
424
resumeToken: resumeToken];
420
425
}
421
426
422
- - (void )addMatchingKey : (FSTDocumentKey * )key
427
+ - (void )addMatchingKey : (cons DocumentKey & )key
423
428
forTargetID : (FSTTargetID)targetID
424
429
group : (FSTWriteGroup *)group {
425
430
FSTDocumentKeySet *keys = [FSTDocumentKeySet keySet ];
426
431
keys = [keys setByAddingObject: key];
427
432
[self .queryCache addMatchingKeys: keys forTargetID: targetID group: group];
428
433
}
429
434
430
- - (void )removeMatchingKey : (FSTDocumentKey * )key
435
+ - (void )removeMatchingKey : (const DocumentKey & )key
431
436
forTargetID : (FSTTargetID)targetID
432
437
group : (FSTWriteGroup *)group {
433
438
FSTDocumentKeySet *keys = [FSTDocumentKeySet keySet ];
0 commit comments