/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #import #import "XCTest/XCUIElementTypes.h" #import "FBIntegrationTestCase.h" #import "FBTestMacros.h" #import "FBElement.h" #import "FBElementUtils.h" #import "FBXCElementSnapshot.h" #import "XCUIElement+FBUtilities.h" @interface XCUIElementHelperIntegrationTests : FBIntegrationTestCase @end @implementation XCUIElementHelperIntegrationTests - (void)setUp { [super setUp]; [self launchApplication]; [self goToAlertsPage]; } - (void)testDescendantsFiltering { NSArray *buttons = self.testedApplication.buttons.allElementsBoundByIndex; XCTAssertTrue(buttons.count > 0); NSArray *windows = self.testedApplication.windows.allElementsBoundByIndex; XCTAssertTrue(windows.count > 0); NSMutableArray *allElements = [NSMutableArray array]; [allElements addObjectsFromArray:buttons]; [allElements addObjectsFromArray:windows]; NSMutableArray> *buttonSnapshots = [NSMutableArray array]; [buttonSnapshots addObject:[buttons.firstObject fb_customSnapshot]]; NSArray *result = [self.testedApplication fb_filterDescendantsWithSnapshots:buttonSnapshots onlyChildren:NO]; XCTAssertEqual(1, result.count); XCTAssertEqual([result.firstObject elementType], XCUIElementTypeButton); } @end