From 17ddec71bca58f13267d451870aea7ad91ccb7ab Mon Sep 17 00:00:00 2001 From: Adam Ernst Date: Fri, 17 Apr 2015 10:33:34 -0400 Subject: [PATCH] Remove unused APIs --- .../Common/CKComponentDataSource.h | 14 ----- .../Common/CKComponentDataSource.mm | 13 ----- .../CKComponentDataSourceTests.mm | 29 ---------- .../CKSectionedArrayControllerTests.mm | 53 ------------------- 4 files changed, 109 deletions(-) diff --git a/ComponentKit/DataSources/Common/CKComponentDataSource.h b/ComponentKit/DataSources/Common/CKComponentDataSource.h index 29d002267..ca7a456ff 100644 --- a/ComponentKit/DataSources/Common/CKComponentDataSource.h +++ b/ComponentKit/DataSources/Common/CKComponentDataSource.h @@ -83,20 +83,6 @@ typedef void(^CKComponentDataSourceEnumerator)(CKComponentDataSourceOutputItem * - (void)enumerateObjectsInSectionAtIndex:(NSInteger)section usingBlock:(CKComponentDataSourceEnumerator)block; -typedef BOOL(^CKComponentDataSourcePredicate)(CKComponentDataSourceOutputItem *, NSIndexPath *, BOOL *); - -/** - @predicate Returning YES from the predicate will halt searching. Passing a nil predicate will return a {nil, nil} pair. - @returns The object passing `predicate` and its corresponding index path. Nil in both fields indicates nothing passed. - This will always return both fields as nil or non-nil. - */ -- (std::pair)firstObjectPassingTest:(CKComponentDataSourcePredicate)predicate; - -/** - This is O(N). - */ -- (std::pair)objectForUUID:(NSString *)UUID; - /** @return YES if the datasource has changesets currently enqueued. */ diff --git a/ComponentKit/DataSources/Common/CKComponentDataSource.mm b/ComponentKit/DataSources/Common/CKComponentDataSource.mm index a74beff5f..55ffc2bb5 100644 --- a/ComponentKit/DataSources/Common/CKComponentDataSource.mm +++ b/ComponentKit/DataSources/Common/CKComponentDataSource.mm @@ -156,19 +156,6 @@ - (void)enumerateObjectsInSectionAtIndex:(NSInteger)section usingBlock:(CKCompon } } -- (std::pair)firstObjectPassingTest:(CKComponentDataSourcePredicate)predicate -{ - return [_outputArrayController firstObjectPassingTest:predicate]; -} - -- (std::pair)objectForUUID:(NSString *)UUID -{ - return [self firstObjectPassingTest: - ^BOOL(CKComponentDataSourceOutputItem *object, NSIndexPath *indexPath, BOOL *stop) { - return [[object UUID] isEqual:UUID]; - }]; -} - - (void)enqueueReload { __block CKArrayControllerInputItems items; diff --git a/ComponentKitTests/CKComponentDataSourceTests.mm b/ComponentKitTests/CKComponentDataSourceTests.mm index 92f165dd8..76e8a49d2 100644 --- a/ComponentKitTests/CKComponentDataSourceTests.mm +++ b/ComponentKitTests/CKComponentDataSourceTests.mm @@ -1059,35 +1059,6 @@ - (void)configureWithMultipleSectionsAndItems [_delegate reset]; } -- (void)testObjectForUUIDWithNilUUIDReturnsNil -{ - [self configureWithMultipleSectionsAndItems]; - - auto pair = [_dataSource objectForUUID:nil]; - XCTAssertNil(pair.first); - XCTAssertNil(pair.second); -} - -- (void)testObjectForUUIDWithNotFoundUUIDReturnsNil -{ - [self configureWithMultipleSectionsAndItems]; - - auto pair = [_dataSource objectForUUID:@"123456789"]; - XCTAssertNil(pair.first); - XCTAssertNil(pair.second); -} - -- (void)testObjectForUUIDReturnsObjectWhenFound -{ - [self configureWithMultipleSectionsAndItems]; - - CKComponentDataSourceOutputItem *item = [_dataSource objectAtIndexPath:IndexPath(1, 0).toNSIndexPath()]; - auto pair = [_dataSource objectForUUID:[item UUID]]; - - XCTAssertEqualObjects([pair.first model], @"Batman"); - XCTAssertEqualObjects(pair.second, IndexPath(1, 0).toNSIndexPath()); -} - - (void)testIsComputingChanges { [self configureWithMultipleSectionsAndItems]; diff --git a/ComponentKitTests/CKSectionedArrayControllerTests.mm b/ComponentKitTests/CKSectionedArrayControllerTests.mm index 5d49396ad..221cac814 100644 --- a/ComponentKitTests/CKSectionedArrayControllerTests.mm +++ b/ComponentKitTests/CKSectionedArrayControllerTests.mm @@ -566,57 +566,4 @@ - (void)testFullEnumerationStop XCTAssertTrue(enumerated == expected, @""); } -- (void)testFirstObjectPassingTestWithNilPredicate -{ - [_controller applyChangeset:_multipleSectionInput()]; - auto pair = [_controller firstObjectPassingTest:nil]; - XCTAssertNil(pair.first, @""); - XCTAssertNil(pair.second, @""); -} - -- (void)testFirstObjectPassingTestWithNonNilPredicate -{ - [_controller applyChangeset:_multipleSectionInput()]; - auto pair = [_controller firstObjectPassingTest:^BOOL(id object, NSIndexPath *indexPath, BOOL *stop) { - return [object isEqual:@1]; - }]; - XCTAssertEqualObjects(pair.first, @1, @""); - XCTAssertEqualObjects(pair.second, [NSIndexPath indexPathForItem:1 inSection:0], @""); -} - -- (void)testFirstObjectPassingTestStop -{ - [_controller applyChangeset:_multipleSectionInput()]; - - NSMutableArray *enumerated = [[NSMutableArray alloc] init]; - auto pair = [_controller firstObjectPassingTest:^BOOL(id object, NSIndexPath *indexPath, BOOL *stop) { - *stop = [indexPath isEqual:[NSIndexPath indexPathForItem:0 inSection:1]]; - [enumerated addObject:object]; - return NO; - }]; - - NSArray *expected = @[@0, @1, @2]; - XCTAssertEqualObjects(enumerated, expected, @""); -} - -- (void)testFirstObjectPassingTestWithMultipleMatchesReturnsFirst -{ - [_controller applyChangeset:_multipleSectionInput()]; - auto pair = [_controller firstObjectPassingTest:^BOOL(id object, NSIndexPath *indexPath, BOOL *stop) { - return YES; - }]; - XCTAssertEqualObjects(pair.first, @0, @""); - XCTAssertEqualObjects(pair.second, [NSIndexPath indexPathForItem:0 inSection:0], @""); -} - -- (void)testFirstObjectPassingTestWithNoMatchesReturnsNil -{ - [_controller applyChangeset:_multipleSectionInput()]; - auto pair = [_controller firstObjectPassingTest:^BOOL(id object, NSIndexPath *indexPath, BOOL *stop) { - return NO; - }]; - XCTAssertNil(pair.first, @""); - XCTAssertNil(pair.second, @""); -} - @end