Skip to content

Commit

Permalink
Remove flaky testAsyncEvents (no way to gurantee order)
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed May 4, 2024
1 parent ffaa854 commit ce1a2ff
Showing 1 changed file with 0 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,47 +65,6 @@ class ImagePipelineAsyncAwaitTests: XCTestCase, @unchecked Sendable {
XCTAssertEqual(image.sizeInPixels, CGSize(width: 640, height: 480))
}

@MainActor
@available(macOS 12, iOS 15, tvOS 15, watchOS 9, *)
func testAsyncImageTaskEvents() async throws {
// GIVEN
let dataLoader = MockProgressiveDataLoader()
pipeline = pipeline.reconfigured {
$0.dataLoader = dataLoader
$0.isProgressiveDecodingEnabled = true
}
pipeline.queue.suspend()
// TODO: Find a more reliable way to subscribe to events
DispatchQueue.global.asyncAfter(deadline: .now() + .milliseconds(64)) {
self.pipeline.queue.resume() // Make sure we subscribe after a delay
}

// WHEN
let task = pipeline.imageTask(with: Test.url)
for await event in task.events.values {
switch event {
case .preview(let response):
recordedPreviews.append(response)
dataLoader.resume()
case .finished(let result):
recordedResult = result
default:
break
}
recordedEvents.append(event)
}

// THEN
XCTAssertEqual(recordedEvents, [
.progress(.init(completed: 13152, total: 39456)),
.preview(recordedPreviews[0]),
.progress(.init(completed: 26304, total: 39456)),
.preview(recordedPreviews[1]),
.progress(.init(completed: 39456, total: 39456)),
.finished(try XCTUnwrap(recordedResult))
])
}

private var observer: AnyObject?

// MARK: - Cancellation
Expand Down

0 comments on commit ce1a2ff

Please sign in to comment.