mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-06 06:58:26 +00:00
Summary: Adds additional functionality and coverage testing to the adapter debugger class Reviewed By: candance Differential Revision: D45004651 fbshipit-source-id: 40330f5f2fed2946cc5ead89b30cf4030b596b65
51 lines
1.8 KiB
Objective-C
51 lines
1.8 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
#import <IGListKit/IGListKit.h>
|
|
|
|
#import "IGListDebugger.h"
|
|
#import "IGListTestAdapterDataSource.h"
|
|
|
|
@interface IGListDebuggerTests : XCTestCase
|
|
|
|
@end
|
|
|
|
@implementation IGListDebuggerTests
|
|
|
|
- (void)test_whenSearchingAdapterInstances_thatCorrectCountReturned {
|
|
// purge any leftover tracking
|
|
[IGListDebugger clear];
|
|
|
|
UIViewController *controller = [UIViewController new];
|
|
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)
|
|
collectionViewLayout:[UICollectionViewFlowLayout new]];
|
|
|
|
IGListTestAdapterDataSource *dataSource = [IGListTestAdapterDataSource new];
|
|
dataSource.objects = @[@1, @2, @3];
|
|
IGListAdapter *adapter1 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:nil workingRangeSize:0];
|
|
adapter1.collectionView = collectionView;
|
|
adapter1.dataSource = dataSource;
|
|
|
|
IGListAdapter *adapter2 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:controller workingRangeSize:2];
|
|
adapter2.collectionView = collectionView;
|
|
adapter2.dataSource = dataSource;
|
|
|
|
IGListAdapter *adapter3 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:controller workingRangeSize:2];
|
|
adapter3.collectionView = collectionView;
|
|
adapter3.dataSource = dataSource;
|
|
|
|
[collectionView setNeedsLayout];
|
|
[collectionView layoutIfNeeded];
|
|
|
|
NSArray *descriptions = [IGListDebugger adapterDescriptions];
|
|
XCTAssertEqual(descriptions.count, 3);
|
|
XCTAssertTrue([[IGListDebugger dump] length] > 0);
|
|
}
|
|
|
|
@end
|