|
41 | 41 | #include "Firestore/core/src/bundle/bundle_reader.h"
|
42 | 42 | #include "Firestore/core/src/bundle/bundle_serializer.h"
|
43 | 43 | #include "Firestore/core/src/core/field_filter.h"
|
| 44 | +#import "Firestore/core/src/core/listen_options.h" |
44 | 45 | #include "Firestore/core/src/credentials/user.h"
|
45 | 46 | #include "Firestore/core/src/local/persistence.h"
|
46 | 47 | #include "Firestore/core/src/local/target_data.h"
|
|
79 | 80 | using firebase::firestore::Error;
|
80 | 81 | using firebase::firestore::google_firestore_v1_ArrayValue;
|
81 | 82 | using firebase::firestore::google_firestore_v1_Value;
|
| 83 | +using firebase::firestore::api::ListenSource; |
82 | 84 | using firebase::firestore::api::LoadBundleTask;
|
83 | 85 | using firebase::firestore::bundle::BundleReader;
|
84 | 86 | using firebase::firestore::bundle::BundleSerializer;
|
85 | 87 | using firebase::firestore::core::DocumentViewChange;
|
| 88 | +using firebase::firestore::core::ListenOptions; |
86 | 89 | using firebase::firestore::core::Query;
|
87 | 90 | using firebase::firestore::credentials::User;
|
88 | 91 | using firebase::firestore::local::Persistence;
|
@@ -385,11 +388,25 @@ - (DocumentViewChange)parseChange:(NSDictionary *)jsonDoc ofType:(DocumentViewCh
|
385 | 388 | return DocumentViewChange{std::move(doc), type};
|
386 | 389 | }
|
387 | 390 |
|
| 391 | +- (ListenOptions)parseOptions:(NSDictionary *)optionsSpec { |
| 392 | + ListenOptions options = ListenOptions::FromIncludeMetadataChanges(true); |
| 393 | + |
| 394 | + if (optionsSpec != nil) { |
| 395 | + ListenSource source = |
| 396 | + [optionsSpec[@"source"] isEqual:@"cache"] ? ListenSource::Cache : ListenSource::Default; |
| 397 | + // include_metadata_changes are default to true in spec tests |
| 398 | + options = ListenOptions::FromOptions(true, source); |
| 399 | + } |
| 400 | + |
| 401 | + return options; |
| 402 | +} |
| 403 | + |
388 | 404 | #pragma mark - Methods for doing the steps of the spec test.
|
389 | 405 |
|
390 | 406 | - (void)doListen:(NSDictionary *)listenSpec {
|
391 | 407 | Query query = [self parseQuery:listenSpec[@"query"]];
|
392 |
| - TargetId actualID = [self.driver addUserListenerWithQuery:std::move(query)]; |
| 408 | + ListenOptions options = [self parseOptions:listenSpec[@"options"]]; |
| 409 | + TargetId actualID = [self.driver addUserListenerWithQuery:std::move(query) options:options]; |
393 | 410 |
|
394 | 411 | TargetId expectedID = [listenSpec[@"targetId"] intValue];
|
395 | 412 | XCTAssertEqual(actualID, expectedID, @"targetID assigned to listen");
|
|
0 commit comments