diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2020-01-08 15:19:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-08 15:19:33 -0500 |
commit | 2ff89724ef0b658114814228229270ae33f09bc4 (patch) | |
tree | 1787b3014ba302e082d9889319bf0ac8ffe4570c | |
parent | 1ea33cb7677eefe999355e02e39c77277cd2cd38 (diff) | |
parent | a1dd7d8548b854e102844b6d94e317c891021e2a (diff) | |
download | sdl_ios-2ff89724ef0b658114814228229270ae33f09bc4.tar.gz |
Merge pull request #1518 from smartdevicelink/bugfix/issue-1517-OCMock-test-failures
Fix issues shown by OCMock 3.5
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m | 8 | ||||
-rw-r--r-- | SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m | 104 |
2 files changed, 83 insertions, 29 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m index 71d74c5bc..1d72c106f 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m @@ -222,8 +222,7 @@ describe(@"choice set manager tests", ^{ beforeEach(^{ pendingPreloadOp = [[SDLPreloadChoicesOperation alloc] init]; - OCMPartialMock(pendingPreloadOp); - OCMStub([pendingPreloadOp removeChoicesFromUpload:[OCMArg any]]); + [testManager.transactionQueue addOperation:pendingPreloadOp]; testManager.pendingMutablePreloadChoices = [NSMutableSet setWithObject:testCell1]; @@ -232,11 +231,6 @@ describe(@"choice set manager tests", ^{ }); it(@"should properly start the deletion", ^{ - OCMStub([pendingPreloadOp removeChoicesFromUpload:[OCMArg checkWithBlock:^BOOL(id obj) { - NSArray<SDLChoiceCell *> *choices = (NSArray<SDLChoiceCell *> *)obj; - return (choices.count == 1) && ([choices.firstObject isEqual:testCell1]); - }]]); - expect(testManager.pendingPreloadChoices).to(beEmpty()); expect(testManager.transactionQueue.operationCount).to(equal(1)); // No delete operation }); diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m index efa067b5c..77a658a86 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m @@ -51,7 +51,7 @@ describe(@"the haptic manager", ^{ __block SDLFocusableItemLocator *hapticManager; __block SDLSendHapticData* sentHapticRequest; - __block id sdlLifecycleManager = OCMClassMock([SDLLifecycleManager class]); + __block id<SDLConnectionManagerType> sdlLifecycleManager = nil; __block SDLStreamingVideoScaleManager *sdlStreamingVideoScaleManager = nil; __block CGRect viewRect1; __block CGRect viewRect2; @@ -61,17 +61,11 @@ describe(@"the haptic manager", ^{ uiViewController = [[UIViewController alloc] init]; uiWindow.rootViewController = uiViewController; + sdlLifecycleManager = OCMProtocolMock(@protocol(SDLConnectionManagerType)); + hapticManager = nil; sentHapticRequest = nil; sdlStreamingVideoScaleManager = [[SDLStreamingVideoScaleManager alloc] initWithScale:1.0 displayViewportResolution:uiViewController.view.frame.size]; - - OCMExpect([[sdlLifecycleManager stub] sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ - BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; - if(isFirstArg) { - sentHapticRequest = value; - } - return YES; - }] withResponseHandler:[OCMArg any]]); }); context(@"when disabled", ^{ @@ -86,7 +80,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have no views", ^{ - OCMVerify(sdlLifecycleManager); + OCMReject([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); expect(sentHapticRequest).to(beNil()); }); @@ -99,7 +99,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have no focusable view", ^{ - OCMVerify(sdlLifecycleManager); + OCMReject([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); expect(sentHapticRequest.hapticRectData.count).to(equal(0)); }); }); @@ -116,7 +122,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have one view", ^{ - OCMVerify(sdlLifecycleManager); + OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); int expectedCount = 1; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); @@ -143,7 +155,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have one view", ^{ - OCMVerify(sdlLifecycleManager); + OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); int expectedCount = 1; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); @@ -176,7 +194,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have two views", ^{ - OCMVerify(sdlLifecycleManager); + OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); int expectedCount = 2; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); @@ -214,7 +238,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have only leaf views added", ^{ - OCMVerify(sdlLifecycleManager); + OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); int expectedCount = 2; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); @@ -252,7 +282,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have only leaf views added", ^{ - OCMVerify(sdlLifecycleManager); + OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); int expectedCount = 2; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); @@ -273,6 +309,14 @@ describe(@"the haptic manager", ^{ context(@"when initialized with two views and then updated with one view removed", ^{ beforeEach(^{ + OCMStub([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); + viewRect1 = CGRectMake(101, 101, 50, 50); UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1]; [uiViewController.view addSubview:textField1]; @@ -291,8 +335,6 @@ describe(@"the haptic manager", ^{ }); it(@"should have one view", ^{ - OCMVerify(sdlLifecycleManager); - int expectedCount = 1; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); @@ -308,6 +350,14 @@ describe(@"the haptic manager", ^{ context(@"when initialized with one view and notified after adding one more view", ^{ beforeEach(^{ + OCMStub([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); + viewRect1 = CGRectMake(101, 101, 50, 50); UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1]; [uiViewController.view addSubview:textField1]; @@ -324,8 +374,6 @@ describe(@"the haptic manager", ^{ }); it(@"should have two views", ^{ - OCMVerify(sdlLifecycleManager); - int expectedCount = 2; expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); @@ -422,7 +470,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have sent one view that has been scaled", ^{ - OCMVerify(sdlLifecycleManager); + OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); int expectedCount = 1; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); @@ -445,7 +499,13 @@ describe(@"the haptic manager", ^{ }); it(@"should have sent one view that has not been scaled", ^{ - OCMVerify(sdlLifecycleManager); + OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){ + BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]]; + if(isFirstArg) { + sentHapticRequest = value; + } + return YES; + }] withResponseHandler:[OCMArg any]]); int expectedCount = 1; expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); |