FPRNSURLSessionInstrumentTestDelegates.h 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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
  43. * URLSession:dataTask:didReceiveResponse:completionHandler: is called, used
  44. * for testing.
  45. */
  46. @property(nonatomic) BOOL URLSessionDataTaskDidReceiveResponseCompletionHandlerCalled;
  47. /** Set to YES when URLSession:downloadTask:didFinishDownloadingToURL: is called, used for testing.
  48. */
  49. @property(nonatomic) BOOL URLSessionDownloadTaskDidFinishDownloadingToURLCalled;
  50. /** Set to YES when URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes is called, used for
  51. * testing.
  52. */
  53. @property(nonatomic) BOOL URLSessionDownloadTaskDidResumeAtOffsetExpectedTotalBytesCalled;
  54. /** Set to YES when
  55. * URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite: is called, used
  56. * for testing.
  57. */
  58. @property(nonatomic) BOOL URLSessionDownloadTaskDidWriteDataTotalBytesWrittenTotalBytesCalled;
  59. @end
  60. /** This class implements the methods necessary to cancel and resume a download. */
  61. @interface FPRNSURLSessionTestDownloadDelegate : NSObject <NSURLSessionDownloadDelegate>
  62. /** Set to YES when URLSession:downloadTask:didFinishDownloadingToURL: is called, used for testing.
  63. */
  64. @property(nonatomic) BOOL URLSessionDownloadTaskDidFinishDownloadingToURLCalled;
  65. /** Set to YES when URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes is called, used for
  66. * testing.
  67. */
  68. @property(nonatomic) BOOL URLSessionDownloadTaskDidResumeAtOffsetExpectedTotalBytesCalled;
  69. /** Set to YES when
  70. * URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite: is called, used
  71. * for testing.
  72. */
  73. @property(nonatomic) BOOL URLSessionDownloadTaskDidWriteDataTotalBytesWrittenTotalBytesCalled;
  74. @end
  75. NS_ASSUME_NONNULL_END