From 82ae68f282beb33cf37bdf50968f50b37171b9dc Mon Sep 17 00:00:00 2001 From: "Benjamin Scholtysik (Reimold)" Date: Mon, 24 Jul 2017 15:31:14 -0700 Subject: [PATCH 01/19] bump to iOS 8 and some obvious cleanup code --- Classes/BITHockeyHelper.m | 6 ----- Classes/BITImageAnnotationViewController.m | 3 +++ Support/HockeySDK.xcodeproj/project.pbxproj | 30 ++++++++++----------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Classes/BITHockeyHelper.m b/Classes/BITHockeyHelper.m index 61fab15f..796fc801 100644 --- a/Classes/BITHockeyHelper.m +++ b/Classes/BITHockeyHelper.m @@ -63,12 +63,6 @@ + (BOOL)isPhotoAccessPossible { @end -#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000 -@interface NSData (BITHockeySDKiOS7) -- (NSString *)base64Encoding; -@end -#endif - typedef struct { uint8_t info_version; const char bit_version[16]; diff --git a/Classes/BITImageAnnotationViewController.m b/Classes/BITImageAnnotationViewController.m index 665f31d2..f8d95972 100644 --- a/Classes/BITImageAnnotationViewController.m +++ b/Classes/BITImageAnnotationViewController.m @@ -349,6 +349,9 @@ - (void)pinched:(UIPinchGestureRecognizer *)gestureRecognizer { } - (void)tapped:(UIGestureRecognizer *) __unused tapRecognizer { + + // TODO: remove pre-iOS 8 code. + // This toggles the nav and status bar. Since iOS7 and pre-iOS7 behave weirdly different, // this might look rather hacky, but hiding the navbar under iOS6 leads to some ugly // animation effect which is avoided by simply hiding the navbar setting it's alpha to 0. // moritzh diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 715a498a..47433dcf 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -2112,9 +2112,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; @@ -2610,9 +2610,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; @@ -3141,9 +3141,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; @@ -3426,9 +3426,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; ONLY_ACTIVE_ARCH = YES; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; @@ -3470,9 +3470,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; From d84a5677c34a2e865fcd324a61816ad66f6c7ed3 Mon Sep 17 00:00:00 2001 From: "Benjamin Scholtysik (Reimold)" Date: Mon, 24 Jul 2017 15:31:14 -0700 Subject: [PATCH 02/19] bump to iOS 8 and some obvious cleanup code --- Classes/BITHockeyHelper.m | 6 ----- Classes/BITImageAnnotationViewController.m | 3 +++ Support/HockeySDK.xcodeproj/project.pbxproj | 30 ++++++++++----------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Classes/BITHockeyHelper.m b/Classes/BITHockeyHelper.m index 61fab15f..796fc801 100644 --- a/Classes/BITHockeyHelper.m +++ b/Classes/BITHockeyHelper.m @@ -63,12 +63,6 @@ + (BOOL)isPhotoAccessPossible { @end -#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000 -@interface NSData (BITHockeySDKiOS7) -- (NSString *)base64Encoding; -@end -#endif - typedef struct { uint8_t info_version; const char bit_version[16]; diff --git a/Classes/BITImageAnnotationViewController.m b/Classes/BITImageAnnotationViewController.m index 665f31d2..f8d95972 100644 --- a/Classes/BITImageAnnotationViewController.m +++ b/Classes/BITImageAnnotationViewController.m @@ -349,6 +349,9 @@ - (void)pinched:(UIPinchGestureRecognizer *)gestureRecognizer { } - (void)tapped:(UIGestureRecognizer *) __unused tapRecognizer { + + // TODO: remove pre-iOS 8 code. + // This toggles the nav and status bar. Since iOS7 and pre-iOS7 behave weirdly different, // this might look rather hacky, but hiding the navbar under iOS6 leads to some ugly // animation effect which is avoided by simply hiding the navbar setting it's alpha to 0. // moritzh diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 715a498a..47433dcf 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -2112,9 +2112,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; @@ -2610,9 +2610,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; @@ -3141,9 +3141,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; @@ -3426,9 +3426,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; ONLY_ACTIVE_ARCH = YES; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; @@ -3470,9 +3470,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - MACOSX_DEPLOYMENT_TARGET = 10.5; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; From 0ebd64092a53dfdc40b1841e0a9e8489c841b036 Mon Sep 17 00:00:00 2001 From: "Benjamin Scholtysik (Reimold)" Date: Tue, 25 Jul 2017 19:09:28 -0700 Subject: [PATCH 03/19] Bump min iOS version to 8 in podspecs --- HockeySDK-Source.podspec | 2 +- HockeySDK.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HockeySDK-Source.podspec b/HockeySDK-Source.podspec index a4a34e0f..fbb3f202 100644 --- a/HockeySDK-Source.podspec +++ b/HockeySDK-Source.podspec @@ -18,7 +18,7 @@ Pod::Spec.new do |s| s.author = { 'Microsoft' => 'support@hockeyapp.net' } s.source = { :git => 'https://github.com/bitstadium/HockeySDK-iOS.git', :tag => s.version.to_s } - s.platform = :ios, '7.0' + s.platform = :ios, '8.0' s.source_files = 'Classes' s.requires_arc = true diff --git a/HockeySDK.podspec b/HockeySDK.podspec index 3cf9aa99..128a2575 100644 --- a/HockeySDK.podspec +++ b/HockeySDK.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.license = { :type => 'MIT', :file => 'HockeySDK-iOS/LICENSE' } s.author = { 'Microsoft' => 'support@hockeyapp.net' } - s.platform = :ios, '7.0' + s.platform = :ios, '8.0' s.requires_arc = true s.preserve_path = 'HockeySDK-iOS/README.md' From 5ed712e210af0a0dc5770a71f0d50715357c2d85 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 12:17:47 +0300 Subject: [PATCH 04/19] Fixed bug in BITHockeyManager --- Classes/BITHockeyManager.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/BITHockeyManager.m b/Classes/BITHockeyManager.m index 9f5e0a8f..16d56d39 100644 --- a/Classes/BITHockeyManager.m +++ b/Classes/BITHockeyManager.m @@ -558,9 +558,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N - (BITHockeyAppClient *)hockeyAppClient { if (!_hockeyAppClient) { - self.hockeyAppClient = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:self.serverURL]]; + _hockeyAppClient = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:self.serverURL]]; } - return self.hockeyAppClient; + return _hockeyAppClient; } - (NSString *)integrationFlowTimeString { From 6b075b0d2cb98dae5d429f2ddefbd65643452e14 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 13:11:12 +0300 Subject: [PATCH 05/19] =?UTF-8?q?Fixed=20=E2=80=9Civar=20direct=20access?= =?UTF-8?q?=E2=80=9D=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HockeySDKTests/BITAuthenticatorTests.m | 228 +++++++++--------- Support/HockeySDKTests/BITChannelTests.m | 48 ++-- Support/HockeySDKTests/BITCrashManagerTests.m | 181 +++++++------- .../HockeySDKTests/BITHockeyAppClientTests.m | 143 +++++------ Support/HockeySDKTests/BITSenderTests.m | 98 ++++---- .../BITStoreUpdateManagerTests.m | 98 ++++---- .../HockeySDKTests/BITTelemetryContextTests.m | 28 +-- 7 files changed, 413 insertions(+), 411 deletions(-) diff --git a/Support/HockeySDKTests/BITAuthenticatorTests.m b/Support/HockeySDKTests/BITAuthenticatorTests.m index 55f8a5f1..c78ed450 100644 --- a/Support/HockeySDKTests/BITAuthenticatorTests.m +++ b/Support/HockeySDKTests/BITAuthenticatorTests.m @@ -46,22 +46,22 @@ - (instancetype)init { static void *kInstallationIdentification = &kInstallationIdentification; @interface BITAuthenticatorTests : XCTestCase + +@property(nonatomic, strong) BITAuthenticator *sut; + @end -@implementation BITAuthenticatorTests { - BITAuthenticator *_sut; - BOOL _KVOCalled; -} +@implementation BITAuthenticatorTests - (void)setUp { [super setUp]; - _sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentOther]; + self.sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentOther]; } - (void)tearDown { - [_sut cleanupInternalStorage]; - _sut = nil; + [self.sut cleanupInternalStorage]; + self.sut = nil; [super tearDown]; } @@ -79,144 +79,144 @@ - (NSDictionary *)jsonFromFixture:(NSString *)fixture { #pragma mark - Setup Tests - (void) testThatItInstantiates { - XCTAssertNotNil(_sut, @"Should be there"); + XCTAssertNotNil(self.sut, @"Should be there"); } #pragma mark - Persistence Tests - (void) testThatLastAuthenticatedVersionIsPersisted { - _sut.lastAuthenticatedVersion = @"1.2.1"; - _sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentAppStore]; - assertThat(_sut.lastAuthenticatedVersion, equalTo(@"1.2.1")); + self.sut.lastAuthenticatedVersion = @"1.2.1"; + self.sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentAppStore]; + assertThat(self.sut.lastAuthenticatedVersion, equalTo(@"1.2.1")); } - (void) testThatCleanupWorks { - _sut.lastAuthenticatedVersion = @"1.2"; + self.sut.lastAuthenticatedVersion = @"1.2"; - [_sut cleanupInternalStorage]; + [self.sut cleanupInternalStorage]; - assertThat(_sut.lastAuthenticatedVersion, equalTo(nil)); - assertThat(_sut.installationIdentifier, equalTo(nil)); + assertThat(self.sut.lastAuthenticatedVersion, equalTo(nil)); + assertThat(self.sut.installationIdentifier, equalTo(nil)); } #pragma mark - Initial defaults - (void) testDefaultValues { - assertThatBool(_sut.restrictApplicationUsage, isFalse()); - assertThatBool(_sut.isIdentified, isFalse()); - assertThatBool(_sut.isValidated, isFalse()); - assertThat(_sut.authenticationSecret, equalTo(nil)); - assertThat(_sut.installationIdentifier, equalTo(nil)); - assertThat(_sut.installationIdentifierParameterString, equalTo(@"uuid")); + assertThatBool(self.sut.restrictApplicationUsage, isFalse()); + assertThatBool(self.sut.isIdentified, isFalse()); + assertThatBool(self.sut.isValidated, isFalse()); + assertThat(self.sut.authenticationSecret, equalTo(nil)); + assertThat(self.sut.installationIdentifier, equalTo(nil)); + assertThat(self.sut.installationIdentifierParameterString, equalTo(@"uuid")); } #pragma mark - General identification tests - (void) testThatIsDoesntShowMoreThanOneAuthenticationController { id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate)); - _sut.delegate = delegateMock; - _sut.identificationType = BITAuthenticatorIdentificationTypeDevice; + self.sut.delegate = delegateMock; + self.sut.identificationType = BITAuthenticatorIdentificationTypeDevice; - [_sut identifyWithCompletion:nil]; - [_sut identifyWithCompletion:nil]; - [_sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; - [verifyCount(delegateMock, times(1)) authenticator:_sut willShowAuthenticationController:(id)anything()]; + [verifyCount(delegateMock, times(1)) authenticator:self.sut willShowAuthenticationController:(id)anything()]; } - (void) testThatChangingIdentificationTypeResetsIdentifiedFlag { - _sut.identified = YES; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; - assertThatBool(_sut.identified, isFalse()); + self.sut.identified = YES; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; + assertThatBool(self.sut.identified, isFalse()); } - (void) testThatAfterChangingIdentificationTypeIdentificationIsRedone { - [_sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; - _sut.identified = YES; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; - [_sut identifyWithCompletion:nil]; - assertThatBool(_sut.identified, isFalse()); - assertThat(_sut.installationIdentifier, nilValue()); + [self.sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; + self.sut.identified = YES; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; + [self.sut identifyWithCompletion:nil]; + assertThatBool(self.sut.identified, isFalse()); + assertThat(self.sut.installationIdentifier, nilValue()); } - (void) testThatIdentifyingAnAlreadyIdentifiedInstanceDoesNothing { id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - [_sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; - _sut.identified = YES; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + [self.sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; + self.sut.identified = YES; - [_sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; - [verifyCount(delegateMock, never()) authenticator:_sut willShowAuthenticationController:(id)anything()]; + [verifyCount(delegateMock, never()) authenticator:self.sut willShowAuthenticationController:(id)anything()]; } #pragma mark - Anonymous identification type - (void) testAnonymousIdentification { - _sut.identificationType = BITAuthenticatorIdentificationTypeAnonymous; - assertThatBool(_sut.isIdentified, isFalse()); - [_sut identifyWithCompletion:^(BOOL identified, NSError *error) { + self.sut.identificationType = BITAuthenticatorIdentificationTypeAnonymous; + assertThatBool(self.sut.isIdentified, isFalse()); + [self.sut identifyWithCompletion:^(BOOL identified, NSError *error) { assertThatBool(identified, isTrue()); assertThat(error, equalTo(nil)); }]; - assertThatBool(_sut.isIdentified, isTrue()); - assertThat(_sut.installationIdentifier, notNilValue()); + assertThatBool(self.sut.isIdentified, isTrue()); + assertThat(self.sut.installationIdentifier, notNilValue()); } //anoynmous users can't be validated - (void) testAnonymousValidation { - _sut.identificationType = BITAuthenticatorIdentificationTypeAnonymous; - assertThatBool(_sut.isValidated, isFalse()); - [_sut validateWithCompletion:^(BOOL validated, NSError *error) { - assertThatBool(_sut.validated, isFalse()); + self.sut.identificationType = BITAuthenticatorIdentificationTypeAnonymous; + assertThatBool(self.sut.isValidated, isFalse()); + [self.sut validateWithCompletion:^(BOOL validated, NSError *error) { + assertThatBool(self.sut.validated, isFalse()); assertThat(error, notNilValue()); }]; - assertThatBool(_sut.isValidated, isFalse()); + assertThatBool(self.sut.isValidated, isFalse()); } #pragma mark - Device identification type - (void) testDeviceIdentificationShowsViewController { - _sut.identificationType = BITAuthenticatorIdentificationTypeDevice; + self.sut.identificationType = BITAuthenticatorIdentificationTypeDevice; id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - [_sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; - [verifyCount(delegateMock, times(1)) authenticator:_sut willShowAuthenticationController:(id)anything()]; + [verifyCount(delegateMock, times(1)) authenticator:self.sut willShowAuthenticationController:(id)anything()]; } #pragma mark - Web auth identification type - (void) testWebAuthIdentificationShowsViewController { - _sut.identificationType = BITAuthenticatorIdentificationTypeWebAuth; + self.sut.identificationType = BITAuthenticatorIdentificationTypeWebAuth; id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - [_sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; - [verifyCount(delegateMock, times(1)) authenticator:_sut willShowAuthenticationController:(id)anything()]; + [verifyCount(delegateMock, times(1)) authenticator:self.sut willShowAuthenticationController:(id)anything()]; } #pragma mark - Email identification type - (void) testEmailIdentificationFailsWithMissingSecret { - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - [_sut identifyWithCompletion:^(BOOL identified, NSError *error) { + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + [self.sut identifyWithCompletion:^(BOOL identified, NSError *error) { assertThatBool(identified, isFalse()); assertThat(error, notNilValue()); }]; } - (void) testEmailIdentificationShowsViewController { - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - _sut.authenticationSecret = @"mySecret"; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + self.sut.authenticationSecret = @"mySecret"; id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - [_sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; - [verifyCount(delegateMock, times(1)) authenticator:_sut willShowAuthenticationController:(id)anything()]; + [verifyCount(delegateMock, times(1)) authenticator:self.sut willShowAuthenticationController:(id)anything()]; } - (void) testEmailValidationFailsWithMissingSecret { - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - [_sut validateWithCompletion:^(BOOL validated, NSError *error) { + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + [self.sut validateWithCompletion:^(BOOL validated, NSError *error) { assertThatBool(validated, isFalse()); assertThat(error, notNilValue()); }]; @@ -227,33 +227,33 @@ - (void) testThatEmailIdentificationQueuesAnOperation { OCMStub([helperMock isURLSessionSupported]).andReturn(NO); id httpClientMock = mock(BITHockeyAppClient.class); - _sut.hockeyAppClient = httpClientMock; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - [_sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; - _sut.authenticationSecret = @"double"; + self.sut.hockeyAppClient = httpClientMock; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + [self.sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; + self.sut.authenticationSecret = @"double"; - [_sut authenticationViewController:nil handleAuthenticationWithEmail:@"stephan@dd.de" request:[NSURLRequest new] completion:nil]; + [self.sut authenticationViewController:nil handleAuthenticationWithEmail:@"stephan@dd.de" request:[NSURLRequest new] completion:nil]; [verify(httpClientMock) enqeueHTTPOperation:anything()]; } #pragma mark - User identification type - (void) testUserIdentificationShowsViewController { - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - [_sut identifyWithCompletion:nil]; + [self.sut identifyWithCompletion:nil]; - [verifyCount(delegateMock, times(1)) authenticator:_sut willShowAuthenticationController:(id)anything()]; + [verifyCount(delegateMock, times(1)) authenticator:self.sut willShowAuthenticationController:(id)anything()]; } #pragma mark - Generic validation tests - (void) testThatValidationFailsIfNotIdentified { - _sut.identified = NO; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; - [_sut validateWithCompletion:^(BOOL validated, NSError *error) { + self.sut.identified = NO; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppUser; + [self.sut validateWithCompletion:^(BOOL validated, NSError *error) { assertThatBool(validated, isFalse()); assertThatLong(error.code, equalToLong(BITAuthenticatorNotIdentified)); }]; @@ -263,11 +263,11 @@ - (void) testThatValidationCreatesAGETRequest { id helperMock = OCMClassMock([BITHockeyHelper class]); OCMStub([helperMock isURLSessionSupported]).andReturn(NO); id httpClientMock = mock(BITHockeyAppClient.class); - _sut.hockeyAppClient = httpClientMock; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - [_sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; - _sut.authenticationSecret = @"double"; - [_sut validateWithCompletion:nil]; + self.sut.hockeyAppClient = httpClientMock; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + [self.sut storeInstallationIdentifier:@"meh" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; + self.sut.authenticationSecret = @"double"; + [self.sut validateWithCompletion:nil]; [verify(httpClientMock) getPath:(id)anything() parameters:(id)anything() completion:(id)anything()]; @@ -275,26 +275,26 @@ - (void) testThatValidationCreatesAGETRequest { #pragma mark - Authentication - (void) testThatEnabledRestrictionTriggersValidation { - id mockAuthenticator = OCMPartialMock(_sut); - _sut.authenticationSecret = @"sekret"; - _sut.restrictApplicationUsage = YES; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - [_sut storeInstallationIdentifier:@"asd" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; + id mockAuthenticator = OCMPartialMock(self.sut); + self.sut.authenticationSecret = @"sekret"; + self.sut.restrictApplicationUsage = YES; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + [self.sut storeInstallationIdentifier:@"asd" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; OCMExpect([mockAuthenticator validateWithCompletion:(id)anything()]); - [_sut authenticate]; + [self.sut authenticate]; OCMVerifyAll(mockAuthenticator); } - (void) testThatDisabledRestrictionDoesntTriggerValidation { id clientMock = mock(BITHockeyAppClient.class); - _sut.hockeyAppClient = clientMock; - _sut.authenticationSecret = @"sekret"; - _sut.restrictApplicationUsage = NO; - _sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; - [_sut storeInstallationIdentifier:@"asd" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; - [_sut authenticate]; + self.sut.hockeyAppClient = clientMock; + self.sut.authenticationSecret = @"sekret"; + self.sut.restrictApplicationUsage = NO; + self.sut.identificationType = BITAuthenticatorIdentificationTypeHockeyAppEmail; + [self.sut storeInstallationIdentifier:@"asd" withType:BITAuthenticatorIdentificationTypeHockeyAppEmail]; + [self.sut authenticate]; [verifyCount(clientMock, never()) getPath:(id)anything() parameters:(id)anything() completion:(id)anything()]; } @@ -302,31 +302,31 @@ - (void) testThatDisabledRestrictionDoesntTriggerValidation { #pragma mark - Lifetime checks - (void) testThatValidationTriggersOnDidBecomeActive { id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate)); - _sut.delegate = delegateMock; - _sut.identificationType = BITAuthenticatorIdentificationTypeDevice; - _sut.restrictApplicationUsage = YES; + self.sut.delegate = delegateMock; + self.sut.identificationType = BITAuthenticatorIdentificationTypeDevice; + self.sut.restrictApplicationUsage = YES; - [_sut applicationDidBecomeActive:nil]; + [self.sut applicationDidBecomeActive:nil]; - [verify(delegateMock) authenticator:_sut willShowAuthenticationController:(id)anything()]; + [verify(delegateMock) authenticator:self.sut willShowAuthenticationController:(id)anything()]; } #pragma mark - Validation helper checks - (void) testThatValidationTriggersOnNewVersion { - _sut.restrictApplicationUsage = YES; - _sut.restrictionEnforcementFrequency = BITAuthenticatorAppRestrictionEnforcementOnFirstLaunch; - _sut.identificationType = BITAuthenticatorIdentificationTypeDevice; - _sut.validated = YES; - _sut.lastAuthenticatedVersion = @"111xxx"; - assertThatBool(_sut.needsValidation, isTrue()); + self.sut.restrictApplicationUsage = YES; + self.sut.restrictionEnforcementFrequency = BITAuthenticatorAppRestrictionEnforcementOnFirstLaunch; + self.sut.identificationType = BITAuthenticatorIdentificationTypeDevice; + self.sut.validated = YES; + self.sut.lastAuthenticatedVersion = @"111xxx"; + assertThatBool(self.sut.needsValidation, isTrue()); } - (void) testThatValidationDoesNotTriggerOnSameVersion { - _sut.restrictApplicationUsage = YES; - _sut.restrictionEnforcementFrequency = BITAuthenticatorAppRestrictionEnforcementOnFirstLaunch; - _sut.validated = YES; - _sut.lastAuthenticatedVersion = _sut.executableUUID; - assertThatBool(_sut.needsValidation, isFalse()); + self.sut.restrictApplicationUsage = YES; + self.sut.restrictionEnforcementFrequency = BITAuthenticatorAppRestrictionEnforcementOnFirstLaunch; + self.sut.validated = YES; + self.sut.lastAuthenticatedVersion = self.sut.executableUUID; + assertThatBool(self.sut.needsValidation, isFalse()); } @end diff --git a/Support/HockeySDKTests/BITChannelTests.m b/Support/HockeySDKTests/BITChannelTests.m index 22e584a1..35c278ae 100644 --- a/Support/HockeySDKTests/BITChannelTests.m +++ b/Support/HockeySDKTests/BITChannelTests.m @@ -14,20 +14,20 @@ @interface BITChannelTests : XCTestCase +@property(nonatomic, strong) BITChannel *sut; +@property(nonatomic, strong) BITPersistence *mockPersistence; + @end -@implementation BITChannelTests { - BITChannel *_sut; - BITPersistence *_mockPersistence; -} +@implementation BITChannelTests - (void)setUp { [super setUp]; - _mockPersistence = OCMPartialMock([[BITPersistence alloc] init]); + self.mockPersistence = OCMPartialMock([[BITPersistence alloc] init]); BITTelemetryContext *mockContext = mock(BITTelemetryContext.class); - _sut = [[BITChannel alloc]initWithTelemetryContext:mockContext persistence:_mockPersistence]; + self.sut = [[BITChannel alloc]initWithTelemetryContext:mockContext persistence:self.mockPersistence]; bit_resetSafeJsonStream(&BITSafeJsonEventsString); } @@ -35,47 +35,47 @@ - (void)setUp { - (void)testNewInstanceWasInitialisedCorrectly { XCTAssertNotNil([BITChannel new]); - XCTAssertNotNil(_sut.dataItemsOperations); + XCTAssertNotNil(self.sut.dataItemsOperations); } #pragma mark - Queue management - (void)testEnqueueEnvelopeWithOneEnvelopeAndJSONStream { - _sut = OCMPartialMock(_sut); - _sut.maxBatchSize = 3; + self.sut = OCMPartialMock(self.sut); + self.sut.maxBatchSize = 3; BITTelemetryData *testData = [BITTelemetryData new]; - [_sut enqueueTelemetryItem:testData]; + [self.sut enqueueTelemetryItem:testData]; - dispatch_sync(_sut.dataItemsOperations, ^{ - assertThatUnsignedInteger(_sut.dataItemCount, equalToUnsignedInteger(1)); + dispatch_sync(self.sut.dataItemsOperations, ^{ + assertThatUnsignedInteger(self.sut.dataItemCount, equalToUnsignedInteger(1)); XCTAssertTrue(strlen(BITSafeJsonEventsString) > 0); }); } - (void)testEnqueueEnvelopeWithMultipleEnvelopesAndJSONStream { - _sut = OCMPartialMock(_sut); - _sut.maxBatchSize = 3; + self.sut = OCMPartialMock(self.sut); + self.sut.maxBatchSize = 3; BITTelemetryData *testData = [BITTelemetryData new]; - assertThatUnsignedInteger(_sut.dataItemCount, equalToUnsignedInteger(0)); + assertThatUnsignedInteger(self.sut.dataItemCount, equalToUnsignedInteger(0)); - [_sut enqueueTelemetryItem:testData]; - dispatch_sync(_sut.dataItemsOperations, ^{ - assertThatUnsignedInteger(_sut.dataItemCount, equalToUnsignedInteger(1)); + [self.sut enqueueTelemetryItem:testData]; + dispatch_sync(self.sut.dataItemsOperations, ^{ + assertThatUnsignedInteger(self.sut.dataItemCount, equalToUnsignedInteger(1)); XCTAssertTrue(strlen(BITSafeJsonEventsString) > 0); }); - [_sut enqueueTelemetryItem:testData]; - dispatch_sync(_sut.dataItemsOperations, ^{ - assertThatUnsignedInteger(_sut.dataItemCount, equalToUnsignedInteger(2)); + [self.sut enqueueTelemetryItem:testData]; + dispatch_sync(self.sut.dataItemsOperations, ^{ + assertThatUnsignedInteger(self.sut.dataItemCount, equalToUnsignedInteger(2)); XCTAssertTrue(strlen(BITSafeJsonEventsString) > 0); }); - [_sut enqueueTelemetryItem:testData]; - dispatch_sync(_sut.dataItemsOperations, ^{ - assertThatUnsignedInteger(_sut.dataItemCount, equalToUnsignedInteger(0)); + [self.sut enqueueTelemetryItem:testData]; + dispatch_sync(self.sut.dataItemsOperations, ^{ + assertThatUnsignedInteger(self.sut.dataItemCount, equalToUnsignedInteger(0)); XCTAssertTrue(strcmp(BITSafeJsonEventsString, "") == 0); }); } diff --git a/Support/HockeySDKTests/BITCrashManagerTests.m b/Support/HockeySDKTests/BITCrashManagerTests.m index 3e321a43..737dc15d 100644 --- a/Support/HockeySDKTests/BITCrashManagerTests.m +++ b/Support/HockeySDKTests/BITCrashManagerTests.m @@ -28,37 +28,38 @@ @interface BITCrashManagerTests : XCTestCase @property BITCrashManager *sut; +@property BOOL startManagerInitialized; @end @implementation BITCrashManagerTests { - BOOL _startManagerInitialized; + } - (void)setUp { [super setUp]; - _startManagerInitialized = NO; - _sut = [[BITCrashManager alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentOther hockeyAppClient:[[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString: BITHOCKEYSDK_URL]]]; + self.startManagerInitialized = NO; + self.sut = [[BITCrashManager alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentOther hockeyAppClient:[[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString: BITHOCKEYSDK_URL]]]; } - (void)tearDown { - [_sut cleanCrashReports]; + [self.sut cleanCrashReports]; [super tearDown]; } #pragma mark - Private - (void)startManager { - [_sut startManager]; - [NSObject cancelPreviousPerformRequestsWithTarget:_sut selector:@selector(invokeDelayedProcessing) object:nil]; - _startManagerInitialized = YES; + [self.sut startManager]; + [NSObject cancelPreviousPerformRequestsWithTarget:self.sut selector:@selector(invokeDelayedProcessing) object:nil]; + self.startManagerInitialized = YES; } - (void)startManagerDisabled { - _sut.crashManagerStatus = BITCrashManagerStatusDisabled; - if (_startManagerInitialized) return; + self.sut.crashManagerStatus = BITCrashManagerStatusDisabled; + if (self.startManagerInitialized) return; [self startManager]; } @@ -68,15 +69,15 @@ - (void)startManagerAutoSend { [given([metricsManagerMock persistence]) willReturn:[[BITPersistence alloc] init]]; [[BITHockeyManager sharedHockeyManager] setValue:metricsManagerMock forKey:@"metricsManager"]; - _sut.crashManagerStatus = BITCrashManagerStatusAutoSend; - if (_startManagerInitialized) return; + self.sut.crashManagerStatus = BITCrashManagerStatusAutoSend; + if (self.startManagerInitialized) return; [self startManager]; } #pragma mark - Setup Tests - (void)testThatItInstantiates { - XCTAssertNotNil(_sut, @"Should be there"); + XCTAssertNotNil(self.sut, @"Should be there"); } #pragma mark - Getter/Setter tests @@ -100,14 +101,14 @@ - (void)testSetServerURL { - (void)testPersistUserProvidedMetaData { NSString *tempCrashName = @"tempCrash"; - [_sut setLastCrashFilename:tempCrashName]; + [self.sut setLastCrashFilename:tempCrashName]; BITCrashMetaData *metaData = [BITCrashMetaData new]; [metaData setUserProvidedDescription:@"Test string"]; - [_sut persistUserProvidedMetaData:metaData]; + [self.sut persistUserProvidedMetaData:metaData]; NSError *error; - NSString *description = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@.desc", [[_sut crashesDir] stringByAppendingPathComponent: tempCrashName]] encoding:NSUTF8StringEncoding error:&error]; + NSString *description = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@.desc", [[self.sut crashesDir] stringByAppendingPathComponent: tempCrashName]] encoding:NSUTF8StringEncoding error:&error]; assertThat(description, equalTo(@"Test string")); } @@ -118,11 +119,11 @@ - (void)testPersistAttachment { NSString* type = @"text/plain"; BITHockeyAttachment *originalAttachment = [[BITHockeyAttachment alloc] initWithFilename:filename hockeyAttachmentData:data contentType:type]; - NSString *attachmentFilename = [[_sut crashesDir] stringByAppendingPathComponent:@"testAttachment"]; + NSString *attachmentFilename = [[self.sut crashesDir] stringByAppendingPathComponent:@"testAttachment"]; - [_sut persistAttachment:originalAttachment withFilename:attachmentFilename]; + [self.sut persistAttachment:originalAttachment withFilename:attachmentFilename]; - BITHockeyAttachment *decodedAttachment = [_sut attachmentForCrashReport:attachmentFilename]; + BITHockeyAttachment *decodedAttachment = [self.sut attachmentForCrashReport:attachmentFilename]; assertThat(decodedAttachment.filename, equalTo(filename)); assertThat(decodedAttachment.hockeyAttachmentData, equalTo(data)); @@ -135,78 +136,78 @@ - (void)testUserIDForCrashReport { BITHockeyManager *hm = [BITHockeyManager sharedHockeyManager]; id delegateMock = mockProtocol(@protocol(BITHockeyManagerDelegate)); hm.delegate = delegateMock; - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - NSString *result = [_sut userIDForCrashReport]; + NSString *result = [self.sut userIDForCrashReport]; assertThat(result, notNilValue()); - [verifyCount(delegateMock, times(1)) userIDForHockeyManager:hm componentManager:_sut]; + [verifyCount(delegateMock, times(1)) userIDForHockeyManager:hm componentManager:self.sut]; } - (void)testUserNameForCrashReport { BITHockeyManager *hm = [BITHockeyManager sharedHockeyManager]; id delegateMock = mockProtocol(@protocol(BITHockeyManagerDelegate)); hm.delegate = delegateMock; - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - NSString *result = [_sut userNameForCrashReport]; + NSString *result = [self.sut userNameForCrashReport]; assertThat(result, notNilValue()); - [verifyCount(delegateMock, times(1)) userNameForHockeyManager:hm componentManager:_sut]; + [verifyCount(delegateMock, times(1)) userNameForHockeyManager:hm componentManager:self.sut]; } - (void)testUserEmailForCrashReport { BITHockeyManager *hm = [BITHockeyManager sharedHockeyManager]; id delegateMock = mockProtocol(@protocol(BITHockeyManagerDelegate)); hm.delegate = delegateMock; - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - NSString *result = [_sut userEmailForCrashReport]; + NSString *result = [self.sut userEmailForCrashReport]; assertThat(result, notNilValue()); - [verifyCount(delegateMock, times(1)) userEmailForHockeyManager:hm componentManager:_sut]; + [verifyCount(delegateMock, times(1)) userEmailForHockeyManager:hm componentManager:self.sut]; } #pragma mark - Handle User Input - (void)testHandleUserInputDontSend { id delegateMock = mockProtocol(@protocol(BITCrashManagerDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; - assertThatBool([_sut handleUserInput:BITCrashManagerUserInputDontSend withUserProvidedMetaData:nil], isTrue()); + assertThatBool([self.sut handleUserInput:BITCrashManagerUserInputDontSend withUserProvidedMetaData:nil], isTrue()); - [verify(delegateMock) crashManagerWillCancelSendingCrashReport:_sut]; + [verify(delegateMock) crashManagerWillCancelSendingCrashReport:self.sut]; } - (void)testHandleUserInputSend { - assertThatBool([_sut handleUserInput:BITCrashManagerUserInputSend withUserProvidedMetaData:nil], isTrue()); + assertThatBool([self.sut handleUserInput:BITCrashManagerUserInputSend withUserProvidedMetaData:nil], isTrue()); } - (void)testHandleUserInputAlwaysSend { id delegateMock = mockProtocol(@protocol(BITCrashManagerDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); //Test if CrashManagerStatus is unset [given([mockUserDefaults integerForKey:@"BITCrashManagerStatus"]) willReturn:nil]; //Test if method runs through - assertThatBool([_sut handleUserInput:BITCrashManagerUserInputAlwaysSend withUserProvidedMetaData:nil], isTrue()); + assertThatBool([self.sut handleUserInput:BITCrashManagerUserInputAlwaysSend withUserProvidedMetaData:nil], isTrue()); //Test if correct CrashManagerStatus is now set [given([mockUserDefaults integerForKey:@"BITCrashManagerStauts"]) willReturnInt:BITCrashManagerStatusAutoSend]; //Verify that delegate method has been called - [verify(delegateMock) crashManagerWillSendCrashReportsAlways:_sut]; + [verify(delegateMock) crashManagerWillSendCrashReportsAlways:self.sut]; } - (void)testHandleUserInputWithInvalidInput { - assertThatBool([_sut handleUserInput:3 withUserProvidedMetaData:nil], isFalse()); + assertThatBool([self.sut handleUserInput:3 withUserProvidedMetaData:nil], isFalse()); } #pragma mark - Debugger @@ -220,20 +221,20 @@ - (void)testHandleUserInputWithInvalidInput { * TODO: what to do if we do run this e.g. on Jenkins or Xcode bots ? */ - (void)testIsDebuggerAttached { - assertThatBool([_sut isDebuggerAttached], isTrue()); + assertThatBool([self.sut isDebuggerAttached], isTrue()); } #endif #pragma mark - Helper - (void)testHasPendingCrashReportWithNoFiles { - _sut.crashManagerStatus = BITCrashManagerStatusAutoSend; - assertThatBool([_sut hasPendingCrashReport], isFalse()); + self.sut.crashManagerStatus = BITCrashManagerStatusAutoSend; + assertThatBool([self.sut hasPendingCrashReport], isFalse()); } - (void)testFirstNotApprovedCrashReportWithNoFiles { - _sut.crashManagerStatus = BITCrashManagerStatusAutoSend; - assertThat([_sut firstNotApprovedCrashReport], equalTo(nil)); + self.sut.crashManagerStatus = BITCrashManagerStatusAutoSend; + assertThat([self.sut firstNotApprovedCrashReport], equalTo(nil)); } @@ -242,7 +243,7 @@ - (void)testFirstNotApprovedCrashReportWithNoFiles { - (void)testStartManagerWithModuleDisabled { [self startManagerDisabled]; - assertThat(_sut.plCrashReporter, equalTo(nil)); + assertThat(self.sut.plCrashReporter, equalTo(nil)); } - (void)testStartManagerWithAutoSend { @@ -254,128 +255,128 @@ - (void)testStartManagerWithAutoSend { // to make this better testable with unit tests id delegateMock = mockProtocol(@protocol(BITCrashManagerDelegate)); - _sut.delegate = delegateMock; + self.sut.delegate = delegateMock; [self startManagerAutoSend]; - assertThat(_sut.plCrashReporter, notNilValue()); + assertThat(self.sut.plCrashReporter, notNilValue()); // When running from the debugger this is always nil and not the exception handler from PLCR NSUncaughtExceptionHandler *currentHandler = NSGetUncaughtExceptionHandler(); - BOOL result = (_sut.exceptionHandler == currentHandler); + BOOL result = (self.sut.exceptionHandler == currentHandler); assertThatBool(result, isTrue()); // No files at startup - assertThatBool([_sut hasPendingCrashReport], isFalse()); - assertThat([_sut firstNotApprovedCrashReport], equalTo(nil)); + assertThatBool([self.sut hasPendingCrashReport], isFalse()); + assertThat([self.sut firstNotApprovedCrashReport], equalTo(nil)); - [_sut invokeDelayedProcessing]; + [self.sut invokeDelayedProcessing]; // handle a new empty crash report assertThatBool([BITTestHelper copyFixtureCrashReportWithFileName:@"live_report_empty"], isTrue()); - [_sut handleCrashReport]; + [self.sut handleCrashReport]; // we should have 0 pending crash report - assertThatBool([_sut hasPendingCrashReport], isFalse()); - assertThat([_sut firstNotApprovedCrashReport], equalTo(nil)); + assertThatBool([self.sut hasPendingCrashReport], isFalse()); + assertThat([self.sut firstNotApprovedCrashReport], equalTo(nil)); - [_sut cleanCrashReports]; + [self.sut cleanCrashReports]; // handle a new signal crash report assertThatBool([BITTestHelper copyFixtureCrashReportWithFileName:@"live_report_signal"], isTrue()); - [_sut handleCrashReport]; + [self.sut handleCrashReport]; // this old report doesn't have a marketing version present - assertThat(_sut.lastSessionCrashDetails.appVersion, equalTo(nil)); + assertThat(self.sut.lastSessionCrashDetails.appVersion, equalTo(nil)); - [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:_sut]; - [verifyCount(delegateMock, times(1)) attachmentForCrashManager:_sut]; + [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:self.sut]; + [verifyCount(delegateMock, times(1)) attachmentForCrashManager:self.sut]; // we should have now 1 pending crash report - assertThatBool([_sut hasPendingCrashReport], isTrue()); - assertThat([_sut firstNotApprovedCrashReport], notNilValue()); + assertThatBool([self.sut hasPendingCrashReport], isTrue()); + assertThat([self.sut firstNotApprovedCrashReport], notNilValue()); // this is currently sending blindly, needs refactoring to test properly - [_sut sendNextCrashReport]; - [verifyCount(delegateMock, times(1)) crashManagerWillSendCrashReport:_sut]; + [self.sut sendNextCrashReport]; + [verifyCount(delegateMock, times(1)) crashManagerWillSendCrashReport:self.sut]; - [_sut cleanCrashReports]; + [self.sut cleanCrashReports]; // handle a new signal crash report assertThatBool([BITTestHelper copyFixtureCrashReportWithFileName:@"live_report_exception"], isTrue()); - [_sut handleCrashReport]; + [self.sut handleCrashReport]; // this old report doesn't have a marketing version present - assertThat(_sut.lastSessionCrashDetails.appVersion, equalTo(nil)); + assertThat(self.sut.lastSessionCrashDetails.appVersion, equalTo(nil)); - [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:_sut]; - [verifyCount(delegateMock, times(1)) attachmentForCrashManager:_sut]; + [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:self.sut]; + [verifyCount(delegateMock, times(1)) attachmentForCrashManager:self.sut]; // we should have now 1 pending crash report - assertThatBool([_sut hasPendingCrashReport], isTrue()); - assertThat([_sut firstNotApprovedCrashReport], notNilValue()); + assertThatBool([self.sut hasPendingCrashReport], isTrue()); + assertThat([self.sut firstNotApprovedCrashReport], notNilValue()); - [_sut cleanCrashReports]; + [self.sut cleanCrashReports]; // handle a new signal crash report assertThatBool([BITTestHelper copyFixtureCrashReportWithFileName:@"live_report_signal_marketing"], isTrue()); - [_sut handleCrashReport]; + [self.sut handleCrashReport]; // this old report doesn't have a marketing version present - assertThat(_sut.lastSessionCrashDetails.appVersion, notNilValue()); + assertThat(self.sut.lastSessionCrashDetails.appVersion, notNilValue()); - [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:_sut]; - [verifyCount(delegateMock, times(1)) attachmentForCrashManager:_sut]; + [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:self.sut]; + [verifyCount(delegateMock, times(1)) attachmentForCrashManager:self.sut]; // we should have now 1 pending crash report - assertThatBool([_sut hasPendingCrashReport], isTrue()); - assertThat([_sut firstNotApprovedCrashReport], notNilValue()); + assertThatBool([self.sut hasPendingCrashReport], isTrue()); + assertThat([self.sut firstNotApprovedCrashReport], notNilValue()); // this is currently sending blindly, needs refactoring to test properly - [_sut sendNextCrashReport]; - [verifyCount(delegateMock, times(1)) crashManagerWillSendCrashReport:_sut]; + [self.sut sendNextCrashReport]; + [verifyCount(delegateMock, times(1)) crashManagerWillSendCrashReport:self.sut]; - [_sut cleanCrashReports]; + [self.sut cleanCrashReports]; // handle a new signal crash report assertThatBool([BITTestHelper copyFixtureCrashReportWithFileName:@"live_report_exception_marketing"], isTrue()); - [_sut handleCrashReport]; + [self.sut handleCrashReport]; // this old report doesn't have a marketing version present - assertThat(_sut.lastSessionCrashDetails.appVersion, notNilValue()); + assertThat(self.sut.lastSessionCrashDetails.appVersion, notNilValue()); - [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:_sut]; - [verifyCount(delegateMock, times(1)) attachmentForCrashManager:_sut]; + [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:self.sut]; + [verifyCount(delegateMock, times(1)) attachmentForCrashManager:self.sut]; // we should have now 1 pending crash report - assertThatBool([_sut hasPendingCrashReport], isTrue()); - assertThat([_sut firstNotApprovedCrashReport], notNilValue()); + assertThatBool([self.sut hasPendingCrashReport], isTrue()); + assertThat([self.sut firstNotApprovedCrashReport], notNilValue()); - [_sut cleanCrashReports]; + [self.sut cleanCrashReports]; // handle a new xamarin crash report assertThatBool([BITTestHelper copyFixtureCrashReportWithFileName:@"live_report_xamarin"], isTrue()); - [_sut handleCrashReport]; + [self.sut handleCrashReport]; // this old report doesn't have a marketing version present - assertThat(_sut.lastSessionCrashDetails.appVersion, notNilValue()); + assertThat(self.sut.lastSessionCrashDetails.appVersion, notNilValue()); - [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:_sut]; - [verifyCount(delegateMock, times(1)) attachmentForCrashManager:_sut]; + [verifyCount(delegateMock, times(1)) applicationLogForCrashManager:self.sut]; + [verifyCount(delegateMock, times(1)) attachmentForCrashManager:self.sut]; // we should have now 1 pending crash report - assertThatBool([_sut hasPendingCrashReport], isTrue()); - assertThat([_sut firstNotApprovedCrashReport], notNilValue()); + assertThatBool([self.sut hasPendingCrashReport], isTrue()); + assertThat([self.sut firstNotApprovedCrashReport], notNilValue()); - [_sut cleanCrashReports]; + [self.sut cleanCrashReports]; } @end diff --git a/Support/HockeySDKTests/BITHockeyAppClientTests.m b/Support/HockeySDKTests/BITHockeyAppClientTests.m index ccc3c7b7..193201fc 100644 --- a/Support/HockeySDKTests/BITHockeyAppClientTests.m +++ b/Support/HockeySDKTests/BITHockeyAppClientTests.m @@ -17,21 +17,22 @@ #import "BITTestHelper.h" @interface BITHockeyAppClientTests : XCTestCase + +@property(nonatomic, strong) BITHockeyAppClient *sut; + @end -@implementation BITHockeyAppClientTests { - BITHockeyAppClient *_sut; -} +@implementation BITHockeyAppClientTests - (void)setUp { [super setUp]; - _sut = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://bitbaseurl.com"]]; + self.sut = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://bitbaseurl.com"]]; } - (void)tearDown { - [_sut cancelOperationsWithPath:nil method:nil]; - _sut = nil; + [self.sut cancelOperationsWithPath:nil method:nil]; + self.sut = nil; [super tearDown]; } @@ -49,32 +50,32 @@ - (NSDictionary *)jsonFromFixture:(NSString *)fixture { #pragma mark - Setup Tests - (void) testThatItInstantiates { - XCTAssertNotNil(_sut, @"Should be there"); + XCTAssertNotNil(self.sut, @"Should be there"); } #pragma mark - Networking base tests - (void) testThatURLRequestHasBaseURLSet { - _sut.baseURL = [NSURL URLWithString:@"http://myserver.com"]; - NSMutableURLRequest *request = [_sut requestWithMethod:@"GET" path:nil parameters:nil]; + self.sut.baseURL = [NSURL URLWithString:@"http://myserver.com"]; + NSMutableURLRequest *request = [self.sut requestWithMethod:@"GET" path:nil parameters:nil]; assertThat(request.URL, equalTo([NSURL URLWithString:@"http://myserver.com/"])); } - (void) testThatURLRequestHasPathAppended { - _sut.baseURL = [NSURL URLWithString:@"http://myserver.com"]; - NSMutableURLRequest *request = [_sut requestWithMethod:@"GET" path:@"projects" parameters:nil]; + self.sut.baseURL = [NSURL URLWithString:@"http://myserver.com"]; + NSMutableURLRequest *request = [self.sut requestWithMethod:@"GET" path:@"projects" parameters:nil]; assertThat(request.URL, equalTo([NSURL URLWithString:@"http://myserver.com/projects"])); } - (void) testThatURLRequestHasMethodSet { - NSMutableURLRequest *request = [_sut requestWithMethod:@"POST" path:nil parameters:nil]; + NSMutableURLRequest *request = [self.sut requestWithMethod:@"POST" path:nil parameters:nil]; assertThat(request.HTTPMethod, equalTo(@"POST")); } - (void) testThatOperationHasURLRequestSet { - _sut.baseURL = [NSURL URLWithString:@"http://myserver.com"]; - NSURLRequest *r = [_sut requestWithMethod:@"PUT" path:@"x" parameters:nil]; - BITHTTPOperation *op = [_sut operationWithURLRequest:r + self.sut.baseURL = [NSURL URLWithString:@"http://myserver.com"]; + NSURLRequest *r = [self.sut requestWithMethod:@"PUT" path:@"x" parameters:nil]; + BITHTTPOperation *op = [self.sut operationWithURLRequest:r completion:nil]; assertThat(op.URLRequest, equalTo(r)); } @@ -84,7 +85,7 @@ - (void) testThatURLRequestHasParametersInGetAppended { @"email" : @"peter@pan.de", @"push" : @"pop", }; - NSMutableURLRequest *request = [_sut requestWithMethod:@"GET" + NSMutableURLRequest *request = [self.sut requestWithMethod:@"GET" path:@"something" parameters:parameters]; NSURL *url = request.URL; @@ -107,25 +108,25 @@ - (void) testThatURLRequestHasParametersInPostInTheBody { #pragma mark - Convenience methods - (void) testThatGetPathCreatesAndEnquesAnOperation { - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(0)); - [given([_sut operationWithURLRequest:(id)anything() + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(0)); + [given([self.sut operationWithURLRequest:(id)anything() completion:nil]) willReturn:[NSOperation new]]; - [_sut getPath:@"endpoint" + [self.sut getPath:@"endpoint" parameters:nil completion:nil]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(1)); + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(1)); } - (void) testThatPostPathCreatesAndEnquesAnOperation { - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(0)); - [given([_sut operationWithURLRequest:nil + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(0)); + [given([self.sut operationWithURLRequest:nil completion:nil]) willReturn:[NSOperation new]]; - [_sut postPath:@"endpoint" + [self.sut postPath:@"endpoint" parameters:nil completion:nil]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(1)); + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(1)); } #pragma mark - Completion Tests @@ -135,91 +136,91 @@ - (void) testThatCompletionIsCalled { #pragma mark - HTTPOperation enqueuing / cancellation - (void) testThatOperationIsQueued { - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(0)); - [_sut.operationQueue setSuspended:YES]; + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(0)); + [self.sut.operationQueue setSuspended:YES]; BITHTTPOperation *op = [BITHTTPOperation new]; - [_sut enqeueHTTPOperation:op]; + [self.sut enqeueHTTPOperation:op]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(1)); + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(1)); } - (void) testThatOperationCancellingMatchesAllOperationsWithNilMethod { - [_sut.operationQueue setSuspended:YES]; - NSURLRequest *requestGet = [_sut requestWithMethod:@"GET" path:nil parameters:nil]; - NSURLRequest *requestPut = [_sut requestWithMethod:@"PUT" path:nil parameters:nil]; - NSURLRequest *requestPost = [_sut requestWithMethod:@"POST" path:nil parameters:nil]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestGet + [self.sut.operationQueue setSuspended:YES]; + NSURLRequest *requestGet = [self.sut requestWithMethod:@"GET" path:nil parameters:nil]; + NSURLRequest *requestPut = [self.sut requestWithMethod:@"PUT" path:nil parameters:nil]; + NSURLRequest *requestPost = [self.sut requestWithMethod:@"POST" path:nil parameters:nil]; + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestGet completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPut + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPut completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPost + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPost completion:nil]]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(3)); - NSUInteger numCancelled = [_sut cancelOperationsWithPath:nil method:nil]; + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(3)); + NSUInteger numCancelled = [self.sut cancelOperationsWithPath:nil method:nil]; assertThatUnsignedLong(numCancelled, equalToUnsignedLong(3)); } - (void) testThatOperationCancellingMatchesAllOperationsWithNilPath { - [_sut.operationQueue setSuspended:YES]; - NSURLRequest *requestGet = [_sut requestWithMethod:@"GET" path:@"test" parameters:nil]; - NSURLRequest *requestPut = [_sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; - NSURLRequest *requestPost = [_sut requestWithMethod:@"POST" path:nil parameters:nil]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestGet + [self.sut.operationQueue setSuspended:YES]; + NSURLRequest *requestGet = [self.sut requestWithMethod:@"GET" path:@"test" parameters:nil]; + NSURLRequest *requestPut = [self.sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; + NSURLRequest *requestPost = [self.sut requestWithMethod:@"POST" path:nil parameters:nil]; + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestGet completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPut + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPut completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPost + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPost completion:nil]]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(3)); - NSUInteger numCancelled = [_sut cancelOperationsWithPath:nil method:nil]; + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(3)); + NSUInteger numCancelled = [self.sut cancelOperationsWithPath:nil method:nil]; assertThatUnsignedLong(numCancelled, equalToUnsignedLong(3)); } - (void) testThatOperationCancellingMatchesAllOperationsWithSetPath { - NSURLRequest *requestGet = [_sut requestWithMethod:@"GET" path:@"test" parameters:nil]; - NSURLRequest *requestPut = [_sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; - NSURLRequest *requestPost = [_sut requestWithMethod:@"POST" path:nil parameters:nil]; - [_sut.operationQueue setSuspended:YES]; + NSURLRequest *requestGet = [self.sut requestWithMethod:@"GET" path:@"test" parameters:nil]; + NSURLRequest *requestPut = [self.sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; + NSURLRequest *requestPost = [self.sut requestWithMethod:@"POST" path:nil parameters:nil]; + [self.sut.operationQueue setSuspended:YES]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestGet + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestGet completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPut + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPut completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPost + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPost completion:nil]]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(3)); - NSUInteger numCancelled = [_sut cancelOperationsWithPath:@"Another/acas" method:nil]; + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(3)); + NSUInteger numCancelled = [self.sut cancelOperationsWithPath:@"Another/acas" method:nil]; assertThatUnsignedLong(numCancelled, equalToUnsignedLong(1)); } - (void) testThatOperationCancellingMatchesAllOperationsWithSetMethod { - NSURLRequest *requestGet = [_sut requestWithMethod:@"GET" path:@"test" parameters:nil]; - NSURLRequest *requestPut = [_sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; - NSURLRequest *requestPost = [_sut requestWithMethod:@"POST" path:nil parameters:nil]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestGet + NSURLRequest *requestGet = [self.sut requestWithMethod:@"GET" path:@"test" parameters:nil]; + NSURLRequest *requestPut = [self.sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; + NSURLRequest *requestPost = [self.sut requestWithMethod:@"POST" path:nil parameters:nil]; + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestGet completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPut + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPut completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPost + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPost completion:nil]]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(3)); - NSUInteger numCancelled = [_sut cancelOperationsWithPath:nil method:@"POST"]; + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(3)); + NSUInteger numCancelled = [self.sut cancelOperationsWithPath:nil method:@"POST"]; assertThatUnsignedLong(numCancelled, equalToUnsignedLong(1)); } - (void) testThatOperationCancellingMatchesAllOperationsWithSetMethodAndPath { - NSURLRequest *requestGet = [_sut requestWithMethod:@"GET" path:@"test" parameters:nil]; - NSURLRequest *requestPut = [_sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; - NSURLRequest *requestPost = [_sut requestWithMethod:@"POST" path:nil parameters:nil]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestGet + NSURLRequest *requestGet = [self.sut requestWithMethod:@"GET" path:@"test" parameters:nil]; + NSURLRequest *requestPut = [self.sut requestWithMethod:@"PUT" path:@"Another/acas" parameters:nil]; + NSURLRequest *requestPost = [self.sut requestWithMethod:@"POST" path:nil parameters:nil]; + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestGet completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPut + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPut completion:nil]]; - [_sut enqeueHTTPOperation:[_sut operationWithURLRequest:requestPost + [self.sut enqeueHTTPOperation:[self.sut operationWithURLRequest:requestPost completion:nil]]; - assertThatUnsignedLong(_sut.operationQueue.operationCount, equalToUnsignedLong(3)); - NSUInteger numCancelled = [_sut cancelOperationsWithPath:@"Another/acas" method:@"PUT"]; + assertThatUnsignedLong(self.sut.operationQueue.operationCount, equalToUnsignedLong(3)); + NSUInteger numCancelled = [self.sut cancelOperationsWithPath:@"Another/acas" method:@"PUT"]; assertThatUnsignedLong(numCancelled, equalToUnsignedLong(1)); } diff --git a/Support/HockeySDKTests/BITSenderTests.m b/Support/HockeySDKTests/BITSenderTests.m index d35443fd..12f2ba9a 100644 --- a/Support/HockeySDKTests/BITSenderTests.m +++ b/Support/HockeySDKTests/BITSenderTests.m @@ -12,35 +12,35 @@ @interface BITSenderTests : BITTestsDependencyInjection +@property(nonatomic, strong) BITSender *sut; +@property(nonatomic, strong) BITPersistence *mockPersistence; +@property(nonatomic, strong) NSURL *testServerURL; + @end -@implementation BITSenderTests{ - BITSender *_sut; - BITPersistence *_mockPersistence; - NSURL *_testServerURL; -} +@implementation BITSenderTests - (void)setUp { [super setUp]; - _testServerURL = [NSURL URLWithString:@"http://test.com"]; - _sut = [self newSender]; + self.testServerURL = [NSURL URLWithString:@"http://test.com"]; + self.sut = [self newSender]; } - (void)tearDown { - _sut = nil; + self.sut = nil; [super tearDown]; } - (BITSender *)newSender { - _mockPersistence = mock(BITPersistence.class); - return [[BITSender alloc]initWithPersistence:_mockPersistence serverURL:[_testServerURL copy]]; + self.mockPersistence = mock(BITPersistence.class); + return [[BITSender alloc]initWithPersistence:self.mockPersistence serverURL:[self.testServerURL copy]]; } - (void)testThatItInstantiatesCorrectly { - XCTAssertNotNil(_sut); - XCTAssertNotNil(_sut.senderTasksQueue); - XCTAssertEqualObjects(_sut.persistence, _mockPersistence); - XCTAssertEqualObjects(_sut.serverURL, _testServerURL); + XCTAssertNotNil(self.sut); + XCTAssertNotNil(self.sut.senderTasksQueue); + XCTAssertEqualObjects(self.sut.persistence, self.mockPersistence); + XCTAssertEqualObjects(self.sut.serverURL, self.testServerURL); } - (void)testRequestContainsDataItem { @@ -48,7 +48,7 @@ - (void)testRequestContainsDataItem { NSData *expectedBodyData = [NSJSONSerialization dataWithJSONObject:[testItem serializeToDictionary] options:0 error:nil]; - NSURLRequest *testRequest = [_sut requestForData:expectedBodyData]; + NSURLRequest *testRequest = [self.sut requestForData:expectedBodyData]; XCTAssertNotNil(testRequest); XCTAssertEqualObjects(testRequest.HTTPBody, expectedBodyData); @@ -56,31 +56,31 @@ - (void)testRequestContainsDataItem { - (void)testSendDataTriggersPlatformSpecificNetworkOperation { // setup - _sut = OCMPartialMock(_sut); - OCMStub([_sut isURLSessionSupported]).andReturn(YES); + self.sut = OCMPartialMock(self.sut); + OCMStub([self.sut isURLSessionSupported]).andReturn(YES); NSURLRequest *testRequest = [NSURLRequest new]; NSString *testFilePath = @"path/to/file"; - [_sut sendRequest:testRequest filePath:testFilePath]; + [self.sut sendRequest:testRequest filePath:testFilePath]; - OCMVerify([_sut sendUsingURLSessionWithRequest:testRequest filePath:testFilePath]); + OCMVerify([self.sut sendUsingURLSessionWithRequest:testRequest filePath:testFilePath]); - _sut = OCMPartialMock([self newSender]); - OCMStub([_sut isURLSessionSupported]).andReturn(NO); + self.sut = OCMPartialMock([self newSender]); + OCMStub([self.sut isURLSessionSupported]).andReturn(NO); - [_sut sendRequest:testRequest filePath:testFilePath]; + [self.sut sendRequest:testRequest filePath:testFilePath]; - OCMVerify([_sut sendUsingURLConnectionWithRequest:testRequest filePath:testFilePath]); + OCMVerify([self.sut sendUsingURLConnectionWithRequest:testRequest filePath:testFilePath]); } - (void)testSendDataVerifyDataIsGzipped { - _sut = OCMPartialMock(_sut); + self.sut = OCMPartialMock(self.sut); NSString *testFilePath = @"path/to/file"; NSData *testData = [@"test" dataUsingEncoding:NSUTF8StringEncoding]; - [_sut sendData:testData withFilePath:testFilePath]; + [self.sut sendData:testData withFilePath:testFilePath]; - OCMVerify([_sut sendRequest:[OCMArg checkWithBlock:^BOOL(id obj) { + OCMVerify([self.sut sendRequest:[OCMArg checkWithBlock:^BOOL(id obj) { NSMutableURLRequest *request = (NSMutableURLRequest *)obj; NSData *data = request.HTTPBody; if (data) { @@ -99,29 +99,29 @@ - (void)testSendDataVerifyDataIsGzipped { - (void)testSendUsingURLConnection { // setup - _sut = OCMPartialMock(_sut); + self.sut = OCMPartialMock(self.sut); NSString *testFilePath = @"path/to/file"; NSURLRequest *testRequest = [NSURLRequest new]; // test - [_sut sendUsingURLConnectionWithRequest:testRequest filePath:testFilePath]; + [self.sut sendUsingURLConnectionWithRequest:testRequest filePath:testFilePath]; //verify - OCMVerify([_sut.operationQueue addOperation:(id)anything()]); + OCMVerify([self.sut.operationQueue addOperation:(id)anything()]); } - (void)testSendUsingURLSession { // setup= - _sut = OCMPartialMock(_sut); + self.sut = OCMPartialMock(self.sut); NSString *testFilePath = @"path/to/file"; NSURLRequest *testRequest = [NSURLRequest new]; - if ([_sut isURLSessionSupported]) { + if ([self.sut isURLSessionSupported]) { // test - [_sut sendUsingURLSessionWithRequest:testRequest filePath:testFilePath]; + [self.sut sendUsingURLSessionWithRequest:testRequest filePath:testFilePath]; //verify - OCMVerify([_sut resumeSessionDataTask:(id)anything()]); + OCMVerify([self.sut resumeSessionDataTask:(id)anything()]); } } @@ -129,16 +129,16 @@ - (void)testDeleteDataWithStatusCodeWorks{ for(NSInteger statusCode = 100; statusCode <= 510; statusCode++){ if((statusCode == 429) || (statusCode == 408) || (statusCode == 500) || (statusCode == 503) || (statusCode == 511)) { - XCTAssertTrue([_sut shouldDeleteDataWithStatusCode:statusCode] == NO); + XCTAssertTrue([self.sut shouldDeleteDataWithStatusCode:statusCode] == NO); }else{ - XCTAssertTrue([_sut shouldDeleteDataWithStatusCode:statusCode] == YES); + XCTAssertTrue([self.sut shouldDeleteDataWithStatusCode:statusCode] == YES); } } } - (void)testRegisterObserversOnInit { self.mockNotificationCenter = mock(NSNotificationCenter.class); - _sut = [[BITSender alloc]initWithPersistence:_mockPersistence serverURL:_testServerURL]; + self.sut = [[BITSender alloc]initWithPersistence:self.mockPersistence serverURL:self.testServerURL]; [verify((id)self.mockNotificationCenter) addObserverForName:BITPersistenceSuccessNotification object:nil queue:nil usingBlock:(id)anything()]; } @@ -146,44 +146,44 @@ - (void)testRegisterObserversOnInit { - (void)testFilesGetDeletedOnPositiveOrUnrecoverableStatusCodes { // setup= - _sut = OCMPartialMock(_sut); + self.sut = OCMPartialMock(self.sut); NSInteger testStatusCode = 999; - OCMStub([_sut shouldDeleteDataWithStatusCode:testStatusCode]).andReturn(YES); - _sut.runningRequestsCount = 8; + OCMStub([self.sut shouldDeleteDataWithStatusCode:testStatusCode]).andReturn(YES); + self.sut.runningRequestsCount = 8; NSData *testData = [@"test" dataUsingEncoding:NSUTF8StringEncoding]; NSString *testFilePath = @"path/to/file"; // Stub `sendSavedData` method so there won't be already a new running request when our test request finishes // Otherwise `runningRequestsCount` will already have been decreased by one and been increased by one again. - OCMStub([_sut sendSavedData]).andDo(nil); + OCMStub([self.sut sendSavedData]).andDo(nil); // test - [_sut handleResponseWithStatusCode:testStatusCode responseData:testData filePath:testFilePath error:[NSError errorWithDomain:@"Network error" code:503 userInfo:nil]]; + [self.sut handleResponseWithStatusCode:testStatusCode responseData:testData filePath:testFilePath error:[NSError errorWithDomain:@"Network error" code:503 userInfo:nil]]; //verify - [verify(_mockPersistence) deleteFileAtPath:testFilePath]; - XCTAssertTrue(_sut.runningRequestsCount == 7); + [verify(self.mockPersistence) deleteFileAtPath:testFilePath]; + XCTAssertTrue(self.sut.runningRequestsCount == 7); } - (void)testFilesGetUnblockedOnRecoverableErrorCodes { // setup= - _sut = OCMPartialMock(_sut); + self.sut = OCMPartialMock(self.sut); NSInteger testStatusCode = 999; - OCMStub([_sut shouldDeleteDataWithStatusCode:testStatusCode]).andReturn(NO); - _sut.runningRequestsCount = 8; + OCMStub([self.sut shouldDeleteDataWithStatusCode:testStatusCode]).andReturn(NO); + self.sut.runningRequestsCount = 8; NSData *testData = [@"test" dataUsingEncoding:NSUTF8StringEncoding]; NSString *testFilePath = @"path/to/file"; // test - [_sut handleResponseWithStatusCode:testStatusCode + [self.sut handleResponseWithStatusCode:testStatusCode responseData:testData filePath:testFilePath error:[NSError errorWithDomain:@"Network error" code:503 userInfo:nil]]; //verify - [verify(_mockPersistence) giveBackRequestedFilePath:testFilePath]; - XCTAssertTrue(_sut.runningRequestsCount == 7); + [verify(self.mockPersistence) giveBackRequestedFilePath:testFilePath]; + XCTAssertTrue(self.sut.runningRequestsCount == 7); } @end diff --git a/Support/HockeySDKTests/BITStoreUpdateManagerTests.m b/Support/HockeySDKTests/BITStoreUpdateManagerTests.m index c196846d..b81a7625 100644 --- a/Support/HockeySDKTests/BITStoreUpdateManagerTests.m +++ b/Support/HockeySDKTests/BITStoreUpdateManagerTests.m @@ -22,23 +22,23 @@ @interface BITStoreUpdateManagerTests : XCTestCase +@property(nonatomic, strong) BITStoreUpdateManager *storeUpdateManager; + @end -@implementation BITStoreUpdateManagerTests { - BITStoreUpdateManager *_storeUpdateManager; -} +@implementation BITStoreUpdateManagerTests - (void)setUp { [super setUp]; // Set-up code here. - _storeUpdateManager = [[BITStoreUpdateManager alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentAppStore]; + self.storeUpdateManager = [[BITStoreUpdateManager alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentAppStore]; } - (void)tearDown { // Tear-down code here. - _storeUpdateManager = nil; + self.storeUpdateManager = nil; [super tearDown]; } @@ -59,9 +59,9 @@ - (NSDictionary *)jsonFromFixture:(NSString *)fixture { } - (void)startManager { - _storeUpdateManager.enableStoreUpdateManager = YES; - [_storeUpdateManager startManager]; - [NSObject cancelPreviousPerformRequestsWithTarget:_storeUpdateManager selector:@selector(checkForUpdateDelayed) object:nil]; + self.storeUpdateManager.enableStoreUpdateManager = YES; + [self.storeUpdateManager startManager]; + [NSObject cancelPreviousPerformRequestsWithTarget:self.storeUpdateManager selector:@selector(checkForUpdateDelayed) object:nil]; } @@ -69,11 +69,11 @@ - (void)startManager { - (void)testUpdateCheckDailyFirstTimeEver { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertTrue(result, @"Checking daily first time ever"); } @@ -81,36 +81,36 @@ - (void)testUpdateCheckDailyFirstTimeEver { - (void)testUpdateCheckDailyFirstTimeTodayLastCheckPreviousDay { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateDateOfLastCheck"]) willReturn:[NSDate dateWithTimeIntervalSinceNow:-(60*60*24)]]; - _storeUpdateManager.userDefaults = mockUserDefaults; - _storeUpdateManager.updateSetting = BITStoreUpdateCheckDaily; + self.storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.updateSetting = BITStoreUpdateCheckDaily; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertTrue(result, @"Checking daily first time today with last check done previous day"); } - (void)testUpdateCheckDailySecondTimeOfTheDay { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); - _storeUpdateManager.userDefaults = mockUserDefaults; - _storeUpdateManager.lastCheck = [NSDate date]; + self.storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.lastCheck = [NSDate date]; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertFalse(result, @"Checking daily second time of the day"); } - (void)testUpdateCheckWeeklyFirstTimeEver { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); - _storeUpdateManager.userDefaults = mockUserDefaults; - _storeUpdateManager.updateSetting = BITStoreUpdateCheckWeekly; + self.storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.updateSetting = BITStoreUpdateCheckWeekly; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertTrue(result, @"Checking weekly first time ever"); } @@ -118,12 +118,12 @@ - (void)testUpdateCheckWeeklyFirstTimeEver { - (void)testUpdateCheckWeeklyFirstTimeTodayLastCheckPreviousWeek { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateDateOfLastCheck"]) willReturn:[NSDate dateWithTimeIntervalSinceNow:-(60*60*24*7)]]; - _storeUpdateManager.userDefaults = mockUserDefaults; - _storeUpdateManager.updateSetting = BITStoreUpdateCheckWeekly; + self.storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.updateSetting = BITStoreUpdateCheckWeekly; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertTrue(result, @"Checking weekly first time after one week"); } @@ -131,24 +131,24 @@ - (void)testUpdateCheckWeeklyFirstTimeTodayLastCheckPreviousWeek { - (void)testUpdateCheckWeeklyFirstTimeFiveDaysAfterPreviousCheck { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateDateOfLastCheck"]) willReturn:[NSDate dateWithTimeIntervalSinceNow:-(60*60*24*5)]]; - _storeUpdateManager.userDefaults = mockUserDefaults; - _storeUpdateManager.updateSetting = BITStoreUpdateCheckWeekly; + self.storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.updateSetting = BITStoreUpdateCheckWeekly; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertFalse(result, @"Checking weekly first time five days after previous check"); } - (void)testUpdateCheckManuallyFirstTimeEver { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); - _storeUpdateManager.userDefaults = mockUserDefaults; - _storeUpdateManager.updateSetting = BITStoreUpdateCheckManually; + self.storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.updateSetting = BITStoreUpdateCheckManually; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertFalse(result, @"Checking manually first time ever"); } @@ -156,12 +156,12 @@ - (void)testUpdateCheckManuallyFirstTimeEver { - (void)testUpdateCheckManuallyFirstTimeTodayLastCheckDonePreviousDay { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateDateOfLastCheck"]) willReturn:[NSDate dateWithTimeIntervalSinceNow:-(60*60*24)]]; - _storeUpdateManager.userDefaults = mockUserDefaults; - _storeUpdateManager.updateSetting = BITStoreUpdateCheckManually; + self.storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.updateSetting = BITStoreUpdateCheckManually; [self startManager]; - BOOL result = [_storeUpdateManager shouldAutoCheckForUpdates]; + BOOL result = [self.storeUpdateManager shouldAutoCheckForUpdates]; XCTAssertFalse(result, @"Checking manually first time ever"); } @@ -170,28 +170,28 @@ - (void)testUpdateCheckManuallyFirstTimeTodayLastCheckDonePreviousDay { #pragma mark - JSON Response Processing - (void)testProcessStoreResponseWithEmptyData { - BOOL result = [_storeUpdateManager processStoreResponseWithString:nil]; + BOOL result = [self.storeUpdateManager processStoreResponseWithString:nil]; XCTAssertFalse(result, @"Empty data was handled correctly"); } - (void)testProcessStoreResponseWithInvalidData { NSString *invalidString = @"8a@c&)if"; - BOOL result = [_storeUpdateManager processStoreResponseWithString:invalidString]; + BOOL result = [self.storeUpdateManager processStoreResponseWithString:invalidString]; XCTAssertFalse(result, @"Invalid JSON data was handled correctly"); } - (void)testProcessStoreResponseWithUnknownBundleIdentifier { NSString *dataString = [BITTestHelper jsonFixture:@"StoreBundleIdentifierUnknown"]; - BOOL result = [_storeUpdateManager processStoreResponseWithString:dataString]; + BOOL result = [self.storeUpdateManager processStoreResponseWithString:dataString]; XCTAssertFalse(result, @"Valid but empty json data was handled correctly"); } - (void)testProcessStoreResponseWithKnownBundleIdentifier { NSString *dataString = [BITTestHelper jsonFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager processStoreResponseWithString:dataString]; + BOOL result = [self.storeUpdateManager processStoreResponseWithString:dataString]; XCTAssertTrue(result, @"Valid and correct JSON data was handled correctly"); } @@ -203,13 +203,13 @@ - (void)testProcessStoreResponseWithKnownBundleIdentifier { - (void)testFirstStartHasNewVersionReturnsFalseWithFirstCheck { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; NSDictionary *json = [self jsonFromFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager hasNewVersion:json]; + BOOL result = [self.storeUpdateManager hasNewVersion:json]; XCTAssertFalse(result, @"There is no udpate available"); } @@ -218,13 +218,13 @@ - (void)testFirstStartHasNewVersionReturnsFalseWithSameVersion { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastStoreVersion"]) willReturn:@"4.1.2"]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastUUID"]) willReturn:@""]; - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; NSDictionary *json = [self jsonFromFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager hasNewVersion:json]; + BOOL result = [self.storeUpdateManager hasNewVersion:json]; XCTAssertFalse(result, @"There is no udpate available"); } @@ -234,13 +234,13 @@ - (void)testFirstStartHasNewVersionReturnsFalseWithSameVersionButDifferentUUID { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastStoreVersion"]) willReturn:@"4.1.2"]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastUUID"]) willReturn:@"1"]; - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; NSDictionary *json = [self jsonFromFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager hasNewVersion:json]; + BOOL result = [self.storeUpdateManager hasNewVersion:json]; XCTAssertFalse(result, @"There is no udpate available"); } @@ -249,13 +249,13 @@ - (void)testFirstStartHasNewVersionReturnsTrue { NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastStoreVersion"]) willReturn:@"4.1.1"]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastUUID"]) willReturn:@""]; - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; NSDictionary *json = [self jsonFromFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager hasNewVersion:json]; + BOOL result = [self.storeUpdateManager hasNewVersion:json]; XCTAssertTrue(result, @"There is an udpate available"); } @@ -265,13 +265,13 @@ - (void)testFirstStartHasNewVersionReturnsFalseBecauseWeHaveANewerVersionInstall NSUserDefaults *mockUserDefaults = mock([NSUserDefaults class]); [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastStoreVersion"]) willReturn:@"4.1.3"]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastUUID"]) willReturn:@""]; - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; NSDictionary *json = [self jsonFromFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager hasNewVersion:json]; + BOOL result = [self.storeUpdateManager hasNewVersion:json]; XCTAssertFalse(result, @"There is no udpate available"); } @@ -281,13 +281,13 @@ - (void)testReportedVersionIsBeingIgnored { [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastStoreVersion"]) willReturn:@"4.1.1"]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastUUID"]) willReturn:@""]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateIgnoredVersion"]) willReturn:@"4.1.2"]; - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; NSDictionary *json = [self jsonFromFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager hasNewVersion:json]; + BOOL result = [self.storeUpdateManager hasNewVersion:json]; XCTAssertFalse(result, @"The newer version is being ignored"); } @@ -297,13 +297,13 @@ - (void)testReportedVersionIsNewerThanTheIgnoredVersion { [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastStoreVersion"]) willReturn:@"4.1.1"]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateLastUUID"]) willReturn:@""]; [given([mockUserDefaults objectForKey:@"BITStoreUpdateIgnoredVersion"]) willReturn:@"4.1.1"]; - _storeUpdateManager.userDefaults = mockUserDefaults; + self.storeUpdateManager.userDefaults = mockUserDefaults; [self startManager]; NSDictionary *json = [self jsonFromFixture:@"StoreBundleIdentifierKnown"]; - BOOL result = [_storeUpdateManager hasNewVersion:json]; + BOOL result = [self.storeUpdateManager hasNewVersion:json]; XCTAssertTrue(result, @"The newer version is not ignored"); } diff --git a/Support/HockeySDKTests/BITTelemetryContextTests.m b/Support/HockeySDKTests/BITTelemetryContextTests.m index 685e3b56..890c7282 100644 --- a/Support/HockeySDKTests/BITTelemetryContextTests.m +++ b/Support/HockeySDKTests/BITTelemetryContextTests.m @@ -13,12 +13,12 @@ @interface BITTelemetryContextTests : XCTestCase +@property(nonatomic, strong) BITTelemetryContext *sut; +@property(nonatomic, strong) BITPersistence *mockPersistence; + @end -@implementation BITTelemetryContextTests { - BITTelemetryContext *_sut; - BITPersistence *_mockPersistence; -} +@implementation BITTelemetryContextTests - (void)setUp { [super setUp]; @@ -31,25 +31,25 @@ - (void)tearDown { } - (void)testThatContextObjectsNotNil { - XCTAssertNotNil(_sut.device); - XCTAssertNotNil(_sut.internal); - XCTAssertNotNil(_sut.application); - XCTAssertNotNil(_sut.session); - XCTAssertNotNil(_sut.user); - XCTAssertNotNil(_sut.appIdentifier); + XCTAssertNotNil(self.sut.device); + XCTAssertNotNil(self.sut.internal); + XCTAssertNotNil(self.sut.application); + XCTAssertNotNil(self.sut.session); + XCTAssertNotNil(self.sut.user); + XCTAssertNotNil(self.sut.appIdentifier); } - (void)testUserMetaDataGetsLoadedOnInit { [self initDependencies]; - [verify(_mockPersistence) metaData]; + [verify(self.mockPersistence) metaData]; } #ifndef CI - (void)testContextDictionaryPerformance { [self measureBlock:^{ for (int i = 0; i < 1000; ++i) { - [_sut contextDictionary]; + [self.sut contextDictionary]; } }]; } @@ -58,8 +58,8 @@ - (void)testContextDictionaryPerformance { #pragma mark - Setup helpers - (void)initDependencies { - _mockPersistence = mock(BITPersistence.class); - _sut = [[BITTelemetryContext alloc] initWithAppIdentifier:@"123" persistence:_mockPersistence]; + self.mockPersistence = mock(BITPersistence.class); + self.sut = [[BITTelemetryContext alloc] initWithAppIdentifier:@"123" persistence:self.mockPersistence]; } -(void)wait { From 0f08b72f2d4c4d435a54c462f355ba856e9993df Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 13:14:35 +0300 Subject: [PATCH 06/19] =?UTF-8?q?Fixed=20=E2=80=9Cunused=20variables?= =?UTF-8?q?=E2=80=9D=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Support/HockeySDKTests/BITAuthenticatorTests.m | 2 +- Support/HockeySDKTests/BITHockeyLoggerTests.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Support/HockeySDKTests/BITAuthenticatorTests.m b/Support/HockeySDKTests/BITAuthenticatorTests.m index c78ed450..1a3d5685 100644 --- a/Support/HockeySDKTests/BITAuthenticatorTests.m +++ b/Support/HockeySDKTests/BITAuthenticatorTests.m @@ -166,7 +166,7 @@ - (void) testAnonymousIdentification { - (void) testAnonymousValidation { self.sut.identificationType = BITAuthenticatorIdentificationTypeAnonymous; assertThatBool(self.sut.isValidated, isFalse()); - [self.sut validateWithCompletion:^(BOOL validated, NSError *error) { + [self.sut validateWithCompletion:^(BOOL __unused validated, NSError *error) { assertThatBool(self.sut.validated, isFalse()); assertThat(error, notNilValue()); }]; diff --git a/Support/HockeySDKTests/BITHockeyLoggerTests.m b/Support/HockeySDKTests/BITHockeyLoggerTests.m index 42ae89ef..70f27c4a 100644 --- a/Support/HockeySDKTests/BITHockeyLoggerTests.m +++ b/Support/HockeySDKTests/BITHockeyLoggerTests.m @@ -29,7 +29,7 @@ - (void)testSetCurrentLogLevel { - (void)testSetLogHandler { XCTestExpectation *expectation = [self expectationWithDescription:@"Expected logHandler to be called"]; - BITLogHandler testLogHandler = ^(BITLogMessageProvider messageProvider, BITLogLevel logLevel, const char *file, const char *function, uint line) { + BITLogHandler testLogHandler = ^(BITLogMessageProvider __unused messageProvider, BITLogLevel __unused logLevel, const char __unused *file, const char __unused *function, uint __unused line) { [expectation fulfill]; }; From b99aee420f70e48b392bfb7a103237270c1c0824 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 13:51:01 +0300 Subject: [PATCH 07/19] Different warnings fixed --- Support/HockeySDKTests/BITChannelTests.m | 1 - Support/HockeySDKTests/BITFeedbackManagerTests.m | 5 +++-- Support/HockeySDKTests/BITHockeyHelperTests.m | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Support/HockeySDKTests/BITChannelTests.m b/Support/HockeySDKTests/BITChannelTests.m index 35c278ae..fdfa5f02 100644 --- a/Support/HockeySDKTests/BITChannelTests.m +++ b/Support/HockeySDKTests/BITChannelTests.m @@ -19,7 +19,6 @@ @interface BITChannelTests : XCTestCase @end - @implementation BITChannelTests - (void)setUp { diff --git a/Support/HockeySDKTests/BITFeedbackManagerTests.m b/Support/HockeySDKTests/BITFeedbackManagerTests.m index 5e5ffafa..18cfc545 100644 --- a/Support/HockeySDKTests/BITFeedbackManagerTests.m +++ b/Support/HockeySDKTests/BITFeedbackManagerTests.m @@ -347,10 +347,11 @@ - (void)testFeedbackComposeViewController { BITFeedbackComposeViewController *composeViewController = [self.sut feedbackComposeViewController]; NSArray *attachments = [composeViewController performSelector:@selector(attachments)]; - XCTAssertEqual(attachments.count, 2); + XCTAssertEqual(attachments.count, (NSUInteger)2); XCTAssertTrue(composeViewController.hideImageAttachmentButton); - XCTAssertEqual(composeViewController.delegate, mockDelegate); + id stronDelegate = composeViewController.delegate; + XCTAssertEqual(stronDelegate, mockDelegate); } @end diff --git a/Support/HockeySDKTests/BITHockeyHelperTests.m b/Support/HockeySDKTests/BITHockeyHelperTests.m index 3eba0594..778355ef 100644 --- a/Support/HockeySDKTests/BITHockeyHelperTests.m +++ b/Support/HockeySDKTests/BITHockeyHelperTests.m @@ -110,7 +110,7 @@ - (void)testValidAppIconFilename { // Regular icon names NSString *validIconPath = @"AppIcon"; NSString *validIconPath2x = @"AppIcon@2x"; - NSString *expected = ([UIScreen mainScreen].scale >= 2.0f) ? validIconPath2x : validIconPath; + NSString *expected = ([UIScreen mainScreen].scale >= 2.0) ? validIconPath2x : validIconPath; // No valid icons defined at all From 520bf53fa7c7494cb01af018f69fa0a30b58fc60 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 14:30:16 +0300 Subject: [PATCH 08/19] Added xcconfig file for tests --- Support/HockeySDK.xcodeproj/project.pbxproj | 6 ++++++ Support/HockeySDKTest.xcconfig | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 Support/HockeySDKTest.xcconfig diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 715a498a..82b60dec 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -261,6 +261,7 @@ 6EA5DEA61CC05E7600D44206 /* live_report_xamarin.plcrash in Resources */ = {isa = PBXBuildFile; fileRef = 6EA5DEA41CC05E7600D44206 /* live_report_xamarin.plcrash */; }; 6EA5DEAE1CC0670000D44206 /* log_report_xamarin in Resources */ = {isa = PBXBuildFile; fileRef = 6EA5DEAD1CC0670000D44206 /* log_report_xamarin */; }; 6EA5DEAF1CC0670000D44206 /* log_report_xamarin in Resources */ = {isa = PBXBuildFile; fileRef = 6EA5DEAD1CC0670000D44206 /* log_report_xamarin */; }; + 8007E2A51F29FCAB001649AE /* HockeySDKTest.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 8007E2A41F29FCAB001649AE /* HockeySDKTest.xcconfig */; }; 802C45B31BD9629B000D043C /* HockeySDKNullability.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E3A260E1B2B207900D59683 /* HockeySDKNullability.h */; settings = {ATTRIBUTES = (Public, ); }; }; 802C45B41BD9629C000D043C /* HockeySDKNullability.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E3A260E1B2B207900D59683 /* HockeySDKNullability.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8034E6271BA31AD600D83A30 /* BITTelemetryContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 8034E61E1BA31AD500D83A30 /* BITTelemetryContext.h */; }; @@ -634,6 +635,7 @@ 628B7B9B7E7741C3D85B1159 /* BITHockeyLoggerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITHockeyLoggerTests.m; sourceTree = ""; }; 6EA5DEA41CC05E7600D44206 /* live_report_xamarin.plcrash */ = {isa = PBXFileReference; lastKnownFileType = file; path = live_report_xamarin.plcrash; sourceTree = ""; }; 6EA5DEAD1CC0670000D44206 /* log_report_xamarin */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = log_report_xamarin; sourceTree = ""; }; + 8007E2A41F29FCAB001649AE /* HockeySDKTest.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = HockeySDKTest.xcconfig; sourceTree = ""; }; 8034E61E1BA31AD500D83A30 /* BITTelemetryContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITTelemetryContext.h; sourceTree = ""; }; 8034E61F1BA31AD500D83A30 /* BITTelemetryContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITTelemetryContext.m; sourceTree = ""; }; 8034E6201BA31AD500D83A30 /* BITTelemetryData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITTelemetryData.h; sourceTree = ""; }; @@ -932,6 +934,7 @@ 1E85C5A11B35BD7000CE2C0D /* module_crashonly.modulemap */, 1E91D84619B924E600E9616D /* module_default.modulemap */, 1E754DC61621BC170070AB92 /* HockeySDKBase.xcconfig */, + 8007E2A41F29FCAB001649AE /* HockeySDKTest.xcconfig */, B29855421D85EB5D007FF452 /* allfeatures.xcconfig */, 1E7DE39619D44DC6009AB8E5 /* crashonly.xcconfig */, 1E27E60A1B74F01400192AE2 /* crashonlyextensions.xcconfig */, @@ -1737,6 +1740,7 @@ 1E70A23217F2F982001BB32D /* live_report_empty.plcrash in Resources */, 1E494AED19491943001EFF74 /* AppIcon@2x.png in Resources */, 8085BB8A1CBF216E0023FD9B /* Icon.png in Resources */, + 8007E2A51F29FCAB001649AE /* HockeySDKTest.xcconfig in Resources */, 1EA1170916F53E3A001C015C /* StoreBundleIdentifierKnown.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2454,6 +2458,7 @@ }; 1E5A45A016F0DFC200B55C04 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8007E2A41F29FCAB001649AE /* HockeySDKTest.xcconfig */; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -2904,6 +2909,7 @@ }; 1EB617581B0A30480035A986 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8007E2A41F29FCAB001649AE /* HockeySDKTest.xcconfig */; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; diff --git a/Support/HockeySDKTest.xcconfig b/Support/HockeySDKTest.xcconfig new file mode 100644 index 00000000..aeeee6a3 --- /dev/null +++ b/Support/HockeySDKTest.xcconfig @@ -0,0 +1,3 @@ +#include "HockeySDKBase.xcconfig" + +WARNING_CFLAGS = -Wno-partial-availability From b421b3a3ae6b3e5678638627529543870a3c759c Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 14:30:32 +0300 Subject: [PATCH 09/19] Conversion warnings fixed --- Support/HockeySDKTests/BITHockeyHelperTests.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Support/HockeySDKTests/BITHockeyHelperTests.m b/Support/HockeySDKTests/BITHockeyHelperTests.m index 778355ef..5679ef52 100644 --- a/Support/HockeySDKTests/BITHockeyHelperTests.m +++ b/Support/HockeySDKTests/BITHockeyHelperTests.m @@ -76,7 +76,7 @@ - (void)testAppName { - (void)testUUID { NSString *resultString = bit_UUID(); assertThat(resultString, notNilValue()); - assertThatInteger([resultString length], equalToInteger(36)); + assertThatInteger((NSInteger)[resultString length], equalToInteger(36)); } - (void)testAppAnonID { @@ -88,7 +88,7 @@ - (void)testAppAnonID { NSString *resultString = bit_appAnonID(NO); assertThat(resultString, notNilValue()); - assertThatInteger([resultString length], equalToInteger(36)); + assertThatInteger((NSInteger)[resultString length], equalToInteger(36)); } - (void)testValidAppIconFilename { @@ -205,7 +205,7 @@ - (void)testOsVersion { - (void)testOsName { NSString *resultString = bit_osName(); assertThat(resultString, notNilValue()); - assertThatInteger([resultString length], greaterThan(@(0))); + assertThatInteger((NSInteger)[resultString length], greaterThan(@(0))); } - (void)testDeviceType { @@ -218,7 +218,7 @@ - (void)testDeviceType { - (void)testSdkVersion { NSString *resultString = bit_sdkVersion(); assertThat(resultString, notNilValue()); - assertThatInteger([resultString length], greaterThan(@(0))); + assertThatInteger((NSInteger)[resultString length], greaterThan(@(0))); } - (void)testUtcDateString{ From 97cdcc3f3f7c28876dc5d5de53dc96596d84f25c Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 14:53:19 +0300 Subject: [PATCH 10/19] =?UTF-8?q?Fixed=20=E2=80=9Cdeprecated=20implementat?= =?UTF-8?q?ions=E2=80=9D=20and=20=E2=80=9Cdirect=20ivar=20access=E2=80=9D?= =?UTF-8?q?=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/BITFeedbackComposeViewController.m | 4 +++- Classes/BITFeedbackListViewController.m | 3 +++ Classes/BITStoreButton.m | 3 +++ Classes/BITUpdateViewController.m | 8 +++++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Classes/BITFeedbackComposeViewController.m b/Classes/BITFeedbackComposeViewController.m index 385d5a13..95ad816e 100644 --- a/Classes/BITFeedbackComposeViewController.m +++ b/Classes/BITFeedbackComposeViewController.m @@ -441,12 +441,14 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskAll; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation) __unused fromInterfaceOrientation { [self removeAttachmentScrollView]; [self refreshAttachmentScrollview]; } - +#pragma clang diagnostic pop #pragma mark - Private methods diff --git a/Classes/BITFeedbackListViewController.m b/Classes/BITFeedbackListViewController.m index e9b40e8e..07d32021 100644 --- a/Classes/BITFeedbackListViewController.m +++ b/Classes/BITFeedbackListViewController.m @@ -412,6 +412,8 @@ - (void)feedbackComposeViewController:(BITFeedbackComposeViewController *)compos #pragma mark - UIViewController Rotation +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { self.numberOfSectionsBeforeRotation = [self numberOfSectionsInTableView:self.tableView]; self.numberOfMessagesBeforeRotation = [self.manager numberOfMessages]; @@ -425,6 +427,7 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; } +#pragma clang diagnostic pop - (UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskAll; diff --git a/Classes/BITStoreButton.m b/Classes/BITStoreButton.m index 2eff9ff5..834245af 100644 --- a/Classes/BITStoreButton.m +++ b/Classes/BITStoreButton.m @@ -252,7 +252,10 @@ - (void)setButtonData:(BITStoreButtonData *)aButtonData { - (void)setButtonData:(BITStoreButtonData *)aButtonData animated:(BOOL)animated { if (self.buttonData != aButtonData) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" _buttonData = aButtonData; +#pragma clang diagnostic pop } [self updateButtonAnimated:animated]; diff --git a/Classes/BITUpdateViewController.m b/Classes/BITUpdateViewController.m index 36436087..ee9ab55d 100644 --- a/Classes/BITUpdateViewController.m +++ b/Classes/BITUpdateViewController.m @@ -477,11 +477,13 @@ - (UITableViewCell *)tableView:(UITableView *) __unused tableView cellForRowAtIn #pragma mark - Rotation +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) __unused interfaceOrientation duration:(NSTimeInterval) __unused duration { // update all cells [self.cells makeObjectsPerformSelector:@selector(addWebView)]; } - +#pragma clang diagnostic pop #pragma mark - PSAppStoreHeaderDelegate @@ -490,7 +492,11 @@ - (void)setAppStoreButtonState:(AppStoreButtonState)anAppStoreButtonState { } - (void)setAppStoreButtonState:(AppStoreButtonState)anAppStoreButtonState animated:(BOOL)animated { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" _appStoreButtonState = anAppStoreButtonState; +#pragma clang diagnostic pop switch (anAppStoreButtonState) { case AppStoreButtonStateOffline: From c8f3bf8e6d99da798253b6b7bb2c673969ca6e1a Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 15:01:58 +0300 Subject: [PATCH 11/19] =?UTF-8?q?Fixed=20=E2=80=9Ccast=20drops=20const=20q?= =?UTF-8?q?ualifier=E2=80=9D=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/BITBlurImageAnnotation.m | 4 +++- Classes/BITCategoryContainer.m | 6 ++++++ Classes/BITKeychainUtils.m | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Classes/BITBlurImageAnnotation.m b/Classes/BITBlurImageAnnotation.m index 01266eed..6be0df86 100644 --- a/Classes/BITBlurImageAnnotation.m +++ b/Classes/BITBlurImageAnnotation.m @@ -89,8 +89,10 @@ - (void)layoutSubviews { [super layoutSubviews]; [CATransaction begin]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - +#pragma clang diagnostic pop self.imageLayer.frame = self.imageFrame; self.imageLayer.masksToBounds = YES; diff --git a/Classes/BITCategoryContainer.m b/Classes/BITCategoryContainer.m index cecf21f5..81f23e97 100644 --- a/Classes/BITCategoryContainer.m +++ b/Classes/BITCategoryContainer.m @@ -63,7 +63,10 @@ - (NSData *)bit_gzippedDataWithCompressionLevel:(float)level stream.zfree = Z_NULL; stream.opaque = Z_NULL; stream.avail_in = (uint)[self length]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" stream.next_in = (Bytef *)[self bytes]; +#pragma clang diagnostic pop stream.total_out = 0; stream.avail_out = 0; @@ -102,7 +105,10 @@ - (NSData *)bit_gunzippedData stream.zalloc = Z_NULL; stream.zfree = Z_NULL; stream.avail_in = (uint)[self length]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" stream.next_in = (Bytef *)[self bytes]; +#pragma clang diagnostic pop stream.total_out = 0; stream.avail_out = 0; diff --git a/Classes/BITKeychainUtils.m b/Classes/BITKeychainUtils.m index 6c3e6eb4..9ec9eddb 100644 --- a/Classes/BITKeychainUtils.m +++ b/Classes/BITKeychainUtils.m @@ -58,7 +58,10 @@ + (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NS // version of this code (which set the password as a generic attribute instead of password data). NSMutableDictionary *attributeQuery = [query mutableCopy]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" [attributeQuery setObject: (id) kCFBooleanTrue forKey:(__bridge_transfer id) kSecReturnAttributes]; +#pragma clang diagnostic pop CFTypeRef attrResult = NULL; OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef) attributeQuery, &attrResult); // NSDictionary *attributeResult = (__bridge_transfer NSDictionary *)attrResult; @@ -78,7 +81,10 @@ + (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NS // We have an existing item, now query for the password data associated with it. NSMutableDictionary *passwordQuery = [query mutableCopy]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" [passwordQuery setObject: (id) kCFBooleanTrue forKey: (__bridge_transfer id) kSecReturnData]; +#pragma clang diagnostic pop CFTypeRef resData = NULL; status = SecItemCopyMatching((__bridge CFDictionaryRef) passwordQuery, (CFTypeRef *) &resData); NSData *resultData = (__bridge_transfer NSData *)resData; From f0fbda09a06b05bbcd5af271d04e8aa2af9e8e79 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 27 Jul 2017 15:02:48 +0300 Subject: [PATCH 12/19] Fixed activityViewController property synthesize warning in BITFeedbackActivity --- Classes/BITFeedbackActivity.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Classes/BITFeedbackActivity.m b/Classes/BITFeedbackActivity.m index 73e7bcd1..08e17750 100644 --- a/Classes/BITFeedbackActivity.m +++ b/Classes/BITFeedbackActivity.m @@ -51,6 +51,8 @@ @interface BITFeedbackActivity() @implementation BITFeedbackActivity +@synthesize activityViewController = _activityViewController; + #pragma mark - NSObject - (instancetype)init { @@ -123,7 +125,7 @@ - (void)prepareWithActivityItems:(NSArray *)activityItems { } - (UIViewController *)activityViewController { - if (!self.activityViewController) { + if (!_activityViewController) { // TODO: return compose controller with activity content added BITFeedbackManager *manager = [BITHockeyManager sharedHockeyManager].feedbackManager; @@ -131,11 +133,11 @@ - (UIViewController *)activityViewController { composeViewController.delegate = self; [composeViewController prepareWithItems:self.items]; - self.activityViewController = [manager customNavigationControllerWithRootViewController:composeViewController + _activityViewController = [manager customNavigationControllerWithRootViewController:composeViewController presentationStyle:UIModalPresentationFormSheet]; - self.activityViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; + _activityViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; } - return self.activityViewController; + return _activityViewController; } - (void)feedbackComposeViewController:(BITFeedbackComposeViewController *) __unused composeViewController didFinishWithResult:(BITFeedbackComposeResult)composeResult { From 47da91979825fcf6c38d1649bf903372f9ed7c7d Mon Sep 17 00:00:00 2001 From: "Benjamin Scholtysik (Reimold)" Date: Mon, 31 Jul 2017 09:43:03 -0700 Subject: [PATCH 13/19] Remove MACOSX deployment target from project. --- Support/HockeySDK.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 47433dcf..15f1ecba 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -2113,8 +2113,6 @@ GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; From 346258be9f7c788c24b27608b6ccc87e9d602ee0 Mon Sep 17 00:00:00 2001 From: "Benjamin Scholtysik (Reimold)" Date: Mon, 31 Jul 2017 14:18:04 -0700 Subject: [PATCH 14/19] One more cleanup in the project file --- Support/HockeySDK.xcodeproj/project.pbxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 15f1ecba..52e4b113 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -2112,7 +2112,6 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "../Resources/HockeySDK-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = NO; From b653019143efe362a5b1349529826d948247fb41 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Tue, 1 Aug 2017 15:31:34 +0300 Subject: [PATCH 15/19] Calling getResourceValue asynchronously --- Classes/BITHockeyHelper.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Classes/BITHockeyHelper.m b/Classes/BITHockeyHelper.m index 796fc801..a40ad67b 100644 --- a/Classes/BITHockeyHelper.m +++ b/Classes/BITHockeyHelper.m @@ -159,13 +159,14 @@ void bit_fixBackupAttributeForURL(NSURL *directoryURL) { } if (directoryURL) { - NSError *getResourceError = nil; - NSNumber *appSupportDirExcludedValue; - - if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) { - NSError *setResourceError = nil; - [directoryURL setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:&setResourceError]; - } + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + NSError *getResourceError = nil; + NSNumber *appSupportDirExcludedValue; + if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) { + NSError *setResourceError = nil; + [directoryURL setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:&setResourceError]; + } + }); } } From 91f0258a062ad7519c7b5d95e88ce39e6db2d7a4 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Tue, 1 Aug 2017 16:32:47 +0300 Subject: [PATCH 16/19] Unit tests updated for handling getResourceValue async call --- Support/HockeySDKTests/BITHockeyHelperTests.m | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Support/HockeySDKTests/BITHockeyHelperTests.m b/Support/HockeySDKTests/BITHockeyHelperTests.m index 5679ef52..74437731 100644 --- a/Support/HockeySDKTests/BITHockeyHelperTests.m +++ b/Support/HockeySDKTests/BITHockeyHelperTests.m @@ -307,15 +307,23 @@ - (NSURL *)createBackupExcludedTestDirectoryForURL{ } - (BOOL)excludeAttributeIsSetForURL:(NSURL *)directoryURL { - - NSError *getResourceError = nil; - NSNumber *appSupportDirExcludedValue; - if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) { - if ([appSupportDirExcludedValue isEqualToValue:@YES]) { - return YES; + __block BOOL result = NO; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + NSError *getResourceError = nil; + NSNumber *appSupportDirExcludedValue; + if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) { + if ([appSupportDirExcludedValue isEqualToValue:@YES]) { + result = YES; + } } + dispatch_semaphore_signal(semaphore); + }); + while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW)){ + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode + beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]]; } - return NO; + return result; } @end From 14b3e1c1b47f5d3ae8d715c5fcba65175d2bbd11 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Wed, 2 Aug 2017 09:59:11 +0300 Subject: [PATCH 17/19] Error logging added --- Classes/BITHockeyHelper.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Classes/BITHockeyHelper.m b/Classes/BITHockeyHelper.m index a40ad67b..03e9499b 100644 --- a/Classes/BITHockeyHelper.m +++ b/Classes/BITHockeyHelper.m @@ -165,6 +165,8 @@ void bit_fixBackupAttributeForURL(NSURL *directoryURL) { if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) { NSError *setResourceError = nil; [directoryURL setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:&setResourceError]; + } else { + BITHockeyLogError(@"ERROR: Error while retrieving resource value: %@", getResourceError.localizedDescription); } }); } From 4d8251bc70e910ae02c2463735b6a4eb823e8ca2 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Wed, 2 Aug 2017 10:09:46 +0300 Subject: [PATCH 18/19] Log setResourceValueError --- Classes/BITHockeyHelper.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/BITHockeyHelper.m b/Classes/BITHockeyHelper.m index 03e9499b..5383c799 100644 --- a/Classes/BITHockeyHelper.m +++ b/Classes/BITHockeyHelper.m @@ -164,7 +164,9 @@ void bit_fixBackupAttributeForURL(NSURL *directoryURL) { NSNumber *appSupportDirExcludedValue; if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) { NSError *setResourceError = nil; - [directoryURL setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:&setResourceError]; + if(![directoryURL setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:&setResourceError]) { + BITHockeyLogError(@"ERROR: Error while setting resource value: %@", setResourceError.localizedDescription); + } } else { BITHockeyLogError(@"ERROR: Error while retrieving resource value: %@", getResourceError.localizedDescription); } From 31cd9beee55a4ff24683cc2c92e9aa8525bcc236 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Wed, 2 Aug 2017 13:11:24 +0300 Subject: [PATCH 19/19] Semaphore replaced with expectation --- Support/HockeySDKTests/BITHockeyHelperTests.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Support/HockeySDKTests/BITHockeyHelperTests.m b/Support/HockeySDKTests/BITHockeyHelperTests.m index 74437731..9b054074 100644 --- a/Support/HockeySDKTests/BITHockeyHelperTests.m +++ b/Support/HockeySDKTests/BITHockeyHelperTests.m @@ -308,7 +308,7 @@ - (NSURL *)createBackupExcludedTestDirectoryForURL{ - (BOOL)excludeAttributeIsSetForURL:(NSURL *)directoryURL { __block BOOL result = NO; - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + XCTestExpectation *expectation = [self expectationWithDescription:@"wait"]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSError *getResourceError = nil; NSNumber *appSupportDirExcludedValue; @@ -317,12 +317,9 @@ - (BOOL)excludeAttributeIsSetForURL:(NSURL *)directoryURL { result = YES; } } - dispatch_semaphore_signal(semaphore); + [expectation fulfill]; }); - while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW)){ - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode - beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]]; - } + [self waitForExpectationsWithTimeout:5 handler:nil]; return result; }