Browse Source

[Issue #1467] Removed downloadProgress and uploadProgress Int64 variants.

Christian Noon 9 years ago
parent
commit
7925a0a7fc
5 changed files with 72 additions and 244 deletions
  1. 0 46
      Source/Request.swift
  2. 3 44
      Source/TaskDelegate.swift
  3. 13 25
      Tests/DownloadTests.swift
  4. 18 43
      Tests/RequestTests.swift
  5. 38 86
      Tests/UploadTests.swift

+ 0 - 46
Source/Request.swift

@@ -72,12 +72,6 @@ open class Request {
     /// A closure executed when monitoring upload or download progress of a request.
     public typealias ProgressHandler = (Progress) -> Void
 
-    /// A closure executed when monitoring the download progress of a request.
-    public typealias DownloadProgressHandler = (_ bytesReceived: Int64, _ totalBytesReceived: Int64, _ totalBytesExpectedToReceive: Int64) -> Void
-
-    /// A closure executed when monitoring the upload progress of a request.
-    public typealias UploadProgressHandler = (_ bytesSent: Int64, _ totalBytesSent: Int64, _ totalBytesExpectedToSend: Int64) -> Void
-
     // MARK: Properties
 
     /// The delegate for the underlying task.
@@ -380,18 +374,6 @@ open class DataRequest: Request {
         dataDelegate.progressHandler = (closure, queue)
         return self
     }
-
-    /// Sets a closure to be called periodically during the lifecycle of the `Request` as data is read from the server.
-    ///
-    /// - parameter queue:   The dispatch queue to execute the closure on.
-    /// - parameter closure: The code to be executed periodically as data is read from the server.
-    ///
-    /// - returns: The request.
-    @discardableResult
-    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping DownloadProgressHandler) -> Self {
-        dataDelegate.progressDebugHandler = (closure, queue)
-        return self
-    }
 }
 
 // MARK: -
@@ -488,18 +470,6 @@ open class DownloadRequest: Request {
         return self
     }
 
-    /// Sets a closure to be called periodically during the lifecycle of the `Request` as data is read from the server.
-    ///
-    /// - parameter queue:   The dispatch queue to execute the closure on.
-    /// - parameter closure: The code to be executed periodically as data is read from the server.
-    ///
-    /// - returns: The request.
-    @discardableResult
-    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping DownloadProgressHandler) -> Self {
-        downloadDelegate.progressDebugHandler = (closure, queue)
-        return self
-    }
-
     // MARK: Destination
 
     /// Creates a download file destination closure which uses the default file manager to move the temporary file to a
@@ -581,22 +551,6 @@ open class UploadRequest: DataRequest {
         uploadDelegate.uploadProgressHandler = (closure, queue)
         return self
     }
-
-    /// Sets a closure to be called periodically during the lifecycle of the `UploadRequest` as data is sent to
-    /// the server.
-    ///
-    /// After the data is sent to the server, the `progress(queue:closure:)` APIs can be used to monitor the progress
-    /// of data being read from the server.
-    ///
-    /// - parameter queue:   The dispatch queue to execute the closure on.
-    /// - parameter closure: The code to be executed periodically as data is sent to the server.
-    ///
-    /// - returns: The request.
-    @discardableResult
-    open func uploadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping UploadProgressHandler) -> Self {
-        uploadDelegate.uploadProgressDebugHandler = (closure, queue)
-        return self
-    }
 }
 
 // MARK: -

+ 3 - 44
Source/TaskDelegate.swift

@@ -182,9 +182,7 @@ class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
     }
 
     var progress: Progress
-
     var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)?
-    var progressDebugHandler: (closure: Request.DownloadProgressHandler, queue: DispatchQueue)?
 
     var dataStream: ((_ data: Data) -> Void)?
 
@@ -263,20 +261,7 @@ class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
             progress.completedUnitCount = totalBytesReceived
 
             if let progressHandler = progressHandler {
-                let progress = Progress()
-
-                progress.totalUnitCount = self.progress.totalUnitCount
-                progress.completedUnitCount = self.progress.completedUnitCount
-
-                progressHandler.queue.async { progressHandler.closure(progress) }
-            }
-
-            if let downloadProgressHandler = progressDebugHandler {
-                let totalBytesReceived = self.totalBytesReceived
-
-                downloadProgressHandler.queue.async {
-                    downloadProgressHandler.closure(bytesReceived, totalBytesReceived, totalBytesExpected)
-                }
+                progressHandler.queue.async { progressHandler.closure(self.progress) }
             }
         }
     }
