forked from parse-community/Parse-SDK-iOS-OSX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileControllerTests.m
548 lines (439 loc) · 25.4 KB
/
FileControllerTests.m
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
/**
* Copyright (c) 2015-present, Parse, LLC.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <OCMock/OCMock.h>
@import Bolts.BFCancellationTokenSource;
@import Bolts.BFTask;
@import Bolts.BFTaskCompletionSource;
#import "PFCommandResult.h"
#import "PFCommandRunning.h"
#import "PFFileController.h"
#import "PFFileManager.h"
#import "PFMutableFileState.h"
#import "PFTestCase.h"
@protocol FileControllerDataSource <PFCommandRunnerProvider, PFFileManagerProvider>
@end
@interface FileControllerTests : PFTestCase
@end
@implementation FileControllerTests
///--------------------------------------
#pragma mark - Helpers
///--------------------------------------
- (NSData *)sampleData {
const char bytes[] = {
0x0, 0x1, 0x2, 0x3,
0x4, 0x5, 0x6, 0x7,
0x8, 0x9, 0xA, 0xB,
0xC, 0xD, 0xE, 0xF};
return [NSData dataWithBytes:bytes length:sizeof(bytes)];
}
- (NSString *)temporaryDirectory {
return [NSTemporaryDirectory() stringByAppendingPathComponent:NSStringFromClass([self class])];
}
- (id)mockedDataSource {
id mockedDataSource = PFStrictProtocolMock(@protocol(FileControllerDataSource));
id mockedCommandRunner = PFStrictProtocolMock(@protocol(PFCommandRunning));
OCMStub([mockedDataSource commandRunner]).andReturn(mockedCommandRunner);
id mockedFileManager = PFStrictClassMock([PFFileManager class]);
OCMStub([mockedDataSource fileManager]).andReturn(mockedFileManager);
OCMStub([mockedFileManager parseLocalSandboxDataDirectoryPath]).andReturn([self temporaryDirectory]);
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn([self temporaryDirectory]);
return mockedDataSource;
}
///--------------------------------------
#pragma mark - XCTestCase
///--------------------------------------
- (void)setUp {
[super setUp];
[[PFFileManager createDirectoryIfNeededAsyncAtPath:[self temporaryDirectory]] waitUntilFinished];
}
- (void)tearDown {
[[PFFileManager removeItemAtPathAsync:[self temporaryDirectory]] waitUntilFinished];
[super tearDown];
}
///--------------------------------------
#pragma mark - Tests
///--------------------------------------
- (void)testConstructors {
id mockedDataSource = [self mockedDataSource];
PFFileController *fileController = [[PFFileController alloc] initWithDataSource:mockedDataSource];
XCTAssertEqual((id)fileController.dataSource, mockedDataSource);
fileController = [PFFileController controllerWithDataSource:mockedDataSource];
XCTAssertEqual((id)fileController.dataSource, mockedDataSource);
}
- (void)testDownload {
id mockedDataSource = [self mockedDataSource];
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
NSURL *tempPath = [NSURL fileURLWithPath:[temporaryPath stringByAppendingPathComponent:@"sampleData.dat"]];
NSData *sampleData = [self sampleData];
[sampleData writeToURL:tempPath atomically:YES];
id mockedFileManager = [mockedDataSource fileManager];
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
id mockedCommandRunner = [mockedDataSource commandRunner];
OCMStub([mockedCommandRunner runFileDownloadCommandAsyncWithFileURL:tempPath
targetFilePath:[OCMArg checkWithBlock:^BOOL(id obj) {
NSString *path = obj;
if (!path) {
return NO;
}
[[NSData data] writeToFile:path atomically:YES];
return YES;
}]
cancellationToken:nil
progressBlock:[OCMArg checkWithBlock:^BOOL(id obj) {
PFProgressBlock block = obj;
if (block) {
block(100);
}
return block != nil;
}]]).andReturn([BFTask taskWithResult:nil]);
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:[tempPath absoluteString]
mimeType:@"application/octet-stream"];
__block int progress = -1;
XCTestExpectation *expectation = [self currentSelectorTestExpectation];
[[fileController downloadFileAsyncWithState:fileState
cancellationToken:nil
progressBlock:^(int percentDone) {
XCTAssertTrue(progress <= percentDone);
progress = percentDone;
}] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
[expectation fulfill];
return nil;
}];
[self waitForTestExpectations];
}
- (void)testDownloadSharesOperations {
id mockedDataSource = [self mockedDataSource];
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
NSURL *tempPath = [NSURL fileURLWithPath:[temporaryPath stringByAppendingPathComponent:@"sampleData.dat"]];
NSData *sampleData = [self sampleData];
[sampleData writeToURL:tempPath atomically:YES];
id mockedFileManager = [mockedDataSource fileManager];
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
__block BOOL enqueuedFirstDownload = NO;
__block BOOL enqueuedSecondDownload = NO;
BFTaskCompletionSource *taskCompletionSource = [BFTaskCompletionSource taskCompletionSource];
__block PFProgressBlock progressBlock = nil;
id mockedCommandRunner = [mockedDataSource commandRunner];
OCMStub([mockedCommandRunner runFileDownloadCommandAsyncWithFileURL:tempPath
targetFilePath:[OCMArg checkWithBlock:^BOOL(id obj) {
NSString *path = obj;
if (!path) {
return NO;
}
[[NSData data] writeToFile:path atomically:YES];
return YES;
}]
cancellationToken:nil
progressBlock:[OCMArg checkWithBlock:^BOOL(id obj) {
progressBlock = obj;
return progressBlock != nil;
}]]).andReturn(taskCompletionSource.task).andDo(^(NSInvocation *invocation) {
XCTAssertFalse(enqueuedFirstDownload);
enqueuedFirstDownload = YES;
});
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:[tempPath absoluteString]
mimeType:@"application/octet-stream"];
XCTestExpectation *firstExpectation = [self expectationWithDescription:@"downloadFileAsyncWithStateNumber1"];
[[fileController downloadFileAsyncWithState:fileState cancellationToken:nil progressBlock:^(int percentDone) {
XCTAssertGreaterThan(percentDone, 0);
XCTAssertLessThanOrEqual(percentDone, 100);
}] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
[firstExpectation fulfill];
return nil;
}];
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:10.0];
// Wait till the download operation starts
while (!enqueuedFirstDownload && [timeoutDate timeIntervalSinceNow] > 0.0) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
}
XCTestExpectation *secondExpectation = [self expectationWithDescription:@"downloadFileAsyncWithStateNumber2"];
[[fileController downloadFileAsyncWithState:fileState cancellationToken:nil progressBlock:^(int percentDone) {
XCTAssertGreaterThan(percentDone, 0);
XCTAssertLessThanOrEqual(percentDone, 100);
enqueuedSecondDownload = YES;
}] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
[secondExpectation fulfill];
return nil;
}];
// Wait till the second operation is enqueued
timeoutDate = [NSDate dateWithTimeIntervalSinceNow:10.0];
while (!enqueuedSecondDownload && [timeoutDate timeIntervalSinceNow] > 0.0) {
progressBlock(50);
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
}
[taskCompletionSource trySetResult:nil];
[self waitForTestExpectations];
}
- (void)testDownloadCancel {
id mockedDataSource = [self mockedDataSource];
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
NSURL *tempPath = [NSURL fileURLWithPath:[temporaryPath stringByAppendingPathComponent:@"sampleData.dat"]];
NSData *sampleData = [self sampleData];
[sampleData writeToURL:tempPath atomically:YES];
id mockedFileManager = [mockedDataSource fileManager];
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
BFCancellationTokenSource *cancellationTokenSource = [BFCancellationTokenSource cancellationTokenSource];
id mockedCommandRunner = [mockedDataSource commandRunner];
OCMStub([mockedCommandRunner runFileDownloadCommandAsyncWithFileURL:tempPath
targetFilePath:[OCMArg isNotNil]
cancellationToken:cancellationTokenSource.token
progressBlock:[OCMArg checkWithBlock:^BOOL(id obj) {
PFProgressBlock block = obj;
if (block) {
block(100);
}
return block != nil;
}]]).andReturn([BFTask cancelledTask]);
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:[tempPath absoluteString]
mimeType:@"application/octet-stream"];
__block int progress = -1;
XCTestExpectation *expectation = [self currentSelectorTestExpectation];
[[fileController downloadFileAsyncWithState:fileState
cancellationToken:cancellationTokenSource.token
progressBlock:^(int percentDone) {
XCTAssertTrue(progress <= percentDone);
progress = percentDone;
}] continueWithBlock:^id(BFTask *task) {
XCTAssertTrue(task.cancelled);
[expectation fulfill];
return nil;
}];
[cancellationTokenSource cancel];
[self waitForTestExpectations];
}
- (void)testDownloadStream {
id mockedDataSource = [self mockedDataSource];
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
NSURL *tempPath = [NSURL fileURLWithPath:[temporaryPath stringByAppendingPathComponent:@"sampleData.dat"]];
NSData *sampleData = [self sampleData];
[sampleData writeToURL:tempPath atomically:YES];
id mockedFileManager = [mockedDataSource fileManager];
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
id mockedCommandRunner = [mockedDataSource commandRunner];
OCMStub([mockedCommandRunner runFileDownloadCommandAsyncWithFileURL:tempPath
targetFilePath:[OCMArg isNotNil]
cancellationToken:nil
progressBlock:[OCMArg checkWithBlock:^BOOL(id obj) {
PFProgressBlock block = obj;
if (block) {
block(100);
}
return block != nil;
}]]).andReturn([BFTask taskWithResult:nil]);
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:[tempPath absoluteString]
mimeType:@"application/octet-stream"];
__block int progress = -1;
XCTestExpectation *expectation = [self currentSelectorTestExpectation];
[[fileController downloadFileStreamAsyncWithState:fileState
cancellationToken:nil
progressBlock:^(int percentDone) {
XCTAssertTrue(progress <= percentDone);
progress = percentDone;
}] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
PFAssertIsKindOfClass(task.result, [NSInputStream class]);
[expectation fulfill];
return nil;
}];
[self waitForTestExpectations];
}
- (void)testDownloadStreamSharesOperations {
id mockedDataSource = [self mockedDataSource];
NSString *temporaryPath = [self temporaryDirectory];
NSURL *tempPath = [NSURL fileURLWithPath:[temporaryPath stringByAppendingPathComponent:@"sampleData.dat"]];
NSData *sampleData = [self sampleData];
[sampleData writeToURL:tempPath atomically:YES];
__block BOOL enqueuedFirstDownload = NO;
__block BOOL enqueuedSecondDownload = NO;
BFTaskCompletionSource *taskCompletionSource = [BFTaskCompletionSource taskCompletionSource];
__block PFProgressBlock progressBlock = nil;
id<PFCommandRunning> commandRunner = [mockedDataSource commandRunner];
OCMStub([commandRunner runFileDownloadCommandAsyncWithFileURL:tempPath
targetFilePath:[OCMArg isNotNil]
cancellationToken:nil
progressBlock:[OCMArg checkWithBlock:^BOOL(id obj) {
progressBlock = obj;
return progressBlock != nil;
}]]).andReturn(taskCompletionSource.task).andDo(^(NSInvocation *invocation) {
XCTAssertFalse(enqueuedFirstDownload);
enqueuedFirstDownload = YES;
});
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:[tempPath absoluteString]
mimeType:@"application/octet-stream"];
XCTestExpectation *firstExpectation = [self expectationWithDescription:@"downloadFileAsyncWithStateNumber1"];
[[fileController downloadFileStreamAsyncWithState:fileState cancellationToken:nil progressBlock:^(int percentDone) {
XCTAssertGreaterThan(percentDone, 0);
XCTAssertLessThanOrEqual(percentDone, 100);
}] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
PFAssertIsKindOfClass(task.result, [NSInputStream class]);
[firstExpectation fulfill];
return nil;
}];
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:10.0];
// Wait till the download operation starts
while (!enqueuedFirstDownload && [timeoutDate timeIntervalSinceNow] > 0.0) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
}
XCTestExpectation *secondExpectation = [self expectationWithDescription:@"downloadFileAsyncWithStateNumber2"];
[[fileController downloadFileStreamAsyncWithState:fileState cancellationToken:nil progressBlock:^(int percentDone) {
XCTAssertGreaterThan(percentDone, 0);
XCTAssertLessThanOrEqual(percentDone, 100);
enqueuedSecondDownload = YES;
}] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
PFAssertIsKindOfClass(task.result, [NSInputStream class]);
[secondExpectation fulfill];
return nil;
}];
// Wait till the second operation is enqueued
timeoutDate = [NSDate dateWithTimeIntervalSinceNow:10.0];
while (!enqueuedSecondDownload && [timeoutDate timeIntervalSinceNow] > 0.0) {
progressBlock(50);
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
}
[taskCompletionSource trySetResult:nil];
[self waitForExpectations:@[firstExpectation, secondExpectation] timeout:50.0];
}
- (void)testUpload {
id mockedDataSource = [self mockedDataSource];
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
NSURL *tempPath = [NSURL fileURLWithPath:[temporaryPath stringByAppendingPathComponent:@"sampleData.dat"]];
NSData *sampleData = [self sampleData];
[sampleData writeToURL:tempPath atomically:YES];
id mockedFileManager = [mockedDataSource fileManager];
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
NSDictionary *result = (@{ @"name": @"sampleData", @"url": [tempPath absoluteString] });
PFCommandResult *commandResult = [PFCommandResult commandResultWithResult:result
resultString:nil
httpResponse:nil];
id mockedCommandRunner = [mockedDataSource commandRunner];
[OCMStub(([[mockedCommandRunner ignoringNonObjectArgs] runFileUploadCommandAsync:[OCMArg isNotNil]
withContentType:@"application/octet-stream"
contentSourceFilePath:[tempPath path]
options:0
cancellationToken:nil
progressBlock:[OCMArg isNotNil]])) andReturn:[BFTask taskWithResult:commandResult]];
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:nil
mimeType:@"application/octet-stream"];
__block int progress = -1;
XCTestExpectation *expectation = [self currentSelectorTestExpectation];
[[fileController uploadFileAsyncWithState:fileState
sourceFilePath:[tempPath path]
sessionToken:@"session-token"
cancellationToken:nil
progressBlock:^(int percentDone) {
XCTAssertTrue(progress <= percentDone);
progress = percentDone;
}] continueWithBlock:^id(BFTask<PFFileState *> *task) {
XCTAssertNotNil(task.result);
XCTAssertEqualObjects(task.result.urlString, tempPath.absoluteString);
[expectation fulfill];
return nil;
}];
[self waitForTestExpectations];
}
- (void)testUploadCancel {
id mockedDataSource = PFStrictProtocolMock(@protocol(FileControllerDataSource));
id mockedCommandRunner = PFStrictProtocolMock(@protocol(PFCommandRunning));
id mockedFileManager = PFStrictClassMock([PFFileManager class]);
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
NSURL *tempPath = [NSURL fileURLWithPath:[temporaryPath stringByAppendingPathComponent:@"sampleData.dat"]];
NSData *sampleData = [self sampleData];
[sampleData writeToURL:tempPath atomically:YES];
OCMStub([mockedDataSource fileManager]).andReturn(mockedFileManager);
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
OCMStub([mockedDataSource commandRunner]).andReturn(mockedCommandRunner);
BFCancellationTokenSource *cancellationTokenSource = [BFCancellationTokenSource cancellationTokenSource];
[OCMStub(([[mockedCommandRunner ignoringNonObjectArgs] runFileUploadCommandAsync:[OCMArg isNotNil]
withContentType:@"application/octet-stream"
contentSourceFilePath:[tempPath path]
options:0
cancellationToken:cancellationTokenSource.token
progressBlock:[OCMArg isNotNil]])) andReturn:[BFTask cancelledTask]];
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:nil
mimeType:@"application/octet-stream"];
__block int progress = -1;
XCTestExpectation *expectation = [self currentSelectorTestExpectation];
[[fileController uploadFileAsyncWithState:fileState
sourceFilePath:[tempPath path]
sessionToken:@"session-token"
cancellationToken:cancellationTokenSource.token
progressBlock:^(int percentDone) {
XCTAssertTrue(progress <= percentDone);
progress = percentDone;
}] continueWithBlock:^id(BFTask *task) {
XCTAssertTrue(task.cancelled);
[expectation fulfill];
return nil;
}];
[cancellationTokenSource cancel];
[self waitForTestExpectations];
}
- (void)testClearFileCache {
id mockedDataSource = PFStrictProtocolMock(@protocol(PFFileManagerProvider));
id mockedFileManager = PFStrictClassMock([PFFileManager class]);
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
OCMStub([mockedDataSource fileManager]).andReturn(mockedFileManager);
OCMStub([mockedFileManager parseLocalSandboxDataDirectoryPath]).andReturn(temporaryPath);
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
PFFileState *fileState = [[PFMutableFileState alloc] initWithName:@"sampleData"
urlString:temporaryPath
mimeType:@"application/octet-stream"];
XCTestExpectation *expectation = [self currentSelectorTestExpectation];
[[fileController clearFileCacheAsyncForFileWithState:fileState] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
[expectation fulfill];
return nil;
}];
[self waitForTestExpectations];
}
- (void)testClearAllFilesCache {
id mockedDataSource = PFStrictProtocolMock(@protocol(PFFileManagerProvider));
id mockedFileManager = PFStrictClassMock([PFFileManager class]);
NSString *temporaryPath = [self temporaryDirectory];
NSString *downloadsPath = [temporaryPath stringByAppendingPathComponent:@"downloads"];
OCMStub([mockedDataSource fileManager]).andReturn(mockedFileManager);
OCMStub([mockedFileManager parseLocalSandboxDataDirectoryPath]).andReturn(temporaryPath);
OCMStub([mockedFileManager parseCacheItemPathForPathComponent:@"PFFileCache"]).andReturn(downloadsPath);
PFFileController *fileController = [PFFileController controllerWithDataSource:mockedDataSource];
XCTestExpectation *expectation = [self currentSelectorTestExpectation];
[[fileController clearAllFileCacheAsync] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
[expectation fulfill];
return nil;
}];
[self waitForTestExpectations];
}
@end