FBTouchActionCommands.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 "FBTouchActionCommands.h"
  10. #import "FBRoute.h"
  11. #import "FBRouteRequest.h"
  12. #import "FBSession.h"
  13. #import "XCUIApplication+FBTouchAction.h"
  14. @implementation FBTouchActionCommands
  15. #pragma mark - <FBCommandHandler>
  16. + (NSArray *)routes
  17. {
  18. return
  19. @[
  20. [[FBRoute POST:@"/actions"] respondWithTarget:self action:@selector(handlePerformW3CTouchActions:)],
  21. ];
  22. }
  23. #pragma mark - Commands
  24. + (id<FBResponsePayload>)handlePerformW3CTouchActions:(FBRouteRequest *)request
  25. {
  26. XCUIApplication *application = request.session.activeApplication;
  27. NSArray *actions = (NSArray *)request.arguments[@"actions"];
  28. NSError *error;
  29. if (![application fb_performW3CActions:actions elementCache:request.session.elementCache error:&error]) {
  30. return FBResponseWithUnknownError(error);
  31. }
  32. return FBResponseWithOK();
  33. }
  34. @end