OCMStubRecorder+FIRAuthUnitTests.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <OCMock/OCMStubRecorder.h>
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** @typedef FIRAuthGeneralBlock1
  20. @brief A general block that takes one id and returns nothing.
  21. */
  22. typedef void (^FIRAuthGeneralBlock1)(id);
  23. /** @typedef FIRAuthGeneralBlock2
  24. @brief A general block that takes two nullable ids and returns nothing.
  25. */
  26. typedef void (^FIRAuthGeneralBlock2)(id _Nullable, id _Nullable);
  27. /** @typedef FIRAuthIdDoubleIdBlock
  28. @brief A block that takes third parameters with types @c id, @c double, and @c id .
  29. */
  30. typedef void (^FIRAuthIdDoubleIdBlock)(id, double, id);
  31. /** @category OCMStubRecorder(FIRAuthUnitTests)
  32. @brief Utility methods and properties use by Firebase Auth unit tests.
  33. */
  34. @interface OCMStubRecorder (FIRAuthUnitTests)
  35. /** @fn andCallBlock1
  36. @brief Calls a general block that takes one parameter as the action of the stub.
  37. @param block1 A block that takes exactly one 'id'-compatible parameter.
  38. @remarks The method being stubbed must take exactly one parameter, which must be
  39. compatible with type 'id'.
  40. */
  41. - (id)andCallBlock1:(FIRAuthGeneralBlock1)block1;
  42. /** @fn andCallBlock2
  43. @brief Calls a general block that takes two parameters as the action of the stub.
  44. @param block2 A block that takes exactly two 'id'-compatible parameters.
  45. @remarks The method being stubbed must take exactly two parameters, both of which must be
  46. compatible with type 'id'.
  47. */
  48. - (id)andCallBlock2:(FIRAuthGeneralBlock2)block2;
  49. /** @fn andDispatchError2
  50. @brief Dispatchs an error to the second callback parameter in the global auth work queue.
  51. @param error The error to call back as the second argument to the second parameter block.
  52. @remarks The method being stubbed must take exactly two parameters, the first of which must be
  53. compatible with type 'id' and the second of which must be a block that takes an
  54. 'id'-compatible parameter and an NSError* parameter.
  55. */
  56. - (id)andDispatchError2:(NSError *)error;
  57. /** @fn andCallIdDoubleIdBlock:
  58. @brief Calls a block that takes three parameters as the action of the stub.
  59. @param block A block that takes exactly three parameters as described.
  60. @remarks The method being stubbed must take exactly three parameters. Its first and the third
  61. parameters must be compatible with type 'id' and its second parameter must be a 'double'.
  62. */
  63. - (id)andCallIdDoubleIdBlock:(FIRAuthIdDoubleIdBlock)block;
  64. // This macro allows .andCallBlock1 shorthand to match established style of OCMStubRecorder.
  65. #define andCallBlock1(block1) _andCallBlock1(block1)
  66. // This macro allows .andCallBlock2 shorthand to match established style of OCMStubRecorder.
  67. #define andCallBlock2(block2) _andCallBlock2(block2)
  68. // This macro allows .andDispatchError2 shorthand to match established style of OCMStubRecorder.
  69. #define andDispatchError2(block2) _andDispatchError2(block2)
  70. // This macro allows .andCallIdDoubleIdBlock shorthand to match established style of
  71. // OCMStubRecorder.
  72. #define andCallIdDoubleIdBlock(block) _andCallIdDoubleIdBlock(block)
  73. /** @property _andCallBlock1
  74. @brief A block that calls @c andCallBlock1: method on self.
  75. */
  76. @property(nonatomic, readonly) OCMStubRecorder * (^_andCallBlock1)(FIRAuthGeneralBlock1);
  77. /** @property _andCallBlock2
  78. @brief A block that calls @c andCallBlock2: method on self.
  79. */
  80. @property(nonatomic, readonly) OCMStubRecorder * (^_andCallBlock2)(FIRAuthGeneralBlock2);
  81. /** @property _andDispatchError2
  82. @brief A block that calls @c andDispatchError2: method on self.
  83. */
  84. @property(nonatomic, readonly) OCMStubRecorder * (^_andDispatchError2)(NSError *);
  85. /** @property _andCallIdDoubleIdBlock
  86. @brief A block that calls @c andCallBlock2: method on self.
  87. */
  88. @property(nonatomic, readonly) OCMStubRecorder * (^_andCallIdDoubleIdBlock)(FIRAuthIdDoubleIdBlock);
  89. @end
  90. NS_ASSUME_NONNULL_END