@@ -306,9 +291,7 @@ class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate {
     var downloadTask: URLSessionDownloadTask { return task as! URLSessionDownloadTask }
 
     var progress: Progress
-
     var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)?
-    var progressDebugHandler: (closure: Request.DownloadProgressHandler, queue: DispatchQueue)?
 
     var resumeData: Data?
     override var data: Data? { return resumeData }
@@ -395,18 +378,7 @@ class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate {
             progress.completedUnitCount = totalBytesWritten
 
             if let progressHandler = progressHandler {
-                let progress = Progress()
-
-                progress.totalUnitCount = self.progress.totalUnitCount
-                progress.completedUnitCount = self.progress.completedUnitCount
-
-                progressHandler.queue.async { progressHandler.closure(progress) }
-            }
-
-            if let progressDebugHandler = progressDebugHandler {
-                progressDebugHandler.queue.async {
-                    progressDebugHandler.closure(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite)
-                }
+                progressHandler.queue.async { progressHandler.closure(self.progress) }
             }
         }
     }
@@ -435,9 +407,7 @@ class UploadTaskDelegate: DataTaskDelegate {
     var uploadTask: URLSessionUploadTask { return task as! URLSessionUploadTask }
 
     var uploadProgress: Progress
-
     var uploadProgressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)?
-    var uploadProgressDebugHandler: (closure: UploadRequest.UploadProgressHandler, queue: DispatchQueue)?
 
     // MARK: Lifecycle
 
@@ -471,18 +441,7 @@ class UploadTaskDelegate: DataTaskDelegate {
             uploadProgress.completedUnitCount = totalBytesSent
 
             if let uploadProgressHandler = uploadProgressHandler {
-                let uploadProgress = Progress()
-
-                uploadProgress.totalUnitCount = self.uploadProgress.totalUnitCount
-                uploadProgress.completedUnitCount = self.uploadProgress.completedUnitCount
-
-                uploadProgressHandler.queue.async { uploadProgressHandler.closure(uploadProgress) }
-            }
-
-            if let uploadProgressDebugHandler = uploadProgressDebugHandler {
-                uploadProgressDebugHandler.queue.async {
-                    uploadProgressDebugHandler.closure(bytesSent, totalBytesSent, totalBytesExpectedToSend)
-                }
+                uploadProgressHandler.queue.async { uploadProgressHandler.closure(self.uploadProgress) }
             }
         }
     }

+ 13 - 25
Tests/DownloadTests.swift

