FSTAPIHelpers.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. @class FIRCollectionReference;
  18. @class FIRDocumentReference;
  19. @class FIRDocumentSnapshot;
  20. @class FIRFirestore;
  21. @class FIRQuerySnapshot;
  22. /** Allow tests to just use an int literal for versions. */
  23. typedef int64_t FSTTestSnapshotVersion;
  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 char *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 char *path);
  38. /** A convenience method for creating a document reference from a path string. */
  39. FIRDocumentReference *FSTTestDocRef(const char *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 char *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