XCUIElement+FBAccessibility.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 "XCUIElement+FBAccessibility.h"
  10. #import "FBConfiguration.h"
  11. #import "XCTestPrivateSymbols.h"
  12. #import "XCUIElement+FBUtilities.h"
  13. #import "FBXCElementSnapshotWrapper+Helpers.h"
  14. @implementation XCUIElement (FBAccessibility)
  15. - (BOOL)fb_isAccessibilityElement
  16. {
  17. id<FBXCElementSnapshot> snapshot = [self fb_snapshotWithAttributes:@[FB_XCAXAIsElementAttributeName]
  18. maxDepth:@1];
  19. return [FBXCElementSnapshotWrapper ensureWrapped:snapshot].fb_isAccessibilityElement;
  20. }
  21. @end
  22. @implementation FBXCElementSnapshotWrapper (FBAccessibility)
  23. - (BOOL)fb_isAccessibilityElement
  24. {
  25. NSNumber *isAccessibilityElement = self.additionalAttributes[FB_XCAXAIsElementAttribute];
  26. if (nil != isAccessibilityElement) {
  27. return isAccessibilityElement.boolValue;
  28. }
  29. return [(NSNumber *)[self fb_attributeValue:FB_XCAXAIsElementAttributeName] boolValue];
  30. }
  31. @end