XCUIDevice+FBHealthCheck.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "XCUIDevice+FBHealthCheck.h"
  10. #import "XCUIDevice+FBRotation.h"
  11. #import "XCUIApplication+FBHelpers.h"
  12. @implementation XCUIDevice (FBHealthCheck)
  13. - (BOOL)fb_healthCheckWithApplication:(nullable XCUIApplication *)application
  14. {
  15. if (![self fb_elementQueryCheckWithApplication:application]) {
  16. return NO;
  17. }
  18. if (![self fb_deviceInteractionCheck]) {
  19. return NO;
  20. }
  21. return YES;
  22. }
  23. - (BOOL)fb_elementQueryCheckWithApplication:(nullable XCUIApplication *)application
  24. {
  25. if (!application) {
  26. return NO;
  27. }
  28. if (!application.label) {
  29. return NO;
  30. }
  31. if ([application descendantsMatchingType:XCUIElementTypeAny].count == 0 ) {
  32. return NO;
  33. }
  34. return YES;
  35. }
  36. - (BOOL)fb_deviceInteractionCheck
  37. {
  38. [self pressButton:XCUIDeviceButtonHome];
  39. return YES;
  40. }
  41. @end