FSTAPIHelpers.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "Firestore/Example/Tests/Util/FSTHelpers.h"
  18. #include "absl/strings/string_view.h"
  19. @class FIRCollectionReference;
  20. @class FIRDocumentReference;
  21. @class FIRDocumentSnapshot;
  22. @class FIRFirestore;
  23. @class FIRQuerySnapshot;
  24. NS_ASSUME_NONNULL_BEGIN
  25. #if __cplusplus
  26. extern "C" {
  27. #endif
  28. /** A convenience method for creating dummy singleton FIRFirestore for tests. */
  29. FIRFirestore *FSTTestFirestore();
  30. /** A convenience method for creating a doc snapshot for tests. */
  31. FIRDocumentSnapshot *FSTTestDocSnapshot(const absl::string_view path,
  32. FSTTestSnapshotVersion version,
  33. NSDictionary<NSString *, id> *_Nullable data,
  34. BOOL hasMutations,
  35. BOOL fromCache);
  36. /** A convenience method for creating a collection reference from a path string. */
  37. FIRCollectionReference *FSTTestCollectionRef(const absl::string_view path);
  38. /** A convenience method for creating a document reference from a path string. */
  39. FIRDocumentReference *FSTTestDocRef(const absl::string_view path);
  40. /**
  41. * A convenience method for creating a particular query snapshot for tests.
  42. *
  43. * @param path To be used in constructing the query.
  44. * @param oldDocs Provides the prior set of documents in the QuerySnapshot. Each dictionary entry
  45. * maps to a document, with the key being the document id, and the value being the document
  46. * contents.
  47. * @param docsToAdd Specifies data to be added into the query snapshot as of now. Each dictionary
  48. * entry maps to a document, with the key being the document id, and the value being the document
  49. * contents.
  50. * @param hasPendingWrites Whether the query snapshot has pending writes to the server.
  51. * @param fromCache Whether the query snapshot is cache result.
  52. * @returns A query snapshot that consists of both sets of documents.
  53. */
  54. FIRQuerySnapshot *FSTTestQuerySnapshot(
  55. const absl::string_view path,
  56. NSDictionary<NSString *, NSDictionary<NSString *, id> *> *oldDocs,
  57. NSDictionary<NSString *, NSDictionary<NSString *, id> *> *docsToAdd,
  58. BOOL hasPendingWrites,
  59. BOOL fromCache);
  60. #if __cplusplus
  61. } // extern "C"
  62. #endif
  63. NS_ASSUME_NONNULL_END