From fb32c8e18a606dc6f49ed5ac88636730578f3dac Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 26 Mar 2016 02:20:34 -0400 Subject: [PATCH] Fix unarchiving unit tests --- Sparkle.xcodeproj/project.pbxproj | 2 ++ Sparkle/SUBinaryDeltaUnarchiver.h | 6 +++++- Sparkle/SUUnarchiver.h | 2 +- Sparkle/SUUnarchiver.m | 6 ++++-- Tests/SUUnarchiverTest.swift | 14 ++++---------- Tests/Sparkle Unit Tests-Bridging-Header.h | 1 + 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index dd13b60d..d420883a 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -164,6 +164,7 @@ 726E07671CA61648001A286B /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */; }; 726E07691CA616A4001A286B /* libxar.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 726E07681CA616A4001A286B /* libxar.tbd */; }; 726E076B1CA616B3001A286B /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 726E076A1CA616B3001A286B /* libbz2.tbd */; }; + 726E076D1CA66180001A286B /* SUBinaryDeltaUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */; }; 726E4A0E1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A0D1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 726E4A101C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A0F1C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 726E4A1B1C86C88F00C57C6A /* TestAppHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E4A1A1C86C88F00C57C6A /* TestAppHelper.m */; }; @@ -1880,6 +1881,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 726E076D1CA66180001A286B /* SUBinaryDeltaUnarchiver.m in Sources */, 72A6F9871C94C4AE005F404C /* SUDiskImageUnarchiver.m in Sources */, 72A6F9861C94C49C005F404C /* SUPipedUnarchiver.m in Sources */, 72A6F9841C94C3FE005F404C /* SUBinaryDeltaApply.m in Sources */, diff --git a/Sparkle/SUBinaryDeltaUnarchiver.h b/Sparkle/SUBinaryDeltaUnarchiver.h index 8ae39071..bba78063 100644 --- a/Sparkle/SUBinaryDeltaUnarchiver.h +++ b/Sparkle/SUBinaryDeltaUnarchiver.h @@ -12,10 +12,14 @@ #import #import "SUUnarchiverProtocol.h" +NS_ASSUME_NONNULL_BEGIN + @interface SUBinaryDeltaUnarchiver : NSObject -- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath delegate:(id )delegate; +- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath delegate:(nullable id )delegate; @end +NS_ASSUME_NONNULL_END + #endif diff --git a/Sparkle/SUUnarchiver.h b/Sparkle/SUUnarchiver.h index 78a5df12..dcb6370d 100644 --- a/Sparkle/SUUnarchiver.h +++ b/Sparkle/SUUnarchiver.h @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUUnarchiver : NSObject -+ (nullable id )unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword delegate:(nullable id )delegate; ++ (nullable id )unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword delegate:(nullable id )delegate; @end diff --git a/Sparkle/SUUnarchiver.m b/Sparkle/SUUnarchiver.m index daa525f4..fc38815f 100644 --- a/Sparkle/SUUnarchiver.m +++ b/Sparkle/SUUnarchiver.m @@ -18,7 +18,7 @@ @implementation SUUnarchiver -+ (nullable id )unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword delegate:(nullable id )delegate ++ (nullable id )unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword delegate:(nullable id )delegate { if ([SUPipedUnarchiver canUnarchivePath:path]) { return [[SUPipedUnarchiver alloc] initWithArchivePath:path delegate:delegate]; @@ -27,7 +27,9 @@ return [[SUDiskImageUnarchiver alloc] initWithArchivePath:path decryptionPassword:decryptionPassword delegate:delegate]; } else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) { - return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path updateHostBundlePath:hostPath delegate:delegate]; + assert(hostPath != nil); + NSString *nonNullHostPath = hostPath; + return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path updateHostBundlePath:nonNullHostPath delegate:delegate]; } return nil; diff --git a/Tests/SUUnarchiverTest.swift b/Tests/SUUnarchiverTest.swift index b81ffc38..1724ff55 100644 --- a/Tests/SUUnarchiverTest.swift +++ b/Tests/SUUnarchiverTest.swift @@ -14,17 +14,13 @@ class SUUnarchiverTest: XCTestCase, SUUnarchiverDelegate var unarchivedExpectation: XCTestExpectation? = nil var unarchivedResult: Bool = false - func unarchiver(unarchiver: SUUnarchiver!, extractedProgress progress: Double) - { - } - - func unarchiverDidFail(unarchiver: SUUnarchiver!) + func unarchiverDidFail() { self.unarchivedResult = false self.unarchivedExpectation!.fulfill() } - func unarchiverDidFinish(unarchiver: SUUnarchiver!) + func unarchiverDidFinish() { self.unarchivedResult = true self.unarchivedExpectation!.fulfill() @@ -49,10 +45,8 @@ class SUUnarchiverTest: XCTestCase, SUUnarchiverDelegate self.unarchivedExpectation = super.expectationWithDescription("Unarchived Application (format: \(archiveExtension))") - let unarchiver = SUUnarchiver(forPath: tempArchiveURL.path!, updatingHostBundlePath: nil, withPassword: self.password) - - unarchiver.delegate = self - unarchiver.start() + let unarchiver = SUUnarchiver.unarchiverForPath(tempArchiveURL.path!, updatingHostBundlePath: nil, decryptionPassword: self.password, delegate: self) + unarchiver!.start() super.waitForExpectationsWithTimeout(7.0, handler: nil) diff --git a/Tests/Sparkle Unit Tests-Bridging-Header.h b/Tests/Sparkle Unit Tests-Bridging-Header.h index 94c26869..5b4bec73 100644 --- a/Tests/Sparkle Unit Tests-Bridging-Header.h +++ b/Tests/Sparkle Unit Tests-Bridging-Header.h @@ -3,6 +3,7 @@ // #import "SUUnarchiver.h" +#import "SUUnarchiverProtocol.h" #import "SUPipedUnarchiver.h" #import "SUBinaryDeltaCommon.h" #import "SUFileManager.h"