FSTTestingHooks.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright 2023 Google LLC
  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. // NOTE: For Swift compatibility, please keep this header Objective-C only.
  17. // Swift cannot interact with any C++ definitions.
  18. #import <Foundation/Foundation.h>
  19. @class FIRDocumentReference;
  20. NS_ASSUME_NONNULL_BEGIN
  21. #pragma mark - FSTTestingHooksBloomFilter
  22. /**
  23. * Information about the bloom filter provided by Watch in the ExistenceFilter message's
  24. * `unchanged_names` field.
  25. */
  26. @interface FSTTestingHooksBloomFilter : NSObject
  27. - (instancetype)init __attribute__((unavailable("instances cannot be created directly")));
  28. /**
  29. * Whether a full requery was averted by using the bloom filter. If false, then something happened,
  30. * such as a false positive, to prevent using the bloom filter to avoid a full requery.
  31. */
  32. @property(nonatomic, readonly) BOOL applied;
  33. /** The number of hash functions used in the bloom filter. */
  34. @property(nonatomic, readonly) int hashCount;
  35. /** The number of bytes in the bloom filter's bitmask. */
  36. @property(nonatomic, readonly) int bitmapLength;
  37. /** The number of bits of padding in the last byte of the bloom filter. */
  38. @property(nonatomic, readonly) int padding;
  39. @end // @interface FSTTestingHooksBloomFilter
  40. #pragma mark - FSTTestingHooksExistenceFilterMismatchInfo
  41. /**
  42. * Information about an existence filter mismatch.
  43. */
  44. @interface FSTTestingHooksExistenceFilterMismatchInfo : NSObject
  45. - (instancetype)init __attribute__((unavailable("instances cannot be created directly")));
  46. /** The number of documents that matched the query in the local cache. */
  47. @property(nonatomic, readonly) int localCacheCount;
  48. /**
  49. * The number of documents that matched the query on the server, as specified in the
  50. * `ExistenceFilter` message's `count` field.
  51. */
  52. @property(nonatomic, readonly) int existenceFilterCount;
  53. /**
  54. * Information about the bloom filter provided by Watch in the ExistenceFilter message's
  55. * `unchanged_names` field. If nil, then that means that Watch did _not_ provide a bloom filter.
  56. */
  57. @property(nonatomic, readonly, nullable) FSTTestingHooksBloomFilter* bloomFilter;
  58. @end
  59. #pragma mark - FSTTestingHooks
  60. /**
  61. * Manages "testing hooks", hooks into the internals of the SDK to verify internal state and events
  62. * during integration tests.
  63. */
  64. @interface FSTTestingHooks : NSObject
  65. - (instancetype)init __attribute__((unavailable("instances cannot be created")));
  66. /**
  67. * Captures all existence filter mismatches in the Watch 'Listen' stream that occur during the
  68. * execution of the given block.
  69. *
  70. * @param block The block to execute; during the execution of this block all existence filter
  71. * mismatches will be captured.
  72. *
  73. * @return the captured existence filter mismatches.
  74. */
  75. + (NSArray<FSTTestingHooksExistenceFilterMismatchInfo*>*)
  76. captureExistenceFilterMismatchesDuringBlock:(void (^)())block;
  77. @end
  78. NS_ASSUME_NONNULL_END