Merge pull request #1114 from nguyenhuy/reloaddata_tests

Test reloadData in ASTableViewStressTest
This commit is contained in:
appleguy
2016-01-25 23:00:28 -08:00
2 changed files with 24 additions and 6 deletions

View File

@@ -110,7 +110,7 @@
XCTAssertEqualObjects([collectionView supplementaryNodeKindsInDataController:nil], @[UICollectionElementKindSectionHeader]);
}
- (void)DISABLED_testCollectionViewController
- (void)testCollectionViewController
{
ASCollectionViewTestController *testController = [[ASCollectionViewTestController alloc] initWithNibName:nil bundle:nil];

View File

@@ -18,6 +18,13 @@
#define NumberOfRowsPerSection 20
#define NumberOfReloadIterations 50
typedef enum : NSUInteger {
ReloadData,
ReloadRows,
ReloadSections,
ReloadTypeMax
} ReloadType;
@interface ViewController () <ASTableViewDataSource, ASTableViewDelegate>
{
ASTableView *_tableView;
@@ -108,7 +115,7 @@
UITableViewRowAnimation rowAnimation = (arc4random_uniform(1) == 0 ? UITableViewRowAnimationMiddle : UITableViewRowAnimationNone);
BOOL animatedScroll = (arc4random_uniform(2) == 0 ? YES : NO);
BOOL reloadRowsInsteadOfSections = (arc4random_uniform(2) == 0 ? YES : NO);
ReloadType reloadType = (arc4random_uniform(ReloadTypeMax));
BOOL letRunloopProceed = (arc4random_uniform(2) == 0 ? YES : NO);
BOOL useBeginEndUpdates = (arc4random_uniform(3) == 0 ? YES : NO);
@@ -120,10 +127,21 @@
[_tableView beginUpdates];
}
if (reloadRowsInsteadOfSections) {
[_tableView reloadRowsAtIndexPaths:[self randomIndexPathsExisting:YES] withRowAnimation:rowAnimation];
} else {
[_tableView reloadSections:[self randomIndexSet] withRowAnimation:rowAnimation];
switch (reloadType) {
case ReloadData:
[_tableView reloadData];
break;
case ReloadRows:
[_tableView reloadRowsAtIndexPaths:[self randomIndexPathsExisting:YES] withRowAnimation:rowAnimation];
break;
case ReloadSections:
[_tableView reloadSections:[self randomIndexSet] withRowAnimation:rowAnimation];
break;
default:
break;
}
if (addIndexPaths && !indexPathsAddedAndRemoved) {