File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 13
13
#import " CCDirector.h"
14
14
#import " AppDelegate.h"
15
15
#import " CCUnitTestAssertions.h"
16
+ #import " CCPackage_private.h"
16
17
17
18
@interface CCPackageDownloadManagerTestURLProtocol : NSURLProtocol @end
18
19
@@ -175,6 +176,22 @@ - (void)testEnqueuePausedPackage
175
176
[self assertPackagesDownloadedAndContentsAreAsExpected: @[package1]];
176
177
}
177
178
179
+ - (void )testResumeDownloadAfterLoadingPackages
180
+ {
181
+ // This test aims at the situation when coming back from persistency and
182
+ // the package manager resume downloads.
183
+
184
+ CCPackage *package = [self completePackageWithName: @" package" ];
185
+ package.status = CCPackageStatusDownloadPaused;
186
+ package.localDownloadURL = [NSURL fileURLWithPath: [_downloadManager.downloadPath stringByAppendingPathComponent: @" foo.zip" ]];
187
+
188
+ [_downloadManager enqueuePackageForDownload: package];
189
+
190
+ [self waitUntilDelegateReturns ];
191
+
192
+ [self assertPackagesDownloadedAndContentsAreAsExpected: @[package]];
193
+ }
194
+
178
195
- (void )waitUntilDelegateReturns
179
196
{
180
197
while (!_allDownloadsReturned)
Original file line number Diff line number Diff line change 45
45
- (void )enqueuePackageForDownload : (CCPackage *)package ;
46
46
47
47
/* *
48
- * Cancels a download of a given package. Downloaded file will be deleted.
48
+ * Cancels a download of a given package. Downloaded data will be deleted.
49
+ * Status of package is reset to CCPackageStatusInitial.
49
50
*
50
51
* @param package The package that should be cancelled
51
52
*/
Original file line number Diff line number Diff line change @@ -126,11 +126,25 @@ - (void)pauseDownloadOfPackage:(CCPackage *)package
126
126
127
127
- (void )resumeDownloadOfPackage : (CCPackage *)package
128
128
{
129
+ [self createDownloadIfNotExistForPackage: package];
130
+
129
131
CCLOGINFO (@" [PACKAGE/DOWNLOADS][INFO] Resuming download of package %@ ." , package);
130
132
CCPackageDownload *packageDownload = [self packageDownloadForPackage: package];
131
133
[packageDownload resume ];
132
134
}
133
135
136
+ - (void )createDownloadIfNotExistForPackage : (CCPackage *)package
137
+ {
138
+ if (![self packageDownloadForPackage: package])
139
+ {
140
+ CCPackageDownload *packageDownload = [[CCPackageDownload alloc ] initWithPackage: package
141
+ localURL: package.localDownloadURL];
142
+ packageDownload.delegate = self;
143
+
144
+ [_downloads addObject: packageDownload];
145
+ }
146
+ }
147
+
134
148
- (void )pauseAllDownloads
135
149
{
136
150
CCLOGINFO (@" [PACKAGE/DOWNLOADS][INFO] Pausing all downloads." );
You can’t perform that action at this time.
0 commit comments