Fixes race conditions in FeedlyOperation progress reporting unit tests.
This commit is contained in:
parent
3d582270ad
commit
52d2121553
|
@ -147,6 +147,11 @@ class FeedlyOperationTests: XCTestCase {
|
||||||
|
|
||||||
func testProgressReporting() {
|
func testProgressReporting() {
|
||||||
let progress = DownloadProgress(numberOfTasks: 0)
|
let progress = DownloadProgress(numberOfTasks: 0)
|
||||||
|
let didChangeExpectation = expectation(forNotification: .DownloadProgressDidChange, object: progress)
|
||||||
|
// This number is the number of times breakpoints on calls to DownloadProgress.postDidChangeNotification is hit.
|
||||||
|
didChangeExpectation.expectedFulfillmentCount = 4
|
||||||
|
didChangeExpectation.assertForOverFulfill = true
|
||||||
|
|
||||||
let testOperation = TestOperation()
|
let testOperation = TestOperation()
|
||||||
|
|
||||||
testOperation.downloadProgress = progress
|
testOperation.downloadProgress = progress
|
||||||
|
@ -154,10 +159,17 @@ class FeedlyOperationTests: XCTestCase {
|
||||||
|
|
||||||
testOperation.downloadProgress = nil
|
testOperation.downloadProgress = nil
|
||||||
XCTAssertTrue(progress.numberRemaining == 0)
|
XCTAssertTrue(progress.numberRemaining == 0)
|
||||||
|
|
||||||
|
waitForExpectations(timeout: 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testProgressReportingOnCancel() {
|
func testProgressReportingOnCancel() {
|
||||||
let progress = DownloadProgress(numberOfTasks: 0)
|
let progress = DownloadProgress(numberOfTasks: 0)
|
||||||
|
let didChangeExpectation = expectation(forNotification: .DownloadProgressDidChange, object: progress)
|
||||||
|
// This number is the number of times breakpoints on calls to DownloadProgress.postDidChangeNotification is hit.
|
||||||
|
didChangeExpectation.expectedFulfillmentCount = 4
|
||||||
|
didChangeExpectation.assertForOverFulfill = true
|
||||||
|
|
||||||
let testOperation = TestOperation()
|
let testOperation = TestOperation()
|
||||||
testOperation.downloadProgress = progress
|
testOperation.downloadProgress = progress
|
||||||
|
|
||||||
|
@ -179,6 +191,11 @@ class FeedlyOperationTests: XCTestCase {
|
||||||
|
|
||||||
func testDoesProgressReportingOnSuccess() {
|
func testDoesProgressReportingOnSuccess() {
|
||||||
let progress = DownloadProgress(numberOfTasks: 0)
|
let progress = DownloadProgress(numberOfTasks: 0)
|
||||||
|
let didChangeExpectation = expectation(forNotification: .DownloadProgressDidChange, object: progress)
|
||||||
|
// This number is the number of times breakpoints on calls to DownloadProgress.postDidChangeNotification is hit.
|
||||||
|
didChangeExpectation.expectedFulfillmentCount = 4
|
||||||
|
didChangeExpectation.assertForOverFulfill = true
|
||||||
|
|
||||||
let testOperation = TestOperation()
|
let testOperation = TestOperation()
|
||||||
testOperation.downloadProgress = progress
|
testOperation.downloadProgress = progress
|
||||||
|
|
||||||
|
@ -198,6 +215,11 @@ class FeedlyOperationTests: XCTestCase {
|
||||||
|
|
||||||
func testProgressReportingOnFailure() {
|
func testProgressReportingOnFailure() {
|
||||||
let progress = DownloadProgress(numberOfTasks: 0)
|
let progress = DownloadProgress(numberOfTasks: 0)
|
||||||
|
let didChangeExpectation = expectation(forNotification: .DownloadProgressDidChange, object: progress)
|
||||||
|
// This number is the number of times breakpoints on calls to DownloadProgress.postDidChangeNotification is hit.
|
||||||
|
didChangeExpectation.expectedFulfillmentCount = 4
|
||||||
|
didChangeExpectation.assertForOverFulfill = true
|
||||||
|
|
||||||
let testOperation = TestOperation()
|
let testOperation = TestOperation()
|
||||||
testOperation.mockError = TestOperationError.mockError
|
testOperation.mockError = TestOperationError.mockError
|
||||||
testOperation.downloadProgress = progress
|
testOperation.downloadProgress = progress
|
||||||
|
|
Loading…
Reference in New Issue