forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownloadProgress.mm
612 lines (490 loc) · 20 KB
/
DownloadProgress.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
/*
* Copyright (C) 2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "config.h"
#import "TestWKWebView.h"
#import "Utilities.h"
#import <Foundation/NSProgress.h>
#import <WebKit/WKBrowsingContextController.h>
#import <WebKit/WKNavigationDelegatePrivate.h>
#import <WebKit/WKProcessPoolPrivate.h>
#import <WebKit/WKWebViewConfiguration.h>
#import <WebKit/_WKDownload.h>
#import <WebKit/_WKDownloadDelegate.h>
#import <pal/spi/cocoa/NSProgressSPI.h>
#import <sys/xattr.h>
#import <wtf/BlockPtr.h>
#import <wtf/FileSystem.h>
#import <wtf/RetainPtr.h>
#import <wtf/WeakObjCPtr.h>
@class DownloadProgressTestProtocol;
enum class DownloadStartType {
ConvertLoadToDownload,
StartFromNavigationAction,
StartInProcessPool,
};
@interface DownloadProgressTestRunner : NSObject <WKNavigationDelegate, _WKDownloadDelegate>
@property (nonatomic, readonly) _WKDownload *download;
@property (nonatomic, readonly) NSProgress *progress;
- (void)startLoadingWithProtocol:(DownloadProgressTestProtocol *)protocol;
@end
@interface DownloadProgressTestProtocol : NSURLProtocol
@end
@implementation DownloadProgressTestProtocol
static DownloadProgressTestRunner *currentTestRunner;
+ (void)registerProtocolForTestRunner:(DownloadProgressTestRunner *)testRunner
{
currentTestRunner = testRunner;
[NSURLProtocol registerClass:self];
[WKBrowsingContextController registerSchemeForCustomProtocol:@"http"];
}
+ (void)unregisterProtocol
{
currentTestRunner = nullptr;
[WKBrowsingContextController unregisterSchemeForCustomProtocol:@"http"];
[NSURLProtocol unregisterClass:self];
}
// MARK: NSURLProtocol Methods
+ (BOOL)canInitWithRequest:(NSURLRequest *)request
{
return [request.URL.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame;
}
+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
{
return request;
}
+ (BOOL)requestIsCacheEquivalent:(NSURLRequest *)a toRequest:(NSURLRequest *)b
{
return NO;
}
- (void)startLoading
{
[currentTestRunner startLoadingWithProtocol:self];
}
- (void)stopLoading
{
}
@end
static void* progressObservingContext = &progressObservingContext;
@implementation DownloadProgressTestRunner {
RetainPtr<NSURL> m_progressURL;
RetainPtr<TestWKWebView> m_webView;
RetainPtr<id> m_progressSubscriber;
RetainPtr<NSProgress> m_progress;
RetainPtr<_WKDownload> m_download;
RetainPtr<DownloadProgressTestProtocol> m_protocol;
BlockPtr<void(void)> m_unpublishingBlock;
DownloadStartType m_startType;
NSInteger m_expectedLength;
bool m_hasProgress;
bool m_lostProgress;
bool m_downloadStarted;
bool m_downloadDidCreateDestination;
bool m_downloadFinished;
bool m_downloadCanceled;
bool m_downloadFailed;
bool m_hasUpdatedCompletedUnitCount;
}
- (instancetype)init
{
self = [super init];
[DownloadProgressTestProtocol registerProtocolForTestRunner:self];
NSString *fileName = [NSString stringWithFormat:@"download-progress-%@", [NSUUID UUID].UUIDString];
m_progressURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fileName] isDirectory:NO];
[NSFileManager.defaultManager createFileAtPath:m_progressURL.get().path contents:nil attributes:nil];
currentTestRunner = self;
m_unpublishingBlock = makeBlockPtr([self] {
[self _didLoseProgress];
}).get();
return self;
}
- (void)dealloc
{
[NSFileManager.defaultManager removeItemAtURL:m_progressURL.get() error:nil];
[super dealloc];
}
- (_WKDownload *)download
{
return m_download.get();
}
- (NSProgress *)progress
{
return m_progress.get();
}
- (void)startLoadingWithProtocol:(DownloadProgressTestProtocol *)protocol
{
m_protocol = protocol;
auto response = adoptNS([[NSURLResponse alloc] initWithURL:protocol.request.URL MIMEType:@"application/x-test-file" expectedContentLength:m_expectedLength textEncodingName:nullptr]);
[m_protocol.get().client URLProtocol:m_protocol.get() didReceiveResponse:response.get() cacheStoragePolicy:NSURLCacheStorageNotAllowed];
}
- (void)tearDown
{
if (m_webView) {
m_webView.get().configuration.processPool._downloadDelegate = nullptr;
[m_webView.get() removeFromSuperview];
m_webView = nullptr;
}
if (m_progressSubscriber) {
#if HAVE(NSPROGRESS_PUBLISHING_SPI)
[NSProgress _removeSubscriber:m_progressSubscriber.get()];
#else
[NSProgress removeSubscriber:m_progressSubscriber.get()];
#endif
m_progressSubscriber = nullptr;
}
m_progress = nullptr;
m_download = nullptr;
m_protocol = nullptr;
m_unpublishingBlock = nullptr;
[DownloadProgressTestProtocol unregisterProtocol];
}
- (void)_didGetProgress:(NSProgress *)progress
{
ASSERT(!m_progress);
m_progress = progress;
[progress addObserver:self forKeyPath:@"completedUnitCount" options:NSKeyValueObservingOptionNew context:progressObservingContext];
m_hasProgress = true;
}
- (void)_didLoseProgress
{
ASSERT(m_progress);
[m_progress.get() removeObserver:self forKeyPath:@"completedUnitCount"];
m_progress = nullptr;
m_lostProgress = true;
}
- (void)subscribeAndWaitForProgress
{
if (!m_progressSubscriber) {
auto publishingHandler = makeBlockPtr([weakSelf = WeakObjCPtr<DownloadProgressTestRunner> { self }](NSProgress *progress) {
if (auto strongSelf = weakSelf.get()) {
[strongSelf.get() _didGetProgress:progress];
return strongSelf->m_unpublishingBlock.get();
}
return static_cast<NSProgressUnpublishingHandler>(nil);
});
#if HAVE(NSPROGRESS_PUBLISHING_SPI)
m_progressSubscriber = [NSProgress _addSubscriberForFileURL:m_progressURL.get() withPublishingHandler:publishingHandler.get()];
#else
m_progressSubscriber = [NSProgress addSubscriberForFileURL:m_progressURL.get() withPublishingHandler:publishingHandler.get()];
#endif
}
TestWebKitAPI::Util::run(&m_hasProgress);
}
- (void)waitToLoseProgress
{
TestWebKitAPI::Util::run(&m_lostProgress);
}
- (void)startDownload:(DownloadStartType)startType expectedLength:(NSInteger)expectedLength
{
m_startType = startType;
m_expectedLength = expectedLength;
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
m_webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
m_webView.get().navigationDelegate = self;
m_webView.get().configuration.processPool._downloadDelegate = self;
auto request = adoptNS([[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://file"]]);
switch (startType) {
case DownloadStartType::ConvertLoadToDownload:
case DownloadStartType::StartFromNavigationAction:
[m_webView loadRequest:request.get()];
break;
case DownloadStartType::StartInProcessPool:
[m_webView.get().configuration.processPool _downloadURLRequest:request.get() websiteDataStore:[WKWebsiteDataStore defaultDataStore] originatingWebView:nullptr];
break;
}
TestWebKitAPI::Util::run(&m_downloadStarted);
}
- (void)publishProgress
{
ASSERT(m_download);
[m_download.get() publishProgressAtURL:m_progressURL.get()];
}
- (void)receiveData:(NSInteger)length
{
auto data = adoptNS([[NSMutableData alloc] init]);
while (length-- > 0) {
const char byte = 'A';
[data.get() appendBytes:static_cast<const void*>(&byte) length:1];
}
[m_protocol.get().client URLProtocol:m_protocol.get() didLoadData:data.get()];
}
- (void)finishDownloadTask
{
[m_protocol.get().client URLProtocolDidFinishLoading:m_protocol.get()];
}
- (void)failDownloadTask
{
[m_protocol.get().client URLProtocol:m_protocol.get() didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nullptr]];
}
- (void)waitForDownloadDidCreateDestination
{
TestWebKitAPI::Util::run(&m_downloadDidCreateDestination);
}
- (void)waitForDownloadFinished
{
TestWebKitAPI::Util::run(&m_downloadFinished);
}
- (void)waitForDownloadCanceled
{
TestWebKitAPI::Util::run(&m_downloadCanceled);
}
- (void)waitForDownloadFailed
{
TestWebKitAPI::Util::run(&m_downloadFailed);
}
- (NSURL *)progressURL
{
return m_progressURL.get();
}
- (int64_t)waitForUpdatedCompletedUnitCount
{
TestWebKitAPI::Util::run(&m_hasUpdatedCompletedUnitCount);
m_hasUpdatedCompletedUnitCount = false;
return m_progress.get().completedUnitCount;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey, id> *)change context:(void *)context
{
if (context == progressObservingContext) {
EXPECT_EQ(object, m_progress.get());
EXPECT_STREQ(keyPath.UTF8String, "completedUnitCount");
m_hasUpdatedCompletedUnitCount = true;
} else
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
// MARK: <WKNavigationDelegate> Methods
- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
{
if (m_startType == DownloadStartType::ConvertLoadToDownload)
decisionHandler(WKNavigationResponsePolicyDownload);
else
decisionHandler(WKNavigationResponsePolicyAllow);
}
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
if (m_startType == DownloadStartType::StartFromNavigationAction)
decisionHandler(_WKNavigationActionPolicyDownload);
else
decisionHandler(WKNavigationActionPolicyAllow);
}
// MARK: <_WKDownloadDelegate> Methods
- (void)_downloadDidStart:(_WKDownload *)download
{
ASSERT(!m_downloadStarted);
ASSERT(!m_download);
m_download = download;
m_downloadStarted = true;
}
- (void)_download:(_WKDownload *)download didCreateDestination:(NSString *)destination
{
EXPECT_EQ(download, m_download.get());
m_downloadDidCreateDestination = true;
}
- (void)_downloadDidFinish:(_WKDownload *)download
{
EXPECT_EQ(download, m_download.get());
m_downloadFinished = true;
}
- (void)_downloadDidCancel:(_WKDownload *)download
{
EXPECT_EQ(download, m_download.get());
m_downloadCanceled = true;
}
- (void)_download:(_WKDownload *)download didFailWithError:(NSError *)error
{
EXPECT_EQ(download, m_download.get());
m_downloadFailed = true;
}
- (void)_download:(_WKDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename completionHandler:(void (^)(BOOL allowOverwrite, NSString *destination))completionHandler
{
EXPECT_EQ(download, m_download.get());
FileSystem::PlatformFileHandle fileHandle;
RetainPtr<NSString> path = (NSString *)FileSystem::openTemporaryFile("TestWebKitAPI"_s, fileHandle);
EXPECT_TRUE(fileHandle != FileSystem::invalidPlatformFileHandle);
FileSystem::closeFile(fileHandle);
completionHandler(YES, path.get());
}
@end
// End-to-end test of subscribing to progress on a successful download. The client
// should be able to receive an NSProgress that is updated as the download makes
// progress, and the NSProgress should be unpublished when the download finishes.
TEST(DownloadProgress, BasicSubscriptionAndProgressUpdates)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:50];
EXPECT_EQ([testRunner.get() waitForUpdatedCompletedUnitCount], 50);
EXPECT_EQ(testRunner.get().progress.fractionCompleted, .5);
[testRunner.get() receiveData:50];
EXPECT_EQ([testRunner.get() waitForUpdatedCompletedUnitCount], 100);
EXPECT_EQ(testRunner.get().progress.fractionCompleted, 1);
[testRunner.get() finishDownloadTask];
[testRunner.get() waitForDownloadFinished];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
// Similar test as before, but initiating the download before receiving its response.
TEST(DownloadProgress, StartDownloadFromNavigationAction)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::StartFromNavigationAction expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:100];
[testRunner.get() finishDownloadTask];
[testRunner.get() waitForDownloadFinished];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
TEST(DownloadProgress, StartDownloadInProcessPool)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::StartInProcessPool expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:100];
[testRunner.get() finishDownloadTask];
[testRunner.get() waitForDownloadFinished];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
// If the download is canceled, the progress should be unpublished.
TEST(DownloadProgress, LoseProgressWhenDownloadIsCanceled)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:50];
[testRunner.get().download cancel];
[testRunner.get() waitForDownloadCanceled];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
// If the download fails, the progress should be unpublished.
TEST(DownloadProgress, LoseProgressWhenDownloadFails)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:50];
[testRunner.get() failDownloadTask];
[testRunner.get() waitForDownloadFailed];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
// Canceling the progress should cancel the download.
TEST(DownloadProgress, CancelDownloadWhenProgressIsCanceled)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:50];
[testRunner.get().progress cancel];
[testRunner.get() waitForDownloadFailed];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
// Publishing progress on a download after it has finished should be a safe no-op.
TEST(DownloadProgress, PublishProgressAfterDownloadFinished)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() receiveData:100];
[testRunner.get() finishDownloadTask];
[testRunner.get() waitForDownloadFinished];
[testRunner.get() publishProgress];
[testRunner.get() tearDown];
}
// Test the behavior of a download of unknown length.
TEST(DownloadProgress, IndeterminateDownloadSize)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:NSURLResponseUnknownLength];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
EXPECT_EQ(testRunner.get().progress.totalUnitCount, -1);
[testRunner.get() receiveData:50];
EXPECT_EQ([testRunner.get() waitForUpdatedCompletedUnitCount], 50);
EXPECT_EQ(testRunner.get().progress.fractionCompleted, 0);
EXPECT_EQ(testRunner.get().progress.totalUnitCount, -1);
[testRunner.get() finishDownloadTask];
[testRunner.get() waitForDownloadFinished];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
// Test the behavior when a download continues returning data beyond its expected length.
TEST(DownloadProgress, ExtraData)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:150];
EXPECT_EQ([testRunner.get() waitForUpdatedCompletedUnitCount], 150);
EXPECT_EQ(testRunner.get().progress.fractionCompleted, 1.5);
[testRunner.get() finishDownloadTask];
[testRunner.get() waitForDownloadFinished];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
// Clients should be able to publish progress on a download that has already started.
TEST(DownloadProgress, PublishProgressOnPartialDownload)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() receiveData:50];
// Ensure that the the data task has become a download task so that we test
// telling a live Download, not a PendingDownload, to publish its progress.
[testRunner.get() waitForDownloadDidCreateDestination];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
EXPECT_EQ(testRunner.get().progress.completedUnitCount, 50);
[testRunner.get() receiveData:50];
EXPECT_EQ([testRunner.get() waitForUpdatedCompletedUnitCount], 100);
[testRunner.get() finishDownloadTask];
[testRunner.get() waitForDownloadFinished];
[testRunner.get() waitToLoseProgress];
[testRunner.get() tearDown];
}
TEST(DownloadProgress, ProgressExtendedAttributeSetAfterPartialDownloadStops)
{
auto testRunner = adoptNS([[DownloadProgressTestRunner alloc] init]);
[testRunner.get() startDownload:DownloadStartType::ConvertLoadToDownload expectedLength:100];
[testRunner.get() publishProgress];
[testRunner.get() subscribeAndWaitForProgress];
[testRunner.get() receiveData:60];
[testRunner.get() waitForUpdatedCompletedUnitCount];
[testRunner.get().download cancel];
[testRunner.get() waitForDownloadCanceled];
[testRunner.get() waitToLoseProgress];
char xattrValue[10] = { 0 };
auto size = getxattr(testRunner.get().progressURL.fileSystemRepresentation, "com.apple.progress.fractionCompleted", xattrValue, sizeof(xattrValue), 0, 0);
EXPECT_EQ(size, 5);
EXPECT_STREQ(xattrValue, "0.600");
[testRunner.get() tearDown];
}