XCTestCase+Await.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <XCTest/XCTest.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * Force the linker to see these extensions even if compiled without -ObjC.
  20. */
  21. void LoadXCTestCaseAwait();
  22. /**
  23. * FSTVoidErrorBlock is a block that gets an error, if one occurred.
  24. *
  25. * @param error The error if it occurred, or nil.
  26. */
  27. typedef void (^FSTVoidErrorBlock)(NSError *_Nullable error);
  28. @interface XCTestCase (Await)
  29. /**
  30. * Await all outstanding expectations with a reasonable timeout, and if any of them fail, XCTFail
  31. * the test.
  32. */
  33. - (void)awaitExpectations;
  34. /**
  35. * Returns a reasonable timeout for testing against Firestore.
  36. */
  37. - (double)defaultExpectationWaitSeconds;
  38. /**
  39. * Returns a completion block that fulfills a newly-created expectation with the specified
  40. * name.
  41. */
  42. - (FSTVoidErrorBlock)completionForExpectationWithName:(NSString *)expectationName;
  43. @end
  44. NS_ASSUME_NONNULL_END