@@ -78,14 +78,12 @@ @interface FSTQueryListenerTests : XCTestCase
78
78
79
79
@implementation FSTQueryListenerTests {
80
80
DelayedConstructor<ExecutorLibdispatch> _executor;
81
- FSTListenOptions * _includeMetadataChanges;
81
+ ListenOptions _includeMetadataChanges;
82
82
}
83
83
84
84
- (void )setUp {
85
85
_executor.Init (dispatch_queue_create (" FSTQueryListenerTests Queue" , DISPATCH_QUEUE_SERIAL));
86
- _includeMetadataChanges = [[FSTListenOptions alloc ] initWithIncludeQueryMetadataChanges: YES
87
- includeDocumentMetadataChanges: YES
88
- waitForSyncWhenOnline: NO ];
86
+ _includeMetadataChanges = ListenOptions::FromIncludeMetadataChanges (true );
89
87
}
90
88
91
89
- (void )testRaisesCollectionEvents {
@@ -248,9 +246,10 @@ - (void)testRaisesDocumentMetadataEventsOnlyWhenSpecified {
248
246
FSTTestDoc (" rooms/Eros" , 1 , @{@" name" : @" Eros" }, FSTDocumentStateSynced);
249
247
FSTDocument *doc3 = FSTTestDoc (" rooms/Other" , 3 , @{@" name" : @" Other" }, FSTDocumentStateSynced);
250
248
251
- FSTListenOptions *options = [[FSTListenOptions alloc ] initWithIncludeQueryMetadataChanges: NO
252
- includeDocumentMetadataChanges: YES
253
- waitForSyncWhenOnline: NO ];
249
+ ListenOptions options (
250
+ /* include_query_metadata_changes=*/ false ,
251
+ /* include_document_metadata_changes=*/ true ,
252
+ /* wait_for_sync_when_online=*/ false );
254
253
255
254
FSTQueryListener *filteredListener = [self listenToQuery: query
256
255
accumulatingSnapshots: &filteredAccum];
@@ -300,9 +299,10 @@ - (void)testRaisesQueryMetadataEventsOnlyWhenHasPendingWritesOnTheQueryChanges {
300
299
FSTTestDoc (" rooms/Hades" , 2 , @{@" name" : @" Hades" }, FSTDocumentStateSynced);
301
300
FSTDocument *doc3 = FSTTestDoc (" rooms/Other" , 3 , @{@" name" : @" Other" }, FSTDocumentStateSynced);
302
301
303
- FSTListenOptions *options = [[FSTListenOptions alloc ] initWithIncludeQueryMetadataChanges: YES
304
- includeDocumentMetadataChanges: NO
305
- waitForSyncWhenOnline: NO ];
302
+ ListenOptions options (
303
+ /* include_query_metadata_changes=*/ true ,
304
+ /* include_document_metadata_changes=*/ false ,
305
+ /* wait_for_sync_when_online=*/ false );
306
306
FSTQueryListener *fullListener = [self listenToQuery: query
307
307
options: options
308
308
accumulatingSnapshots: &fullAccum];
@@ -373,12 +373,14 @@ - (void)testWillWaitForSyncIfOnline {
373
373
FSTQuery *query = FSTTestQuery (" rooms" );
374
374
FSTDocument *doc1 = FSTTestDoc (" rooms/Eros" , 1 , @{@" name" : @" Eros" }, FSTDocumentStateSynced);
375
375
FSTDocument *doc2 = FSTTestDoc (" rooms/Hades" , 2 , @{@" name" : @" Hades" }, FSTDocumentStateSynced);
376
- FSTQueryListener *listener =
377
- [self listenToQuery: query
378
- options: [[FSTListenOptions alloc ] initWithIncludeQueryMetadataChanges: NO
379
- includeDocumentMetadataChanges: NO
380
- waitForSyncWhenOnline: YES ]
381
- accumulatingSnapshots: &events];
376
+
377
+ ListenOptions options (
378
+ /* include_query_metadata_changes=*/ false ,
379
+ /* include_document_metadata_changes=*/ false ,
380
+ /* wait_for_sync_when_online=*/ true );
381
+ FSTQueryListener *listener = [self listenToQuery: query
382
+ options: options
383
+ accumulatingSnapshots: &events];
382
384
383
385
FSTView *view = [[FSTView alloc ] initWithQuery: query remoteDocuments: DocumentKeySet{}];
384
386
ViewSnapshot snap1 = FSTTestApplyChanges (view, @[ doc1 ], absl::nullopt ).value ();
@@ -412,12 +414,15 @@ - (void)testWillRaiseInitialEventWhenGoingOffline {
412
414
FSTQuery *query = FSTTestQuery (" rooms" );
413
415
FSTDocument *doc1 = FSTTestDoc (" rooms/Eros" , 1 , @{@" name" : @" Eros" }, FSTDocumentStateSynced);
414
416
FSTDocument *doc2 = FSTTestDoc (" rooms/Hades" , 2 , @{@" name" : @" Hades" }, FSTDocumentStateSynced);
415
- FSTQueryListener *listener =
416
- [self listenToQuery: query
417
- options: [[FSTListenOptions alloc ] initWithIncludeQueryMetadataChanges: NO
418
- includeDocumentMetadataChanges: NO
419
- waitForSyncWhenOnline: YES ]
420
- accumulatingSnapshots: &events];
417
+
418
+ ListenOptions options (
419
+ /* include_query_metadata_changes=*/ false ,
420
+ /* include_document_metadata_changes=*/ false ,
421
+ /* wait_for_sync_when_online=*/ true );
422
+
423
+ FSTQueryListener *listener = [self listenToQuery: query
424
+ options: options
425
+ accumulatingSnapshots: &events];
421
426
422
427
FSTView *view = [[FSTView alloc ] initWithQuery: query remoteDocuments: DocumentKeySet{}];
423
428
ViewSnapshot snap1 = FSTTestApplyChanges (view, @[ doc1 ], absl::nullopt ).value ();
@@ -457,7 +462,7 @@ - (void)testWillRaiseInitialEventWhenGoingOfflineAndThereAreNoDocs {
457
462
458
463
FSTQuery *query = FSTTestQuery (" rooms" );
459
464
FSTQueryListener *listener = [self listenToQuery: query
460
- options: [FSTListenOptions defaultOptions ]
465
+ options:ListenOptions: : DefaultOptions ()
461
466
accumulatingSnapshots: &events];
462
467
463
468
FSTView *view = [[FSTView alloc ] initWithQuery: query remoteDocuments: DocumentKeySet{}];
@@ -483,7 +488,7 @@ - (void)testWillRaiseInitialEventWhenStartingOfflineAndThereAreNoDocs {
483
488
484
489
FSTQuery *query = FSTTestQuery (" rooms" );
485
490
FSTQueryListener *listener = [self listenToQuery: query
486
- options: [FSTListenOptions defaultOptions ]
491
+ options:ListenOptions: : DefaultOptions ()
487
492
accumulatingSnapshots: &events];
488
493
489
494
FSTView *view = [[FSTView alloc ] initWithQuery: query remoteDocuments: DocumentKeySet{}];
@@ -505,12 +510,12 @@ - (void)testWillRaiseInitialEventWhenStartingOfflineAndThereAreNoDocs {
505
510
506
511
- (FSTQueryListener *)listenToQuery : (FSTQuery *)query handler : (ViewSnapshotHandler &&)handler {
507
512
return [[FSTQueryListener alloc ] initWithQuery: query
508
- options: [FSTListenOptions defaultOptions ]
513
+ options:ListenOptions: : DefaultOptions ()
509
514
viewSnapshotHandler:std: :move (handler)];
510
515
}
511
516
512
517
- (FSTQueryListener *)listenToQuery : (FSTQuery *)query
513
- options : (FSTListenOptions * )options
518
+ options : (ListenOptions )options
514
519
accumulatingSnapshots : (std::vector<ViewSnapshot> *)values {
515
520
return [[FSTQueryListener alloc ] initWithQuery: query
516
521
options: options
@@ -522,7 +527,7 @@ - (FSTQueryListener *)listenToQuery:(FSTQuery *)query
522
527
- (FSTQueryListener *)listenToQuery : (FSTQuery *)query
523
528
accumulatingSnapshots : (std::vector<ViewSnapshot> *)values {
524
529
return [self listenToQuery: query
525
- options: [FSTListenOptions defaultOptions ]
530
+ options:ListenOptions: : DefaultOptions ()
526
531
accumulatingSnapshots: values];
527
532
}
528
533
0 commit comments