FPRNSURLSessionInstrumentTestDelegates.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright 2020 Google LLC
  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. NS_ASSUME_NONNULL_BEGIN
  16. /** This class implements a single method of NSURLSessionDelegate to be used during testing. */
  17. @interface FPRNSURLSessionTestDelegate : NSObject <NSURLSessionDelegate>
  18. /** Is set to YES when URLSession:didBecomeInvalidWithError is called. */
  19. @property(nonatomic) BOOL URLSessionDidBecomeInvalidWithErrorWasCalled;
  20. /** Set to YES when didCallNonStandardDelegateMethod is called, used for testing. */
  21. @property(nonatomic) BOOL nonStandardDelegateMethodCalled;
  22. /** Sets nonStandardDelegateMethodCalled to YES. */
  23. - (void)didCallNonStandardDelegateMethod;
  24. @end
  25. /** This class implements all NSURLSession delegates to test methods used for automated tracing. */
  26. @interface FPRNSURLSessionCompleteTestDelegate : NSObject <NSURLSessionDelegate,
  27. NSURLSessionTaskDelegate,
  28. NSURLSessionDataDelegate,
  29. NSURLSessionDownloadDelegate>
  30. /** Set to YES when URLSession:task:didCompleteWithError: is called, used for testing. */
  31. @property(nonatomic) BOOL URLSessionTaskDidCompleteWithErrorCalled;
  32. /** Set to YES when URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:
  33. * is called, used for testing.
  34. */
  35. @property(nonatomic) BOOL URLSessionTaskDidSendBodyDataTotalBytesSentTotalBytesExpectedCalled;
  36. /** Set to YES when URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler: is
  37. * called, used for testing.
  38. */
  39. @property(nonatomic) BOOL URLSessionTaskWillPerformHTTPRedirectionNewRequestCompletionHandlerCalled;
  40. /** Set to YES when URLSession:dataTask:didReceiveData: is called, used for testing. */
  41. @property(nonatomic) BOOL URLSessionDataTaskDidReceiveDataCalled;
  42. /** Set to YES when URLSession:downloadTask:didFinishDownloadingToURL: is called, used for testing.
  43. */
  44. @property(nonatomic) BOOL URLSessionDownloadTaskDidFinishDownloadingToURLCalled;
  45. /** Set to YES when URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes is called, used for
  46. * testing.
  47. */
  48. @property(nonatomic) BOOL URLSessionDownloadTaskDidResumeAtOffsetExpectedTotalBytesCalled;
  49. /** Set to YES when
  50. * URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite: is called, used
  51. * for testing.
  52. */
  53. @property(nonatomic) BOOL URLSessionDownloadTaskDidWriteDataTotalBytesWrittenTotalBytesCalled;
  54. @end
  55. /** This class implements the methods necessary to cancel and resume a download. */
  56. @interface FPRNSURLSessionTestDownloadDelegate : NSObject <NSURLSessionDownloadDelegate>
  57. /** Set to YES when URLSession:downloadTask:didFinishDownloadingToURL: is called, used for testing.
  58. */
  59. @property(nonatomic) BOOL URLSessionDownloadTaskDidFinishDownloadingToURLCalled;
  60. /** Set to YES when URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes is called, used for
  61. * testing.
  62. */
  63. @property(nonatomic) BOOL URLSessionDownloadTaskDidResumeAtOffsetExpectedTotalBytesCalled;
  64. /** Set to YES when
  65. * URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite: is called, used
  66. * for testing.
  67. */
  68. @property(nonatomic) BOOL URLSessionDownloadTaskDidWriteDataTotalBytesWrittenTotalBytesCalled;
  69. @end
  70. NS_ASSUME_NONNULL_END