diff --git a/.gitmodules b/.gitmodules index dcfbda21..38597b13 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "src/Vendor/OHHTTPStubs"] path = src/Vendor/OHHTTPStubs url = https://github.com/AliSoftware/OHHTTPStubs.git +[submodule "src/Vendor/OCMock"] + path = src/Vendor/OCMock + url = https://github.com/erikdoe/ocmock.git diff --git a/Samples/Objective-C/nhubsample-refresh/nhubsample-refresh/SetupViewController.m b/Samples/Objective-C/nhubsample-refresh/nhubsample-refresh/SetupViewController.m index 8452f095..45312a82 100644 --- a/Samples/Objective-C/nhubsample-refresh/nhubsample-refresh/SetupViewController.m +++ b/Samples/Objective-C/nhubsample-refresh/nhubsample-refresh/SetupViewController.m @@ -66,7 +66,7 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd } } -- (void)notificationHub:(MSNotificationHub *)notificationHub didReceivePushNotification:(MSNotificationHubMessage *)notification { +- (void)notificationHub:(MSNotificationHub *)notificationHub didReceivePushNotification:(MSNotificationHubMessage *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { NSLog(@"Received notification: %@: %@", notification.title, notification.body); [self.notificationsTableView addNotification:notification]; @@ -79,7 +79,7 @@ - (void)notificationHub:(MSNotificationHub *)notificationHub didReceivePushNotif dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [alertController dismissViewControllerAnimated:YES completion: nil]; }); - + completionHandler((notification.additionalData != nil && [notification.additionalData count] > 0) ? UIBackgroundFetchResultNewData : UIBackgroundFetchResultNoData); } diff --git a/Samples/Swift/nhubsample-refresh/nhubsample-refresh/SetupViewController.swift b/Samples/Swift/nhubsample-refresh/nhubsample-refresh/SetupViewController.swift index c9cd8d9f..2a1ac098 100644 --- a/Samples/Swift/nhubsample-refresh/nhubsample-refresh/SetupViewController.swift +++ b/Samples/Swift/nhubsample-refresh/nhubsample-refresh/SetupViewController.swift @@ -67,7 +67,7 @@ class SetupViewController: UIViewController, UITextFieldDelegate, UITableViewDat } } - func notificationHub(_ notificationHub: MSNotificationHub!, didReceivePushNotification notification: MSNotificationHubMessage!) { + func notificationHub(_ notificationHub: MSNotificationHub!, didReceivePushNotification notification: MSNotificationHubMessage!, fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { NSLog("Received notification: %@; %@", notification.title ?? "", notification.body) notificationsTableView?.addNotification(notification); @@ -78,6 +78,7 @@ class SetupViewController: UIViewController, UITextFieldDelegate, UITableViewDat DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { alertController.dismiss(animated: true, completion: nil) } + completionHandler((notification.additionalData != nil && notification.additionalData.count > 0) ? .newData : .noData) } } diff --git a/src/Vendor/OCMock b/src/Vendor/OCMock new file mode 160000 index 00000000..10a7545f --- /dev/null +++ b/src/Vendor/OCMock @@ -0,0 +1 @@ +Subproject commit 10a7545fe8f370139b36392bb9b53045a4da0bb1 diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/NSNotificationCenter+OCMAdditions.h b/src/Vendor/OCMock/OCMock.framework/Headers/NSNotificationCenter+OCMAdditions.h deleted file mode 100644 index 164ec2aa..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/NSNotificationCenter+OCMAdditions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2009-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCObserverMockObject; - - -@interface NSNotificationCenter(OCMAdditions) - -- (void)addMockObserver:(OCObserverMockObject *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender; - -@end diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMArg.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMArg.h deleted file mode 100644 index 56280486..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMArg.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2009-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@interface OCMArg : NSObject - -// constraining arguments - -+ (id)any; -+ (SEL)anySelector; -+ (void *)anyPointer; -+ (id __autoreleasing *)anyObjectRef; -+ (id)isNil; -+ (id)isNotNil; -+ (id)isEqual:(id)value; -+ (id)isNotEqual:(id)value; -+ (id)isKindOfClass:(Class)cls; -+ (id)checkWithSelector:(SEL)selector onObject:(id)anObject; -+ (id)checkWithBlock:(BOOL (^)(id obj))block; - -// manipulating arguments - -+ (id *)setTo:(id)value; -+ (void *)setToValue:(NSValue *)value; -+ (id)invokeBlock; -+ (id)invokeBlockWithArgs:(id)first,... NS_REQUIRES_NIL_TERMINATION; - -+ (id)defaultValue; - -// internal use only - -+ (id)resolveSpecialValues:(NSValue *)value; - -@end - -#define OCMOCK_ANY [OCMArg any] - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - #define OCMOCK_VALUE(variable) \ - ({ __typeof__(variable) __v = (variable); [NSValue value:&__v withObjCType:@encode(__typeof__(__v))]; }) -#else - #define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))] -#endif - diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMConstraint.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMConstraint.h deleted file mode 100644 index b0aee230..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMConstraint.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2007-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - - -@interface OCMConstraint : NSObject - -+ (instancetype)constraint; -- (BOOL)evaluate:(id)value; - -// if you are looking for any, isNil, etc, they have moved to OCMArg - -// try to use [OCMArg checkWith...] instead of the constraintWith... methods below - -+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject; -+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue; - - -@end - -@interface OCMAnyConstraint : OCMConstraint -@end - -@interface OCMIsNilConstraint : OCMConstraint -@end - -@interface OCMIsNotNilConstraint : OCMConstraint -@end - -@interface OCMIsNotEqualConstraint : OCMConstraint -{ - @public - id testValue; -} - -@end - -@interface OCMInvocationConstraint : OCMConstraint -{ - @public - NSInvocation *invocation; -} - -@end - -@interface OCMBlockConstraint : OCMConstraint -{ - BOOL (^block)(id); -} - -- (instancetype)initWithConstraintBlock:(BOOL (^)(id))block; - -@end - -#ifndef OCM_DISABLE_SHORT_SYNTAX -#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self] -#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)] -#endif diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMFunctions.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMFunctions.h deleted file mode 100644 index 16ce0423..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMFunctions.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2014-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - - -#if defined(__cplusplus) -#define OCMOCK_EXTERN extern "C" -#else -#define OCMOCK_EXTERN extern -#endif - - -OCMOCK_EXTERN BOOL OCMIsObjectType(const char *objCType); diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMLocation.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMLocation.h deleted file mode 100644 index 318aff24..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMLocation.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import -#import "OCMFunctions.h" - - -@interface OCMLocation : NSObject -{ - id testCase; - NSString *file; - NSUInteger line; -} - -+ (instancetype)locationWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; - -- (instancetype)initWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; - -- (id)testCase; -- (NSString *)file; -- (NSUInteger)line; - -@end - -OCMOCK_EXTERN OCMLocation *OCMMakeLocation(id testCase, const char *file, int line); diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMMacroState.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMMacroState.h deleted file mode 100644 index 30c8dba8..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMMacroState.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCMLocation; -@class OCMQuantifier; -@class OCMRecorder; -@class OCMStubRecorder; -@class OCMockObject; - - -@interface OCMMacroState : NSObject -{ - id recorder; -} - -+ (void)beginStubMacro; -+ (OCMStubRecorder *)endStubMacro; - -+ (void)beginExpectMacro; -+ (OCMStubRecorder *)endExpectMacro; - -+ (void)beginRejectMacro; -+ (OCMStubRecorder *)endRejectMacro; - -+ (void)beginVerifyMacroAtLocation:(OCMLocation *)aLocation; -+ (void)beginVerifyMacroAtLocation:(OCMLocation *)aLocation withQuantifier:(OCMQuantifier *)quantifier; -+ (void)endVerifyMacro; - -+ (OCMMacroState *)globalState; - -- (void)setRecorder:(id)aRecorder; -- (id)recorder; - -- (void)switchToClassMethod; - -@end diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMQuantifier.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMQuantifier.h deleted file mode 100644 index d85e8b1f..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMQuantifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@interface OCMQuantifier : NSObject -{ - NSUInteger expectedCount; -} - -+ (instancetype)never; -+ (instancetype)exactly:(NSUInteger)count; -+ (instancetype)atLeast:(NSUInteger)count; -+ (instancetype)atMost:(NSUInteger)count; - -- (BOOL)isValidCount:(NSUInteger)count; - -- (NSString *)description; - -@end - - -#define OCMNever() ([OCMQuantifier never]) -#define OCMTimes(n) ([OCMQuantifier exactly:(n)]) -#define OCMAtLeast(n) ([OCMQuantifier atLeast:(n)]) -#define OCMAtMost(n) ([OCMQuantifier atMost:(n)]) - -#ifndef OCM_DISABLE_SHORT_QSYNTAX -#define never() OCMNever() -#define times(n) OCMTimes(n) -#define atLeast(n) OCMAtLeast(n) -#define atMost(n) OCMAtMost(n) -#endif diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMRecorder.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMRecorder.h deleted file mode 100644 index 97924957..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMRecorder.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCMockObject; -@class OCMInvocationMatcher; - - -@interface OCMRecorder : NSProxy -{ - OCMockObject *mockObject; - OCMInvocationMatcher *invocationMatcher; - BOOL wasUsed; -} - -- (instancetype)init; -- (instancetype)initWithMockObject:(OCMockObject *)aMockObject; - -- (void)setMockObject:(OCMockObject *)aMockObject; - -- (OCMInvocationMatcher *)invocationMatcher; -- (BOOL)wasUsed; - -- (id)classMethod; -- (id)ignoringNonObjectArgs; - -@end - -@interface OCMRecorder (Properties) - -#define ignoringNonObjectArgs() _ignoringNonObjectArgs() -@property (nonatomic, readonly) OCMRecorder *(^ _ignoringNonObjectArgs)(void); - -@end diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMStubRecorder.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMStubRecorder.h deleted file mode 100644 index 16557fe3..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMStubRecorder.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import -#import -#import - -@interface OCMStubRecorder : OCMRecorder - -- (id)andReturn:(id)anObject; -- (id)andReturnValue:(NSValue *)aValue; -- (id)andThrow:(NSException *)anException; -- (id)andPost:(NSNotification *)aNotification; -- (id)andCall:(SEL)selector onObject:(id)anObject; -- (id)andDo:(void (^)(NSInvocation *invocation))block; -- (id)andForwardToRealObject; - -@end - - -@interface OCMStubRecorder (Properties) - -#define andReturn(aValue) _andReturn(({ \ - __typeof__(aValue) _val = (aValue); \ - NSValue *_nsval = [NSValue value:&_val withObjCType:@encode(__typeof__(_val))]; \ - if (OCMIsObjectType(@encode(__typeof(_val)))) { \ - objc_setAssociatedObject(_nsval, "OCMAssociatedBoxedValue", *(__unsafe_unretained id *) (void *) &_val, OBJC_ASSOCIATION_RETAIN); \ - } \ - _nsval; \ -})) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andReturn)(NSValue *); - -#define andThrow(anException) _andThrow(anException) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andThrow)(NSException *); - -#define andPost(aNotification) _andPost(aNotification) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andPost)(NSNotification *); - -#define andCall(anObject, aSelector) _andCall(anObject, aSelector) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andCall)(id, SEL); - -#define andDo(aBlock) _andDo(aBlock) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andDo)(void (^)(NSInvocation *)); - -#define andForwardToRealObject() _andForwardToRealObject() -@property (nonatomic, readonly) OCMStubRecorder *(^ _andForwardToRealObject)(void); - -@property (nonatomic, readonly) OCMStubRecorder *(^ _ignoringNonObjectArgs)(void); - -@end - - - diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMVerifier.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMVerifier.h deleted file mode 100644 index 164904fe..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMVerifier.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import "OCMRecorder.h" -#import "OCMLocation.h" -#import "OCMQuantifier.h" - - -@interface OCMVerifier : OCMRecorder - -@property(retain) OCMLocation *location; -@property(retain) OCMQuantifier *quantifier; - -- (instancetype)withQuantifier:(OCMQuantifier *)quantifier; - -@end diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMock.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMock.h deleted file mode 100644 index 09e1a38e..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMock.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2004-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import - - -#ifdef OCM_DISABLE_SHORT_SYNTAX -#define OCM_DISABLE_SHORT_QSYNTAX -#endif - - -#define OCMClassMock(cls) [OCMockObject niceMockForClass:cls] - -#define OCMStrictClassMock(cls) [OCMockObject mockForClass:cls] - -#define OCMProtocolMock(protocol) [OCMockObject niceMockForProtocol:protocol] - -#define OCMStrictProtocolMock(protocol) [OCMockObject mockForProtocol:protocol] - -#define OCMPartialMock(obj) [OCMockObject partialMockForObject:obj] - -#define OCMObserverMock() [OCMockObject observerMock] - - -#define OCMStub(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginStubMacro]; \ - OCMStubRecorder *recorder = nil; \ - @try{ \ - invocation; \ - }@finally{ \ - recorder = [OCMMacroState endStubMacro]; \ - } \ - recorder; \ - ); \ -}) - -#define OCMExpect(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginExpectMacro]; \ - OCMStubRecorder *recorder = nil; \ - @try{ \ - invocation; \ - }@finally{ \ - recorder = [OCMMacroState endExpectMacro]; \ - } \ - recorder; \ - ); \ -}) - -#define OCMReject(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginRejectMacro]; \ - OCMStubRecorder *recorder = nil; \ - @try{ \ - invocation; \ - }@finally{ \ - recorder = [OCMMacroState endRejectMacro]; \ - } \ - recorder; \ - ); \ -}) - - - -#define OCMClassMethod(invocation) \ - _OCMSilenceWarnings( \ - [[OCMMacroState globalState] switchToClassMethod]; \ - invocation; \ - ); - - -#ifndef OCM_DISABLE_SHORT_SYNTAX -#define ClassMethod(invocation) OCMClassMethod(invocation) -#endif - - -#define OCMVerifyAll(mock) [mock verifyAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)] - -#define OCMVerifyAllWithDelay(mock, delay) [mock verifyWithDelay:delay atLocation:OCMMakeLocation(self, __FILE__, __LINE__)] - -#define _OCMVerify(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginVerifyMacroAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)]; \ - @try{ \ - invocation; \ - }@finally{ \ - [OCMMacroState endVerifyMacro]; \ - } \ - ); \ -}) - -#define _OCMVerifyWithQuantifier(quantifier, invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginVerifyMacroAtLocation:OCMMakeLocation(self, __FILE__, __LINE__) withQuantifier:quantifier]; \ - @try{ \ - invocation; \ - }@finally{ \ - [OCMMacroState endVerifyMacro]; \ - } \ - ); \ -}) - -// explanation for macros below here: https://stackoverflow.com/questions/3046889/optional-parameters-with-c-macros - -#define _OCMVerify_1(A) _OCMVerify(A) -#define _OCMVerify_2(A,B) _OCMVerifyWithQuantifier(A, B) -#define _OCMVerify_X(x,A,B,FUNC, ...) FUNC -#define OCMVerify(...) _OCMVerify_X(,##__VA_ARGS__, _OCMVerify_2(__VA_ARGS__), _OCMVerify_1(__VA_ARGS__)) - - -#define _OCMSilenceWarnings(macro) \ -({ \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ - _Pragma("clang diagnostic ignored \"-Wunused-getter-return-value\"") \ - _Pragma("clang diagnostic ignored \"-Wstrict-selector-match\"") \ - macro \ - _Pragma("clang diagnostic pop") \ -}) diff --git a/src/Vendor/OCMock/OCMock.framework/Headers/OCMockObject.h b/src/Vendor/OCMock/OCMock.framework/Headers/OCMockObject.h deleted file mode 100644 index ba685f78..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Headers/OCMockObject.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004-2020 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCMLocation; -@class OCMQuantifier; -@class OCMInvocationStub; -@class OCMStubRecorder; -@class OCMInvocationMatcher; -@class OCMInvocationExpectation; - - -@interface OCMockObject : NSProxy -{ - BOOL isNice; - BOOL expectationOrderMatters; - NSMutableArray *stubs; - NSMutableArray *expectations; - NSMutableArray *exceptions; - NSMutableArray *invocations; -} - -+ (id)mockForClass:(Class)aClass; -+ (id)mockForProtocol:(Protocol *)aProtocol; -+ (id)partialMockForObject:(NSObject *)anObject; - -+ (id)niceMockForClass:(Class)aClass; -+ (id)niceMockForProtocol:(Protocol *)aProtocol; - -+ (id)observerMock; - -- (instancetype)init; - -- (void)setExpectationOrderMatters:(BOOL)flag; - -- (id)stub; -- (id)expect; -- (id)reject; - -- (id)verify; -- (id)verifyAtLocation:(OCMLocation *)location; - -- (void)verifyWithDelay:(NSTimeInterval)delay; -- (void)verifyWithDelay:(NSTimeInterval)delay atLocation:(OCMLocation *)location; - -- (void)stopMocking; - -// internal use only - -- (void)addStub:(OCMInvocationStub *)aStub; -- (void)addExpectation:(OCMInvocationExpectation *)anExpectation; - -- (BOOL)handleInvocation:(NSInvocation *)anInvocation; -- (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation; -- (BOOL)handleSelector:(SEL)sel; - -- (void)verifyInvocation:(OCMInvocationMatcher *)matcher; -- (void)verifyInvocation:(OCMInvocationMatcher *)matcher atLocation:(OCMLocation *)location; -- (void)verifyInvocation:(OCMInvocationMatcher *)matcher withQuantifier:(OCMQuantifier *)quantifier atLocation:(OCMLocation *)location; - -@end - diff --git a/src/Vendor/OCMock/OCMock.framework/Info.plist b/src/Vendor/OCMock/OCMock.framework/Info.plist deleted file mode 100644 index 3cc06065..00000000 Binary files a/src/Vendor/OCMock/OCMock.framework/Info.plist and /dev/null differ diff --git a/src/Vendor/OCMock/OCMock.framework/Modules/module.modulemap b/src/Vendor/OCMock/OCMock.framework/Modules/module.modulemap deleted file mode 100644 index 6e988909..00000000 --- a/src/Vendor/OCMock/OCMock.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module OCMock { - umbrella header "OCMock.h" - - export * - module * { export * } -} diff --git a/src/Vendor/OCMock/OCMock.framework/OCMock b/src/Vendor/OCMock/OCMock.framework/OCMock deleted file mode 100755 index 0e103377..00000000 Binary files a/src/Vendor/OCMock/OCMock.framework/OCMock and /dev/null differ diff --git a/src/Vendor/OCMock/OCMock.framework/_CodeSignature/CodeResources b/src/Vendor/OCMock/OCMock.framework/_CodeSignature/CodeResources deleted file mode 100644 index dc25a9c4..00000000 --- a/src/Vendor/OCMock/OCMock.framework/_CodeSignature/CodeResources +++ /dev/null @@ -1,297 +0,0 @@ - - - - - files - - Headers/NSNotificationCenter+OCMAdditions.h - - +dV/+LFSP/wgYqVhTndAcL7TD24= - - Headers/OCMArg.h - - 8kMOu6mPvZqomUJVkfEhk55dyrk= - - Headers/OCMConstraint.h - - 7r+T1akr6XyPRInJ2wwQz4LxNWU= - - Headers/OCMFunctions.h - - sVA8T8aL72IRJjL+/jEevEoXs3c= - - Headers/OCMLocation.h - - +tfLEIKU+i6IjKVgvF/ak1rnHPA= - - Headers/OCMMacroState.h - - S0Vp8auu2ramcunTQiz1cdXEkuA= - - Headers/OCMQuantifier.h - - k5KiAhQtULHAViAEhsqglY/yeRU= - - Headers/OCMRecorder.h - - FEpNbSiU7KTpN0EaeG6x2yW1o4M= - - Headers/OCMStubRecorder.h - - cIvq3E4OnjdnmeapAi5wANLjQuE= - - Headers/OCMVerifier.h - - 3mhr+fTB5C9dQ2q1QnkNhP6dA6k= - - Headers/OCMock.h - - pUSnqRTSZ1Fp90E907NjatfrcpY= - - Headers/OCMockObject.h - - IvCE70YU0fEv8sPHkZSXNcOfYmo= - - Info.plist - - 1WOtnGepFrQ47cEYJJwyN453B44= - - Modules/module.modulemap - - C/zv4wGd+b+kg7T2q31cWmGbPX0= - - - files2 - - Headers/NSNotificationCenter+OCMAdditions.h - - hash - - +dV/+LFSP/wgYqVhTndAcL7TD24= - - hash2 - - /ImGvHEJTjmLZOj+pE4MIL425zza3McAuUKcBKWxeAU= - - - Headers/OCMArg.h - - hash - - 8kMOu6mPvZqomUJVkfEhk55dyrk= - - hash2 - - aCaZshkVRHoegnS0eWRGi6UH13vQ3T/dhN1Lse847L0= - - - Headers/OCMConstraint.h - - hash - - 7r+T1akr6XyPRInJ2wwQz4LxNWU= - - hash2 - - HZwWZL7ZbLlEpOy3YsITyKzclYEW3SusfqjElkcpfZ0= - - - Headers/OCMFunctions.h - - hash - - sVA8T8aL72IRJjL+/jEevEoXs3c= - - hash2 - - TZ0O+hkS9/Sa7A3gQWccPFyC9VIhlY3BkU0aSTWodUI= - - - Headers/OCMLocation.h - - hash - - +tfLEIKU+i6IjKVgvF/ak1rnHPA= - - hash2 - - bMjiK1Na5YP3TwffI/ii1GuXtgS6IwoEFAY4V8+UCFw= - - - Headers/OCMMacroState.h - - hash - - S0Vp8auu2ramcunTQiz1cdXEkuA= - - hash2 - - RRuzi6sTGDINTC9X+poQ2wi9hxXXDsdeyqfdCyMardw= - - - Headers/OCMQuantifier.h - - hash - - k5KiAhQtULHAViAEhsqglY/yeRU= - - hash2 - - yyoRkfq5MsDrbO78MpYvYEHIaq0pHaWsz79pX9bVDO8= - - - Headers/OCMRecorder.h - - hash - - FEpNbSiU7KTpN0EaeG6x2yW1o4M= - - hash2 - - f1BDy/dETG4wxEqz/XEqMKl0s3cj5rrw7g176cA0wpM= - - - Headers/OCMStubRecorder.h - - hash - - cIvq3E4OnjdnmeapAi5wANLjQuE= - - hash2 - - M4F1oDiGYiQsYhJXiLZCZvsV4JD99CNg8iqtkC4n54o= - - - Headers/OCMVerifier.h - - hash - - 3mhr+fTB5C9dQ2q1QnkNhP6dA6k= - - hash2 - - rp/OJ5MhnjeHfpUOTvzfA7/1tWpBEAC0BS20JZy+T8I= - - - Headers/OCMock.h - - hash - - pUSnqRTSZ1Fp90E907NjatfrcpY= - - hash2 - - NZx/Aybw9MKnlcbm0HchQFbYoiCBZbop21t9qqWDO3o= - - - Headers/OCMockObject.h - - hash - - IvCE70YU0fEv8sPHkZSXNcOfYmo= - - hash2 - - zuGw9uKVIjsZuOu8SMuFwbEYjR/Xm7Ixtful/FxqdPU= - - - Modules/module.modulemap - - hash - - C/zv4wGd+b+kg7T2q31cWmGbPX0= - - hash2 - - B5k13RUp+z7jVfSrgRPFafuYH6CF8A6V1qosS2Lm+1k= - - - - rules - - ^.* - - ^.*\.lproj/ - - optional - - weight - 1000 - - ^.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Base\.lproj/ - - weight - 1010 - - ^version.plist$ - - - rules2 - - .*\.dSYM($|/) - - weight - 11 - - ^(.*/)?\.DS_Store$ - - omit - - weight - 2000 - - ^.* - - ^.*\.lproj/ - - optional - - weight - 1000 - - ^.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Base\.lproj/ - - weight - 1010 - - ^Info\.plist$ - - omit - - weight - 20 - - ^PkgInfo$ - - omit - - weight - 20 - - ^embedded\.provisionprofile$ - - weight - 20 - - ^version\.plist$ - - weight - 20 - - - - diff --git a/src/WindowsAzureMessaging/WindowsAzureMessaging.xcodeproj/project.pbxproj b/src/WindowsAzureMessaging/WindowsAzureMessaging.xcodeproj/project.pbxproj index fdf54396..bc9e215d 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessaging.xcodeproj/project.pbxproj +++ b/src/WindowsAzureMessaging/WindowsAzureMessaging.xcodeproj/project.pbxproj @@ -77,7 +77,6 @@ A358374916AA3B250041E372 /* SBRegistration.m in Sources */ = {isa = PBXBuildFile; fileRef = A358371D16AA39850041E372 /* SBRegistration.m */; }; B300E30E24583A95008A32DA /* WindowsAzureMessaging.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 35B4DBCB22268CB900EAC781 /* WindowsAzureMessaging.framework */; platformFilter = ios; }; B300E31024583BE8008A32DA /* OCHamcrestIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B300E30F24583BE7008A32DA /* OCHamcrestIOS.framework */; platformFilter = ios; }; - B300E31224583BF4008A32DA /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B300E31124583BF4008A32DA /* OCMock.framework */; platformFilter = ios; }; B300E32424584DB7008A32DA /* MSHttpTestUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B300E32324584DB7008A32DA /* MSHttpTestUtil.m */; }; B300E34D2458628C008A32DA /* HTTPStubs.m in Sources */ = {isa = PBXBuildFile; fileRef = B300E33E2458628C008A32DA /* HTTPStubs.m */; }; B300E34E2458628C008A32DA /* NSURLRequest+HTTPBodyTesting.m in Sources */ = {isa = PBXBuildFile; fileRef = B300E33F2458628C008A32DA /* NSURLRequest+HTTPBodyTesting.m */; }; @@ -111,8 +110,10 @@ B34BA7A52458A128002457DC /* WindowsAzureMessaging.h in Headers */ = {isa = PBXBuildFile; fileRef = 906E404016A86A3200817A11 /* WindowsAzureMessaging.h */; settings = {ATTRIBUTES = (Public, ); }; }; B34BA7A62458A131002457DC /* SBStaticHandlerResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 929886EF1857FAB100C1676C /* SBStaticHandlerResponse.h */; }; B34BA7A72458A135002457DC /* SBStaticHandlerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 92988747185931DE00C1676C /* SBStaticHandlerResponse.m */; }; + B372117E246AD832008664BD /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3D111AB246AD033004CDF56 /* OCMock.framework */; platformFilter = ios; }; B3821CC02459AFB500567643 /* MS_Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B3D285512456F09900C78CC8 /* MS_Reachability.m */; }; B3821CC12459AFB800567643 /* MS_Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = B3D285522456F09900C78CC8 /* MS_Reachability.h */; }; + B391A3C3246AE24E004D8AF0 /* MSNotificationHub.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C854703244F9347005F6B49 /* MSNotificationHub.h */; settings = {ATTRIBUTES = (Public, ); }; }; B3D285272456E97F00C78CC8 /* MSHttpClientProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B3D2851E2456E97E00C78CC8 /* MSHttpClientProtocol.h */; }; B3D285282456E97F00C78CC8 /* MSHttpClientProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B3D2851E2456E97E00C78CC8 /* MSHttpClientProtocol.h */; }; B3D285292456E97F00C78CC8 /* MSHttpClient.m in Sources */ = {isa = PBXBuildFile; fileRef = B3D2851F2456E97E00C78CC8 /* MSHttpClient.m */; }; @@ -177,6 +178,55 @@ remoteGlobalIDString = 35B4DBCA22268CB900EAC781; remoteInfo = WindowsAzureMessaging; }; + B3D111A2246AD033004CDF56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 030EF0A814632FD000B04273; + remoteInfo = OCMock; + }; + B3D111A4246AD033004CDF56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 03565A3118F0566E003AE91E; + remoteInfo = OCMockTests; + }; + B3D111A6246AD033004CDF56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 030EF0DC14632FF700B04273; + remoteInfo = OCMockLib; + }; + B3D111A8246AD033004CDF56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D31108AD1828DB8700737925; + remoteInfo = OCMockLibTests; + }; + B3D111AA246AD033004CDF56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = F0B950F11B0080BE00942C38; + remoteInfo = "OCMock iOS"; + }; + B3D111AC246AD033004CDF56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 817EB1621BD765130047E85A; + remoteInfo = "OCMock tvOS"; + }; + B3D111AE246AD033004CDF56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 8DE97CA022B43EE60098C63F; + remoteInfo = "OCMock watchOS"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -238,7 +288,6 @@ A358371C16AA39850041E372 /* SBRegistration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBRegistration.h; path = ../SBRegistration.h; sourceTree = ""; }; A358371D16AA39850041E372 /* SBRegistration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBRegistration.m; path = ../SBRegistration.m; sourceTree = ""; }; B300E30F24583BE7008A32DA /* OCHamcrestIOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OCHamcrestIOS.framework; path = ../../Vendor/OCHamcrest/OCHamcrestIOS.framework; sourceTree = ""; }; - B300E31124583BF4008A32DA /* OCMock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OCMock.framework; path = ../../Vendor/OCMock/OCMock.framework; sourceTree = ""; }; B300E32224584DA6008A32DA /* MSHttpTestUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSHttpTestUtil.h; sourceTree = ""; }; B300E32324584DB7008A32DA /* MSHttpTestUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSHttpTestUtil.m; sourceTree = ""; }; B300E32524585081008A32DA /* MSConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSConstants.h; sourceTree = ""; }; @@ -258,6 +307,7 @@ B300E34C2458628C008A32DA /* HTTPStubs+NSURLSessionConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "HTTPStubs+NSURLSessionConfiguration.m"; sourceTree = ""; }; B34BA78E24589F1C002457DC /* TestHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestHelper.h; sourceTree = ""; }; B34BA78F24589F1C002457DC /* TestHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestHelper.m; sourceTree = ""; }; + B3D11198246AD032004CDF56 /* OCMock.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OCMock.xcodeproj; path = ../../Vendor/OCMock/Source/OCMock.xcodeproj; sourceTree = ""; }; B3D2851E2456E97E00C78CC8 /* MSHttpClientProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSHttpClientProtocol.h; sourceTree = ""; }; B3D2851F2456E97E00C78CC8 /* MSHttpClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSHttpClient.m; sourceTree = ""; }; B3D285202456E97E00C78CC8 /* MSHttpCall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSHttpCall.m; sourceTree = ""; }; @@ -301,8 +351,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + B372117E246AD832008664BD /* OCMock.framework in Frameworks */, B300E30E24583A95008A32DA /* WindowsAzureMessaging.framework in Frameworks */, - B300E31224583BF4008A32DA /* OCMock.framework in Frameworks */, B300E31024583BE8008A32DA /* OCHamcrestIOS.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -469,6 +519,20 @@ path = include; sourceTree = ""; }; + B3D11199246AD032004CDF56 /* Products */ = { + isa = PBXGroup; + children = ( + B3D111A3246AD033004CDF56 /* OCMock.framework */, + B3D111A5246AD033004CDF56 /* OCMockTests.xctest */, + B3D111A7246AD033004CDF56 /* libOCMock.a */, + B3D111A9246AD033004CDF56 /* OCMockLibTests.xctest */, + B3D111AB246AD033004CDF56 /* OCMock.framework */, + B3D111AD246AD033004CDF56 /* OCMock.framework */, + B3D111AF246AD033004CDF56 /* OCMock.framework */, + ); + name = Products; + sourceTree = ""; + }; B3D2851D2456DFED00C78CC8 /* HttpClient */ = { isa = PBXGroup; children = ( @@ -539,8 +603,8 @@ B3D2856924572A4900C78CC8 /* Frameworks */ = { isa = PBXGroup; children = ( + B3D11198246AD032004CDF56 /* OCMock.xcodeproj */, B300E33D2458628C008A32DA /* OHHTTPStubs */, - B300E31124583BF4008A32DA /* OCMock.framework */, B300E30F24583BE7008A32DA /* OCHamcrestIOS.framework */, ); name = Frameworks; @@ -604,6 +668,7 @@ 8471C92B16EABF5600C73674 /* SBLocalStorage.h in Headers */, A358373D16AA3B0D0041E372 /* WindowsAzureMessaging.h in Headers */, A358374016AA3B160041E372 /* SBTokenProvider.h in Headers */, + B391A3C3246AE24E004D8AF0 /* MSNotificationHub.h in Headers */, A358373C16AA3B0B0041E372 /* SBRegistration.h in Headers */, 6489DDF624582A270021CF36 /* MSNotificationHubAppDelegate.h in Headers */, B3D2852D2456E97F00C78CC8 /* MSHttpClientPrivate.h in Headers */, @@ -717,6 +782,12 @@ mainGroup = 906E402D16A86A3200817A11; productRefGroup = 906E403916A86A3200817A11 /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = B3D11199246AD032004CDF56 /* Products */; + ProjectRef = B3D11198246AD032004CDF56 /* OCMock.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 906E406D16A8851E00817A11 /* Framework */, @@ -727,6 +798,58 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + B3D111A3246AD033004CDF56 /* OCMock.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = OCMock.framework; + remoteRef = B3D111A2246AD033004CDF56 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B3D111A5246AD033004CDF56 /* OCMockTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = OCMockTests.xctest; + remoteRef = B3D111A4246AD033004CDF56 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B3D111A7246AD033004CDF56 /* libOCMock.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libOCMock.a; + remoteRef = B3D111A6246AD033004CDF56 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B3D111A9246AD033004CDF56 /* OCMockLibTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = OCMockLibTests.xctest; + remoteRef = B3D111A8246AD033004CDF56 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B3D111AB246AD033004CDF56 /* OCMock.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = OCMock.framework; + remoteRef = B3D111AA246AD033004CDF56 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B3D111AD246AD033004CDF56 /* OCMock.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = OCMock.framework; + remoteRef = B3D111AC246AD033004CDF56 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B3D111AF246AD033004CDF56 /* OCMock.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = OCMock.framework; + remoteRef = B3D111AE246AD033004CDF56 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ 35B4DBC922268CB900EAC781 /* Resources */ = { isa = PBXResourcesBuildPhase; diff --git a/src/WindowsAzureMessaging/WindowsAzureMessaging/Internal/MSNotificationHubAppDelegate.m b/src/WindowsAzureMessaging/WindowsAzureMessaging/Internal/MSNotificationHubAppDelegate.m index dea2336f..efa8555c 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessaging/Internal/MSNotificationHubAppDelegate.m +++ b/src/WindowsAzureMessaging/WindowsAzureMessaging/Internal/MSNotificationHubAppDelegate.m @@ -50,8 +50,6 @@ - (void)custom_setDelegate:(id)delegate { [[MSNotificationHubAppDelegate sharedInstance] swizzleImplForMethod:@selector(application: didFailToRegisterForRemoteNotificationsWithError:) inClass:[delegate class]]; - [[MSNotificationHubAppDelegate sharedInstance] swizzleImplForMethod:@selector(application:didReceiveRemoteNotification:) - inClass:[delegate class]]; [[MSNotificationHubAppDelegate sharedInstance] swizzleImplForMethod:@selector(application: didReceiveRemoteNotification:fetchCompletionHandler:) inClass:[delegate class]]; @@ -105,19 +103,10 @@ - (void)custom_application:(UIApplication *)application didFailToRegisterForRemo [MSNotificationHub didFailToRegisterForRemoteNotificationsWithError:error]; } -- (void)custom_application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { - [MSNotificationHub didReceiveRemoteNotification:userInfo]; -} - - (void)custom_application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { - BOOL result = [MSNotificationHub didReceiveRemoteNotification:userInfo]; - if (result) { - completionHandler(UIBackgroundFetchResultNewData); - } else { - completionHandler(UIBackgroundFetchResultNoData); - } + [MSNotificationHub didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } @end diff --git a/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.h b/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.h index 0c68e7de..c403e606 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.h +++ b/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.h @@ -5,6 +5,7 @@ #import "MSNotificationHubDelegate.h" #import "MSNotificationHubMessage.h" #import +#import NS_ASSUME_NONNULL_BEGIN @@ -32,11 +33,11 @@ NS_ASSUME_NONNULL_BEGIN + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; + (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; -+ (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo; ++ (void)didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; - (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; -- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo; +- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; + (void)setDelegate:(nullable id)delegate; diff --git a/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.m b/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.m index 9b60154e..b31b43cf 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.m +++ b/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHub.m @@ -84,14 +84,10 @@ - (void)registerForRemoteNotifications { [[UIApplication sharedApplication] registerForRemoteNotifications]; } -- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo { +- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo + fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { MSNotificationHubMessage *message = [MSNotificationHubMessage createFromNotification:userInfo]; - [self didReceivePushNotification:message]; - - if (message.additionalData) { - return YES; - } - return NO; + [self didReceivePushNotification:message fetchCompletionHandler:completionHandler]; } #pragma mark Instance Callbacks @@ -114,11 +110,12 @@ - (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { NSLog(@"Registering for push notifications has been finished with error: %@", error.localizedDescription); } -- (void)didReceivePushNotification:(MSNotificationHubMessage *)notification { +- (void)didReceivePushNotification:(MSNotificationHubMessage *)notification + fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { dispatch_async(dispatch_get_main_queue(), ^{ id delegate = self.delegate; - if ([delegate respondsToSelector:@selector(notificationHub:didReceivePushNotification:)]) { - [delegate notificationHub:self didReceivePushNotification:notification]; + if ([delegate respondsToSelector:@selector(notificationHub:didReceivePushNotification:fetchCompletionHandler:)]) { + [delegate notificationHub:self didReceivePushNotification:notification fetchCompletionHandler:completionHandler]; } }); } @@ -126,25 +123,26 @@ - (void)didReceivePushNotification:(MSNotificationHubMessage *)notification { #pragma mark Register Callbacks + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - [sharedInstance didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; + [[MSNotificationHub sharedInstance] didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } + (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { - [sharedInstance didFailToRegisterForRemoteNotificationsWithError:error]; + [[MSNotificationHub sharedInstance] didFailToRegisterForRemoteNotificationsWithError:error]; } -+ (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo { - return [sharedInstance didReceiveRemoteNotification:userInfo]; ++ (void)didReceiveRemoteNotification:(NSDictionary *)userInfo + fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { + return [[MSNotificationHub sharedInstance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } #pragma mark SDK Basics + (void)setEnabled:(BOOL)isEnabled { - [sharedInstance setEnabled:isEnabled]; + [[MSNotificationHub sharedInstance] setEnabled:isEnabled]; } + (BOOL)isEnabled { - return [sharedInstance isEnabled]; + return [[MSNotificationHub sharedInstance] isEnabled]; } - (void)setEnabled:(BOOL)isEnabled { @@ -163,17 +161,17 @@ - (BOOL)isEnabled { } + (void)setDelegate:(nullable id)delegate { - [sharedInstance setDelegate:delegate]; + [[MSNotificationHub sharedInstance] setDelegate:delegate]; } #pragma mark Installations + (NSString *) getPushChannel { - return [sharedInstance getPushChannel]; + return [[MSNotificationHub sharedInstance] getPushChannel]; } + (NSString *) getInstallationId { - return [sharedInstance getInstallationId]; + return [[MSNotificationHub sharedInstance] getInstallationId]; } - (NSString *) getPushChannel { @@ -211,23 +209,23 @@ + (BOOL)addTag:(NSString *)tag { } + (BOOL)addTags:(NSArray *)tags { - return [sharedInstance addTags:tags]; + return [[MSNotificationHub sharedInstance] addTags:tags]; } + (void)clearTags { - [sharedInstance clearTags]; + [[MSNotificationHub sharedInstance] clearTags]; } + (NSArray *)getTags { - return [sharedInstance getTags]; + return [[MSNotificationHub sharedInstance] getTags]; } + (BOOL)removeTag:(NSString *)tag { - return [sharedInstance removeTag:tag]; + return [[MSNotificationHub sharedInstance] removeTag:tag]; } + (BOOL)removeTags:(NSArray *)tags { - return [sharedInstance removeTags:tags]; + return [[MSNotificationHub sharedInstance] removeTags:tags]; } - (BOOL)addTag:(NSString *)tag { diff --git a/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHubDelegate.h b/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHubDelegate.h index 45a21039..b0440693 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHubDelegate.h +++ b/src/WindowsAzureMessaging/WindowsAzureMessaging/MSNotificationHubDelegate.h @@ -3,6 +3,7 @@ //---------------------------------------------------------------- #import +#import @class MSNotificationHub; @class MSNotificationHubMessage; @@ -18,6 +19,6 @@ * @param notificationHub The instance of MSNotificationHub * @param message The push notification details. */ -- (void)notificationHub:(MSNotificationHub *)notificationHub didReceivePushNotification:(MSNotificationHubMessage *)message; +- (void)notificationHub:(MSNotificationHub *)notificationHub didReceivePushNotification:(MSNotificationHubMessage *)message fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; @end diff --git a/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.h b/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.h index 85af4785..60cb5eef 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.h +++ b/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.h @@ -6,7 +6,7 @@ @interface MSInstallation : NSObject -@property(nonatomic, copy) NSString *installationID, *pushChannel, *platform; +@property(nonatomic, copy) NSString *installationID, *pushChannel; @property(nonatomic, copy) NSSet *tags; - (instancetype)initWithDeviceToken:(NSString *)deviceToken; diff --git a/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.m b/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.m index 8f0eaf93..ceae0003 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.m +++ b/src/WindowsAzureMessaging/WindowsAzureMessaging/Models/MSInstallation.m @@ -9,7 +9,6 @@ @implementation MSInstallation - (void)encodeWithCoder:(nonnull NSCoder *)coder { [coder encodeObject:self.installationID forKey:@"installationID"]; [coder encodeObject:self.pushChannel forKey:@"pushChannel"]; - [coder encodeObject:self.platform forKey:@"platform"]; [coder encodeObject:self.tags forKey:@"tags"]; } @@ -17,7 +16,6 @@ - (instancetype)initWithCoder:(NSCoder *)coder { if (self = [super init]) { self.installationID = [coder decodeObjectForKey:@"installationID"] ?: [[NSUUID UUID] UUIDString]; self.pushChannel = [coder decodeObjectForKey:@"pushChannel"]; - self.platform = [coder decodeObjectForKey:@"platform"] ?: @"APNS"; self.tags = [coder decodeObjectForKey:@"tags"]; } @@ -27,7 +25,6 @@ - (instancetype)initWithCoder:(NSCoder *)coder { - (instancetype)init { if (self = [super init]) { self.installationID = [[NSUUID UUID] UUIDString]; - self.platform = @"APNS"; self.tags = [NSSet new]; } @@ -54,7 +51,6 @@ + (MSInstallation *)createFromJsonString:(NSString *)jsonString { NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; installation.installationID = dictionary[@"installationId"]; - installation.platform = dictionary[@"platform"]; installation.pushChannel = dictionary[@"pushChannel"]; installation.tags = dictionary[@"tags"]; @@ -65,7 +61,7 @@ - (NSData *)toJsonData { NSDictionary *dictionary = @{ @"installationId" : self.installationID, - @"platform" : self.platform, + @"platform" : @"apns", @"pushChannel" : self.pushChannel, @"tags" : [self.tags allObjects] ?: [NSArray new] }; @@ -74,13 +70,10 @@ - (NSData *)toJsonData { } - (BOOL)addTags:(NSArray *)tags { - NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[a-zA-Z0-9_@#\\.:\\-]{1,120}$" - options:NSRegularExpressionCaseInsensitive - error:nil]; NSMutableSet *tmpTags = [NSMutableSet setWithSet:self.tags]; for (NSString *tag in tags) { - if ([regex numberOfMatchesInString:tag options:0 range:NSMakeRange(0, tag.length)] > 0) { + if ([MSInstallation isValidTag:tag]) { [tmpTags addObject:tag]; } else { NSLog(@"Invalid tag: %@", tag); @@ -110,11 +103,11 @@ - (void)clearTags { } - (NSUInteger)hash { - return [self.installationID hash] ^ [self.platform hash] ^ [self.pushChannel hash] ^ [self.tags hash]; + return [self.installationID hash] ^ [self.pushChannel hash] ^ [self.tags hash]; } - (BOOL)isEqualToMSInstallation:(MSInstallation *)installation { - return [self.installationID isEqualToString:installation.installationID] && [self.platform isEqualToString:installation.platform] && + return [self.installationID isEqualToString:installation.installationID] && [self.tags isEqualToSet:installation.tags]; } @@ -130,4 +123,12 @@ - (BOOL)isEqual:(id)object { return [self isEqualToMSInstallation:(MSInstallation *)object]; } ++ (BOOL)isValidTag:(NSString *)tag { + NSString *tagPattern = @"^[a-zA-Z0-9_@#\\.:\\-]{1,120}$"; + NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:tagPattern options:NSRegularExpressionCaseInsensitive + error:nil]; + + return [regex numberOfMatchesInString:tag options:0 range:NSMakeRange(0, tag.length)] > 0; +} + @end diff --git a/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSInstallationManagerTests.m b/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSInstallationManagerTests.m index 75e81143..7b8a0d53 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSInstallationManagerTests.m +++ b/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSInstallationManagerTests.m @@ -44,9 +44,9 @@ -(void) testSaveInstallation { NSDictionary * dictionary = @{ @"installationId" : installation.installationID, - @"platform" : installation.platform, + @"platform" : @"apns", @"pushChannel" : installation.pushChannel, - @"tags" : installation.tags ?: @"" + @"tags" : [installation.tags allObjects] ?: [NSArray new] }; NSData *expectedData = [NSJSONSerialization dataWithJSONObject:dictionary diff --git a/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSLocalStorageTests.m b/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSLocalStorageTests.m index eab8c6da..1beba7af 100644 --- a/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSLocalStorageTests.m +++ b/src/WindowsAzureMessaging/WindowsAzureMessagingTests/MSLocalStorageTests.m @@ -33,7 +33,6 @@ -(void) testUpsertAndLoadInstallation { [MSLocalStorage upsertInstallation:installation]; MSInstallation *inst = [MSLocalStorage loadInstallation]; XCTAssertEqualObjects(installation.installationID, inst.installationID); - XCTAssertEqualObjects(installation.platform, inst.platform); XCTAssertEqualObjects(installation.pushChannel, inst.pushChannel); } diff --git a/src/runCIT.command b/src/runCIT.command index c7328391..e2f41ac3 100644 --- a/src/runCIT.command +++ b/src/runCIT.command @@ -7,7 +7,11 @@ testLogPath=$buildFolderPath/CITLog.txt echo "******* Build and run CIT *******" 2>&1 | tee -a "$testLogPath" cd "$ABSPATH/WindowsAzureMessaging" -xcodebuild -scheme WindowsAzureMessagingStatic -destination 'platform=iOS Simulator,name=iPhone 8' test 2>&1 | tee -a "$testLogPath" +xcodebuild \ +-scheme WindowsAzureMessagingStatic \ +-destination 'platform=iOS Simulator,name=iPhone 8' \ +-target WindowsAzureMessagingTests \ +test 2>&1 | tee -a "$testLogPath" grep " TEST SUCCEEDED " "$testLogPath" &> /dev/null if [ "$?" != "0" ]; then