XCUIElementHelperIntegrationTests.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <XCTest/XCTest.h>
  10. #import "XCTest/XCUIElementTypes.h"
  11. #import "FBIntegrationTestCase.h"
  12. #import "FBTestMacros.h"
  13. #import "FBElement.h"
  14. #import "FBElementUtils.h"
  15. #import "FBXCElementSnapshot.h"
  16. #import "XCUIElement+FBUtilities.h"
  17. @interface XCUIElementHelperIntegrationTests : FBIntegrationTestCase
  18. @end
  19. @implementation XCUIElementHelperIntegrationTests
  20. - (void)setUp
  21. {
  22. [super setUp];
  23. [self launchApplication];
  24. [self goToAlertsPage];
  25. }
  26. - (void)testDescendantsFiltering
  27. {
  28. NSArray<XCUIElement *> *buttons = self.testedApplication.buttons.allElementsBoundByIndex;
  29. XCTAssertTrue(buttons.count > 0);
  30. NSArray<XCUIElement *> *windows = self.testedApplication.windows.allElementsBoundByIndex;
  31. XCTAssertTrue(windows.count > 0);
  32. NSMutableArray<XCUIElement *> *allElements = [NSMutableArray array];
  33. [allElements addObjectsFromArray:buttons];
  34. [allElements addObjectsFromArray:windows];
  35. NSMutableArray<id<FBXCElementSnapshot>> *buttonSnapshots = [NSMutableArray array];
  36. [buttonSnapshots addObject:[buttons.firstObject fb_customSnapshot]];
  37. NSArray<XCUIElement *> *result = [self.testedApplication fb_filterDescendantsWithSnapshots:buttonSnapshots
  38. onlyChildren:NO];
  39. XCTAssertEqual(1, result.count);
  40. XCTAssertEqual([result.firstObject elementType], XCUIElementTypeButton);
  41. }
  42. @end