From 3da7305abb63deb032b46d76cef84553bf63aec8 Mon Sep 17 00:00:00 2001 From: Ethan Nagel Date: Wed, 15 Jul 2015 16:31:01 -0700 Subject: [PATCH] Wait to begin thrashing until we have completed reloading the data so we aren't trying to do both operations concurrently. --- AsyncDisplayKitTests/ASTableViewTests.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKitTests/ASTableViewTests.m b/AsyncDisplayKitTests/ASTableViewTests.m index 154a9eb3..e73ff71e 100644 --- a/AsyncDisplayKitTests/ASTableViewTests.m +++ b/AsyncDisplayKitTests/ASTableViewTests.m @@ -151,8 +151,19 @@ tableView.asyncDelegate = dataSource; tableView.asyncDataSource = dataSource; + + XCTestExpectation *reloadDataExpectation = [self expectationWithDescription:@"reloadData"]; - [tableView reloadData]; + [tableView reloadDataWithCompletion:^{ + NSLog(@"*** Reload Complete ***"); + [reloadDataExpectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:5 handler:^(NSError *error) { + if (error) { + XCTFail(@"Expectation failed: %@", error); + } + }]; for (int i = 0; i < NumberOfReloadIterations; ++i) { UITableViewRowAnimation rowAnimation = (arc4random_uniform(2) == 0 ? UITableViewRowAnimationMiddle : UITableViewRowAnimationNone);