@@ -112,18 +112,13 @@ class DownloadResponseTestCase: BaseTestCase {
 
         let expectation = self.expectation(description: "Bytes download progress should be reported: \(urlString)")
 
-        var byteValues: [(bytes: Int64, totalBytes: Int64, totalBytesExpected: Int64)] = []
-        var progressValues: [(completedUnitCount: Int64, totalUnitCount: Int64)] = []
+        var progressValues: [Double] = []
         var response: DefaultDownloadResponse?
 
         // When
         Alamofire.download(urlString)
             .downloadProgress { progress in
-                progressValues.append((progress.completedUnitCount, progress.totalUnitCount))
-            }
-            .downloadProgress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
-                let bytes = (bytes: bytesRead, totalBytes: totalBytesRead, totalBytesExpected: totalBytesExpectedToRead)
-                byteValues.append(bytes)
+                progressValues.append(progress.fractionCompleted)
             }
             .response { resp in
                 response = resp
@@ -140,24 +135,17 @@ class DownloadResponseTestCase: BaseTestCase {
         XCTAssertNil(response?.resumeData)
         XCTAssertNil(response?.error)
 
-        XCTAssertEqual(byteValues.count, progressValues.count)
+        var previousProgress: Double = progressValues.first ?? 0.0
 
-        if byteValues.count == progressValues.count {
-            for (byteValue, progressValue) in zip(byteValues, progressValues) {
-                XCTAssertGreaterThan(byteValue.bytes, 0)
-                XCTAssertEqual(byteValue.totalBytes, progressValue.completedUnitCount)
-                XCTAssertEqual(byteValue.totalBytesExpected, progressValue.totalUnitCount)
-            }
+        for progress in progressValues {
+            XCTAssertGreaterThan(progress, previousProgress)
+            previousProgress = progress
         }
 
-        if let lastByteValue = byteValues.last, let lastProgressValue = progressValues.last {
-            let byteValueFractionalCompletion = Double(lastByteValue.totalBytes) / Double(lastByteValue.totalBytesExpected)
-            let progressValueFractionalCompletion = Double(lastProgressValue.0) / Double(lastProgressValue.1)
-
-            XCTAssertEqual(byteValueFractionalCompletion, 1.0)
-            XCTAssertEqual(progressValueFractionalCompletion, 1.0)
+        if let lastProgressValue = progressValues.last {
+            XCTAssertEqual(lastProgressValue, 1.0)
         } else {
-            XCTFail("last item in bytesValues and progressValues should not be nil")
+            XCTFail("last item in progressValues should not be nil")
         }
     }
 
@@ -403,8 +391,8 @@ class DownloadResumeDataTestCase: BaseTestCase {
 
         // When
         let download = Alamofire.download(urlString)
-        download.downloadProgress { _, totalBytesReceived, _ in
-            if totalBytesReceived > 10_000 { download.cancel() }
+        download.downloadProgress { progress in
+            if progress.fractionCompleted > 0.1 { download.cancel() }
         }
         download.response { resp in
             response = resp
@@ -436,8 +424,8 @@ class DownloadResumeDataTestCase: BaseTestCase {
 
         // When
         let download = Alamofire.download(urlString)
-        download.downloadProgress { _, totalBytesReceived, _ in
-            if totalBytesReceived > 10_000 { download.cancel() }
+        download.downloadProgress { progress in
+            if progress.fractionCompleted > 0.1 { download.cancel() }
         }
         download.responseJSON { resp in
             response = resp

+ 18 - 43
Tests/RequestTests.swift

@@ -108,18 +108,13 @@ class RequestResponseTestCase: BaseTestCase {
 
         let expectation = self.expectation(description: "Bytes download progress should be reported: \(urlString)")
 
-        var byteValues: [(bytes: Int64, totalBytes: Int64, totalBytesExpected: Int64)] = []
-        var progressValues: [(completedUnitCount: Int64, totalUnitCount: Int64)] = []
+        var progressValues: [Double] = []
         var response: DefaultDataResponse?
 
         // When
         Alamofire.request(urlString)
             .downloadProgress { progress in
-                progressValues.append((progress.completedUnitCount, progress.totalUnitCount))
-            }
-            .downloadProgress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
-                let bytes = (bytes: bytesRead, totalBytes: totalBytesRead, totalBytesExpected: totalBytesExpectedToRead)
-                byteValues.append(bytes)
+                progressValues.append(progress.fractionCompleted)
             }
             .response { resp in
                 response = resp
@@ -134,24 +129,17 @@ class RequestResponseTestCase: BaseTestCase {
         XCTAssertNotNil(response?.data)
         XCTAssertNil(response?.error)
 
-        XCTAssertEqual(byteValues.count, progressValues.count)
+        var previousProgress: Double = progressValues.first ?? 0.0
 
-        if byteValues.count == progressValues.count {
-            for (byteValue, progressValue) in zip(byteValues, progressValues) {
-                XCTAssertGreaterThan(byteValue.bytes, 0)
-                XCTAssertEqual(byteValue.totalBytes, progressValue.completedUnitCount)
-                XCTAssertEqual(byteValue.totalBytesExpected, progressValue.totalUnitCount)
-            }
+        for progress in progressValues {
+            XCTAssertGreaterThan(progress, previousProgress)
+            previousProgress = progress
         }
 
-        if let lastByteValue = byteValues.last, let lastProgressValue = progressValues.last {
-            let byteValueFractionalCompletion = Double(lastByteValue.totalBytes) / Double(lastByteValue.totalBytesExpected)
-            let progressValueFractionalCompletion = Double(lastProgressValue.0) / Double(lastProgressValue.1)
-
-            XCTAssertEqual(byteValueFractionalCompletion, 1.0)
-            XCTAssertEqual(progressValueFractionalCompletion, 1.0)
+        if let lastProgressValue = progressValues.last {
+            XCTAssertEqual(lastProgressValue, 1.0)
         } else {
-            XCTFail("last item in bytesValues and progressValues should not be nil")
+            XCTFail("last item in progressValues should not be nil")
         }
     }
 
@@ -162,19 +150,14 @@ class RequestResponseTestCase: BaseTestCase {
 
         let expectation = self.expectation(description: "Bytes download progress should be reported: \(urlString)")
 
-        var byteValues: [(bytes: Int64, totalBytes: Int64, totalBytesExpected: Int64)] = []
-        var progressValues: [(completedUnitCount: Int64, totalUnitCount: Int64)] = []
+        var progressValues: [Double] = []
         var accumulatedData = [Data]()
         var response: DefaultDataResponse?
 
         // When
         Alamofire.request(urlString)
             .downloadProgress { progress in
-                progressValues.append((progress.completedUnitCount, progress.totalUnitCount))
-            }
-            .downloadProgress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
-                let bytes = (bytes: bytesRead, totalBytes: totalBytesRead, totalBytesExpected: totalBytesExpectedToRead)
-                byteValues.append(bytes)
+                progressValues.append(progress.fractionCompleted)
             }
             .stream { data in
                 accumulatedData.append(data)
@@ -193,25 +176,17 @@ class RequestResponseTestCase: BaseTestCase {
         XCTAssertNil(response?.error)
         XCTAssertGreaterThanOrEqual(accumulatedData.count, 1)
 
-        XCTAssertEqual(byteValues.count, progressValues.count)
+        var previousProgress: Double = progressValues.first ?? 0.0
 
-        if byteValues.count == progressValues.count {
-            for (byteValue, progressValue) in zip(byteValues, progressValues) {
-                XCTAssertGreaterThan(byteValue.bytes, 0)
-                XCTAssertEqual(byteValue.totalBytes, progressValue.completedUnitCount)
-                XCTAssertEqual(byteValue.totalBytesExpected, progressValue.totalUnitCount)
-            }
+        for progress in progressValues {
+            XCTAssertGreaterThan(progress, previousProgress)
+            previousProgress = progress
         }
 
-        if let lastByteValue = byteValues.last, let lastProgressValue = progressValues.last {
-            let byteValueFractionalCompletion = Double(lastByteValue.totalBytes) / Double(lastByteValue.totalBytesExpected)
-            let progressValueFractionalCompletion = Double(lastProgressValue.0) / Double(lastProgressValue.1)
-
-            XCTAssertEqual(byteValueFractionalCompletion, 1.0)
-            XCTAssertEqual(progressValueFractionalCompletion, 1.0)
-            XCTAssertEqual(accumulatedData.reduce(Int64(0)) { $0 + $1.count }, lastByteValue.totalBytes)
+        if let lastProgress = progressValues.last {
+            XCTAssertEqual(lastProgress, 1.0)
         } else {
-            XCTFail("last item in bytesValues and progressValues should not be nil")
+            XCTFail("last item in progressValues should not be nil")
         }
     }
 

+ 38 - 86
Tests/UploadTests.swift

@@ -181,29 +181,18 @@ class UploadDataTestCase: BaseTestCase {
 
         let expectation = self.expectation(description: "Bytes upload progress should be reported: \(urlString)")
 
-        var uploadByteValues: [(bytes: Int64, totalBytes: Int64, totalBytesExpected: Int64)] = []
-        var uploadProgressValues: [(completedUnitCount: Int64, totalUnitCount: Int64)] = []
-
-        var downloadByteValues: [(bytes: Int64, totalBytes: Int64, totalBytesExpected: Int64)] = []
-        var downloadProgressValues: [(completedUnitCount: Int64, totalUnitCount: Int64)] = []
+        var uploadProgressValues: [Double] = []
+        var downloadProgressValues: [Double] = []
 
         var response: DefaultDataResponse?
 
         // When
         Alamofire.upload(data, to: urlString)
             .uploadProgress { progress in
-                uploadProgressValues.append((progress.completedUnitCount, progress.totalUnitCount))
-            }
-            .uploadProgress { bytesSent, totalBytesSent, totalBytesExpectedToSend in
-                let bytes = (bytes: bytesSent, totalBytes: totalBytesSent, totalBytesExpected: totalBytesExpectedToSend)
-                uploadByteValues.append(bytes)
+                uploadProgressValues.append(progress.fractionCompleted)
             }
             .downloadProgress { progress in
-                downloadProgressValues.append((progress.completedUnitCount, progress.totalUnitCount))
-            }
-            .downloadProgress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
-                let bytes = (bytes: bytesRead, totalBytes: totalBytesRead, totalBytesExpected: totalBytesExpectedToRead)
-                downloadByteValues.append(bytes)
+                downloadProgressValues.append(progress.fractionCompleted)
             }
             .response { resp in
                 response = resp
@@ -218,43 +207,30 @@ class UploadDataTestCase: BaseTestCase {
         XCTAssertNotNil(response?.data)
         XCTAssertNil(response?.error)
 
-        XCTAssertEqual(uploadByteValues.count, uploadProgressValues.count)
-        XCTAssertEqual(downloadByteValues.count, downloadProgressValues.count)
+        var previousUploadProgress: Double = uploadProgressValues.first ?? 0.0
 
-        if uploadByteValues.count == uploadProgressValues.count {
-            for (byteValue, progressValue) in zip(uploadByteValues, uploadProgressValues) {
-                XCTAssertGreaterThan(byteValue.bytes, 0)
-                XCTAssertEqual(byteValue.totalBytes, progressValue.completedUnitCount)
-                XCTAssertEqual(byteValue.totalBytesExpected, progressValue.totalUnitCount)
-            }
+        for progress in uploadProgressValues {
+            XCTAssertGreaterThan(progress, previousUploadProgress)
+            previousUploadProgress = progress
         }
 
-        if let lastUploadByteValue = uploadByteValues.last, let lastUploadProgressValue = uploadProgressValues.last {
-            let byteValueFractionalCompletion = Double(lastUploadByteValue.totalBytes) / Double(lastUploadByteValue.totalBytesExpected)
-            let progressValueFractionalCompletion = Double(lastUploadProgressValue.0) / Double(lastUploadProgressValue.1)
-
-            XCTAssertEqual(byteValueFractionalCompletion, 1.0)
-            XCTAssertEqual(progressValueFractionalCompletion, 1.0)
+        if let lastProgressValue = uploadProgressValues.last {
+            XCTAssertEqual(lastProgressValue, 1.0)
         } else {
-            XCTFail("last item in uploadByteValues and uploadProgressValues should not be nil")
+            XCTFail("last item in uploadProgressValues should not be nil")
         }
 
-        if downloadByteValues.count == downloadProgressValues.count {
-            for (byteValue, progressValue) in zip(downloadByteValues, downloadProgressValues) {
-                XCTAssertGreaterThan(byteValue.bytes, 0)
-                XCTAssertEqual(byteValue.totalBytes, progressValue.completedUnitCount)
-                XCTAssertEqual(byteValue.totalBytesExpected, progressValue.totalUnitCount)
-            }
-        }
+        var previousDownloadProgress: Double = downloadProgressValues.first ?? 0.0
 
-        if let lastDownloadByteValue = downloadByteValues.last, let lastDownloadProgressValue = downloadProgressValues.last {
-            let byteValueFractionalCompletion = Double(lastDownloadByteValue.totalBytes) / Double(lastDownloadByteValue.totalBytesExpected)
-            let progressValueFractionalCompletion = Double(lastDownloadProgressValue.0) / Double(lastDownloadProgressValue.1)
+        for progress in downloadProgressValues {
+            XCTAssertGreaterThan(progress, previousDownloadProgress)
+            previousDownloadProgress = progress
+        }
 
-            XCTAssertEqual(byteValueFractionalCompletion, 1.0)
-            XCTAssertEqual(progressValueFractionalCompletion, 1.0)
+        if let lastProgressValue = downloadProgressValues.last {
+            XCTAssertEqual(lastProgressValue, 1.0)
         } else {
-            XCTFail("last item in downloadByteValues and downloadProgressValues should not be nil")
+            XCTFail("last item in downloadProgressValues should not be nil")
         }
     }
 }
@@ -648,11 +624,8 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
 
         let expectation = self.expectation(description: "multipart form data upload should succeed")
 
-        var uploadByteValues: [(bytes: Int64, totalBytes: Int64, totalBytesExpected: Int64)] = []
-        var uploadProgressValues: [(completedUnitCount: Int64, totalUnitCount: Int64)] = []
-
-        var downloadByteValues: [(bytes: Int64, totalBytes: Int64, totalBytesExpected: Int64)] = []
-        var downloadProgressValues: [(completedUnitCount: Int64, totalUnitCount: Int64)] = []
+        var uploadProgressValues: [Double] = []
+        var downloadProgressValues: [Double] = []
 
         var response: DefaultDataResponse?
 
@@ -669,18 +642,10 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
                 case .success(let upload, _, _):
                     upload
                         .uploadProgress { progress in
-                            uploadProgressValues.append((progress.completedUnitCount, progress.totalUnitCount))
-                        }
-                        .uploadProgress { bytesSent, totalBytesSent, totalBytesExpectedToSend in
-                            let bytes = (bytes: bytesSent, totalBytes: totalBytesSent, totalBytesExpected: totalBytesExpectedToSend)
-                            uploadByteValues.append(bytes)
+                            uploadProgressValues.append(progress.fractionCompleted)
                         }
                         .downloadProgress { progress in
-                            downloadProgressValues.append((progress.completedUnitCount, progress.totalUnitCount))
-                        }
-                        .downloadProgress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
-                            let bytes = (bytes: bytesRead, totalBytes: totalBytesRead, totalBytesExpected: totalBytesExpectedToRead)
-                            downloadByteValues.append(bytes)
+                            downloadProgressValues.append(progress.fractionCompleted)
                         }
                         .response { resp in
                             response = resp
@@ -700,43 +665,30 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
         XCTAssertNotNil(response?.data)
         XCTAssertNil(response?.error)
 
-        XCTAssertEqual(uploadByteValues.count, uploadProgressValues.count)
-        XCTAssertEqual(downloadByteValues.count, downloadProgressValues.count)
+        var previousUploadProgress: Double = uploadProgressValues.first ?? 0.0
 
-        if uploadByteValues.count == uploadProgressValues.count {
-            for (byteValue, progressValue) in zip(uploadByteValues, uploadProgressValues) {
-                XCTAssertGreaterThan(byteValue.bytes, 0)
-                XCTAssertEqual(byteValue.totalBytes, progressValue.completedUnitCount)
-                XCTAssertEqual(byteValue.totalBytesExpected, progressValue.totalUnitCount)
-            }
+        for progress in uploadProgressValues {
+            XCTAssertGreaterThan(progress, previousUploadProgress)
+            previousUploadProgress = progress
         }
 
-        if let lastUploadByteValue = uploadByteValues.last, let lastUploadProgressValue = uploadProgressValues.last {
-            let byteValueFractionalCompletion = Double(lastUploadByteValue.totalBytes) / Double(lastUploadByteValue.totalBytesExpected)
-            let progressValueFractionalCompletion = Double(lastUploadProgressValue.0) / Double(lastUploadProgressValue.1)
-
-            XCTAssertEqual(byteValueFractionalCompletion, 1.0)
-            XCTAssertEqual(progressValueFractionalCompletion, 1.0)
+        if let lastProgressValue = uploadProgressValues.last {
+            XCTAssertEqual(lastProgressValue, 1.0)
         } else {
-            XCTFail("last item in uploadByteValues and uploadProgressValues should not be nil")
+            XCTFail("last item in uploadProgressValues should not be nil")
         }
 
-        if downloadByteValues.count == downloadProgressValues.count {
-            for (byteValue, progressValue) in zip(downloadByteValues, downloadProgressValues) {
-                XCTAssertGreaterThan(byteValue.bytes, 0)
-                XCTAssertEqual(byteValue.totalBytes, progressValue.completedUnitCount)
-                XCTAssertEqual(byteValue.totalBytesExpected, progressValue.totalUnitCount)
-            }
-        }
+        var previousDownloadProgress: Double = downloadProgressValues.first ?? 0.0
 
-        if let lastDownloadByteValue = downloadByteValues.last, let lastDownloadProgressValue = downloadProgressValues.last {
-            let byteValueFractionalCompletion = Double(lastDownloadByteValue.totalBytes) / Double(lastDownloadByteValue.totalBytesExpected)
-            let progressValueFractionalCompletion = Double(lastDownloadProgressValue.0) / Double(lastDownloadProgressValue.1)
+        for progress in downloadProgressValues {
+            XCTAssertGreaterThan(progress, previousDownloadProgress)
+            previousDownloadProgress = progress
+        }
 
-            XCTAssertEqual(byteValueFractionalCompletion, 1.0)
-            XCTAssertEqual(progressValueFractionalCompletion, 1.0)
+        if let lastProgressValue = downloadProgressValues.last {
+            XCTAssertEqual(lastProgressValue, 1.0)
         } else {
-            XCTFail("last item in downloadByteValues and downloadProgressValues should not be nil")
+            XCTFail("last item in downloadProgressValues should not be nil")
         }
     }
 }