FBResponsePayload.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <Foundation/Foundation.h>
  10. #import <WebDriverAgentLib/FBCommandStatus.h>
  11. @class FBElementCache;
  12. @class RouteResponse;
  13. @class XCUIElement;
  14. @protocol FBResponsePayload;
  15. NS_ASSUME_NONNULL_BEGIN
  16. /**
  17. Returns 'FBCommandStatusNoError' response payload
  18. */
  19. id<FBResponsePayload> FBResponseWithOK(void);
  20. /**
  21. Returns 'FBCommandStatusNoError' response payload with given 'object'
  22. */
  23. id<FBResponsePayload> FBResponseWithObject(id _Nullable object);
  24. /**
  25. Returns 'FBCommandStatusNoError' response payload with given 'element', which will be also cached in 'elementCache'
  26. */
  27. id<FBResponsePayload> FBResponseWithCachedElement(XCUIElement *element, FBElementCache *elementCache, BOOL compact);
  28. /**
  29. Returns 'FBCommandStatusNoError' response payload with given array of 'elements', which will be also cached in 'elementCache'
  30. */
  31. id<FBResponsePayload> FBResponseWithCachedElements(NSArray<XCUIElement *> *elements, FBElementCache *elementCache, BOOL compact);
  32. /**
  33. Returns 'FBCommandStatusUnhandled' response payload with given error's description
  34. */
  35. id<FBResponsePayload> FBResponseWithUnknownError(NSError *error);
  36. /**
  37. Returns 'FBCommandStatusUnhandled' response payload with given error message
  38. */
  39. id<FBResponsePayload> FBResponseWithUnknownErrorFormat(NSString *errorFormat, ...) NS_FORMAT_FUNCTION(1,2);
  40. /**
  41. Returns 'status' response payload with given object
  42. */
  43. id<FBResponsePayload> FBResponseWithStatus(FBCommandStatus *status);
  44. /**
  45. Returns a response payload as a NSDictionary for given element.
  46. Set compact=NO to include further attributes (defined by FBConfiguration.elementResponseAttributes)
  47. */
  48. NSDictionary *FBDictionaryResponseWithElement(XCUIElement *element, BOOL compact);
  49. /**
  50. Protocol for objects that can dispatch some kind of a payload for given 'response'
  51. */
  52. @protocol FBResponsePayload <NSObject>
  53. /**
  54. Dispatch constructed payload into given response
  55. */
  56. - (void)dispatchWithResponse:(RouteResponse *)response;
  57. @end
  58. NS_ASSUME_NONNULL_END