FABTestExpectations.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2019 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. @class FIRCLSFABAsyncOperation;
  16. @class XCTestCase;
  17. /// These blocks provide mechanisms to indirectly call XCTestCase assertion macros, since they
  18. /// require 'self' to be an XCTestCase. So, the test case adding expectations can pass along calls
  19. /// to XCTAssert... and XCTFail into the methods of this class.
  20. typedef void (^FABAsyncCompletionAssertionBlock)(NSString *operationName, NSError *error);
  21. typedef void (^FABPreFlightCancellationFailureAssertionBlock)(void);
  22. @interface FABTestExpectationObserver : NSObject
  23. @property(copy, nonatomic) FABPreFlightCancellationFailureAssertionBlock assertionBlock;
  24. @end
  25. @interface FABTestExpectations : NSObject
  26. /*
  27. The two following methods add XCTestExpectations for async operations that will be cancelled after
  28. they begin executing.
  29. */
  30. + (void)
  31. addInFlightCancellationCompletionExpectationsToOperation:(FIRCLSFABAsyncOperation *)operation
  32. testCase:(XCTestCase *)testCase
  33. assertionBlock:
  34. (FABAsyncCompletionAssertionBlock)assertionBlock;
  35. + (void)addInFlightCancellationKVOExpectationsToOperation:(FIRCLSFABAsyncOperation *)operation
  36. testCase:(XCTestCase *)testCase;
  37. /*
  38. The two following methods add XCTestExpectations for async operations that will be cancelled before
  39. they begin executing.
  40. */
  41. + (void)
  42. addPreFlightCancellationCompletionExpectationsToOperation:(FIRCLSFABAsyncOperation *)operation
  43. testCase:(XCTestCase *)testCase
  44. asyncAssertionBlock:
  45. (FABAsyncCompletionAssertionBlock)asyncAssertionBlock;
  46. + (FABTestExpectationObserver *)
  47. addPreFlightCancellationKVOExpectationsToOperation:(FIRCLSFABAsyncOperation *)operation
  48. testCase:(XCTestCase *)testCase;
  49. @end