FSTTestingHooks.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. /** Returns whether the bloom filter contains the given document. */
  40. - (BOOL)mightContain:(FIRDocumentReference*)documentRef;
  41. @end // @interface FSTTestingHooksBloomFilter
  42. #pragma mark - FSTTestingHooksExistenceFilterMismatchInfo
  43. /**
  44. * Information about an existence filter mismatch.
  45. */
  46. @interface FSTTestingHooksExistenceFilterMismatchInfo : NSObject
  47. - (instancetype)init __attribute__((unavailable("instances cannot be created directly")));
  48. /** The number of documents that matched the query in the local cache. */
  49. @property(nonatomic, readonly) int localCacheCount;
  50. /**
  51. * The number of documents that matched the query on the server, as specified in the
  52. * `ExistenceFilter` message's `count` field.
  53. */
  54. @property(nonatomic, readonly) int existenceFilterCount;
  55. /**
  56. * Information about the bloom filter provided by Watch in the ExistenceFilter message's
  57. * `unchanged_names` field. If nil, then that means that Watch did _not_ provide a bloom filter.
  58. */
  59. @property(nonatomic, readonly, nullable) FSTTestingHooksBloomFilter* bloomFilter;
  60. @end
  61. #pragma mark - FSTTestingHooks
  62. /**
  63. * Manages "testing hooks", hooks into the internals of the SDK to verify internal state and events
  64. * during integration tests.
  65. */
  66. @interface FSTTestingHooks : NSObject
  67. - (instancetype)init __attribute__((unavailable("instances cannot be created")));
  68. /**
  69. * Captures all existence filter mismatches in the Watch 'Listen' stream that occur during the
  70. * execution of the given block.
  71. *
  72. * @param block The block to execute; during the execution of this block all existence filter
  73. * mismatches will be captured.
  74. *
  75. * @return the captured existence filter mismatches.
  76. */
  77. + (NSArray<FSTTestingHooksExistenceFilterMismatchInfo*>*)
  78. captureExistenceFilterMismatchesDuringBlock:(void (^)())block;
  79. @end
  80. NS_ASSUME_NONNULL_END