diff options
author | NicoleYarroch <nicole@livio.io> | 2020-07-20 14:58:48 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2020-07-20 14:58:48 -0400 |
commit | 2e06ec5a528179c255592844fe9b2889a627a465 (patch) | |
tree | 16365cf725eb70111434ab110452e844faf4b1d9 | |
parent | f2599cd17bb95367834e2db7bd6ffed0555aa279 (diff) | |
download | sdl_ios-2e06ec5a528179c255592844fe9b2889a627a465.tar.gz |
Fixed test cases
Signed-off-by: NicoleYarroch <nicole@livio.io>
6 files changed, 67 insertions, 60 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleProtocolHandlerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleProtocolHandlerSpec.m index 458196cc6..dce778e51 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleProtocolHandlerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleProtocolHandlerSpec.m @@ -122,7 +122,7 @@ describe(@"SDLLifecycleProtocolHandler tests", ^{ OCMExpect([mockNotificationDispatcher postNotificationName:[OCMArg isEqual:SDLRPCServiceDidConnect] infoObject:[OCMArg isNil]]); OCMExpect([(SDLTimer *)mockTimer cancel]); - [testHandler handleProtocolStartServiceACKMessage:message]; + [testHandler handleProtocolStartServiceACKMessage:message protocol:mockProtocol]; }); it(@"should stop the timer and send a notification", ^{ @@ -141,7 +141,7 @@ describe(@"SDLLifecycleProtocolHandler tests", ^{ OCMExpect([mockNotificationDispatcher postNotificationName:[OCMArg isEqual:SDLRPCServiceConnectionDidError] infoObject:[OCMArg isNil]]); OCMExpect([(SDLTimer *)mockTimer cancel]); - [testHandler handleProtocolStartServiceNAKMessage:message]; + [testHandler handleProtocolStartServiceNAKMessage:message protocol:mockProtocol]; }); it(@"should stop the timer and send a notification", ^{ @@ -160,7 +160,7 @@ describe(@"SDLLifecycleProtocolHandler tests", ^{ OCMExpect([mockNotificationDispatcher postNotificationName:[OCMArg isEqual:SDLRPCServiceDidDisconnect] infoObject:[OCMArg isNil]]); OCMExpect([(SDLTimer *)mockTimer cancel]); - [testHandler handleProtocolEndServiceACKMessage:message]; + [testHandler handleProtocolEndServiceACKMessage:message protocol:mockProtocol]; }); it(@"should stop the timer and send a notification", ^{ @@ -189,7 +189,7 @@ describe(@"SDLLifecycleProtocolHandler tests", ^{ OCMExpect([mockNotificationDispatcher postRPCRequestNotification:[OCMArg isEqual:SDLDidReceiveShowRequest] request:[OCMArg isNotNil]]); - [testHandler onProtocolMessageReceived:testMessage]; + [testHandler onProtocolMessageReceived:testMessage protocol:mockProtocol]; }); it(@"should send the notification", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m index 96ea3897d..e37abed75 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m @@ -311,7 +311,7 @@ describe(@"the streaming audio manager", ^{ testAudioStartServicePayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithMTU:testMTU]; testAudioMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testAudioHeader andPayload:testAudioStartServicePayload.data]; - [streamingLifecycleManager handleProtocolStartServiceACKMessage:testAudioMessage]; + [streamingLifecycleManager handleProtocolStartServiceACKMessage:testAudioMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -335,7 +335,7 @@ describe(@"the streaming audio manager", ^{ testAudioHeader.serviceType = SDLServiceTypeAudio; testAudioMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testAudioHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceACKMessage:testAudioMessage]; + [streamingLifecycleManager handleProtocolEndServiceACKMessage:testAudioMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -357,7 +357,7 @@ describe(@"the streaming audio manager", ^{ testAudioHeader.serviceType = SDLServiceTypeAudio; testAudioMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testAudioHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceACKMessage:testAudioMessage]; + [streamingLifecycleManager handleProtocolEndServiceACKMessage:testAudioMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -379,7 +379,7 @@ describe(@"the streaming audio manager", ^{ testAudioHeader.serviceType = SDLServiceTypeAudio; testAudioMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testAudioHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testAudioMessage]; + [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testAudioMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -464,7 +464,7 @@ describe(@"the streaming audio manager", ^{ testAudioHeader.serviceType = SDLServiceTypeAudio; testAudioMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testAudioHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceACKMessage:testAudioMessage]; + [streamingLifecycleManager handleProtocolEndServiceACKMessage:testAudioMessage protocol:protocolMock]; }); it(@"should transistion to the stopped state", ^{ @@ -484,7 +484,7 @@ describe(@"the streaming audio manager", ^{ testAudioHeader.serviceType = SDLServiceTypeAudio; testAudioMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testAudioHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testAudioMessage]; + [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testAudioMessage protocol:protocolMock]; }); it(@"should transistion to the stopped state", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m index 6e9fc2136..08c8d82c5 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m @@ -552,7 +552,7 @@ describe(@"the streaming video manager", ^{ beforeEach(^{ testVideoStartServicePayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:testVideoHeight width:testVideoWidth protocol:testVideoProtocol codec:testVideoCodec]; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartServicePayload.data]; - [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -568,7 +568,7 @@ describe(@"the streaming video manager", ^{ beforeEach(^{ testVideoStartServicePayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:testVideoHeight width:testVideoWidth protocol:nil codec:nil]; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartServicePayload.data]; - [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should fall back correctly", ^{ @@ -589,7 +589,7 @@ describe(@"the streaming video manager", ^{ context(@"If no preferred resolutions were set in the data source", ^{ beforeEach(^{ streamingLifecycleManager.dataSource = nil; - [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should not replace the existing screen resolution", ^{ expect(@(CGSizeEqualToSize(streamingLifecycleManager.videoScaleManager.displayViewportResolution, CGSizeZero))).to(beTrue()); @@ -606,7 +606,7 @@ describe(@"the streaming video manager", ^{ streamingLifecycleManager.dataSource = testDataSource; streamingLifecycleManager.preferredResolutions = @[preferredResolutionLow, preferredResolutionHigh]; - [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should set the screen size using the first provided preferred resolution", ^{ CGSize preferredFormat = CGSizeMake(preferredResolutionLow.resolutionWidth.floatValue, preferredResolutionLow.resolutionHeight.floatValue); @@ -648,7 +648,7 @@ describe(@"the streaming video manager", ^{ testVideoStartNakPayload = [[SDLControlFramePayloadNak alloc] initWithRejectedParams:@[[NSString stringWithUTF8String:SDLControlFrameHeightKey], [NSString stringWithUTF8String:SDLControlFrameVideoCodecKey]]]; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartNakPayload.data]; - [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should have retried with new properties", ^{ @@ -670,7 +670,7 @@ describe(@"the streaming video manager", ^{ testVideoStartNakPayload = [[SDLControlFramePayloadNak alloc] initWithRejectedParams:@[[NSString stringWithUTF8String:SDLControlFrameVideoCodecKey]]]; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartNakPayload.data]; - [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should have retried with new properties", ^{ @@ -691,7 +691,7 @@ describe(@"the streaming video manager", ^{ testVideoStartNakPayload = [[SDLControlFramePayloadNak alloc] initWithRejectedParams:@[[NSString stringWithUTF8String:SDLControlFrameVideoCodecKey]]]; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartNakPayload.data]; - [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should end the service", ^{ @@ -706,7 +706,7 @@ describe(@"the streaming video manager", ^{ testVideoStartNakPayload = [[SDLControlFramePayloadNak alloc] initWithRejectedParams:nil]; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartNakPayload.data]; - [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolStartServiceNAKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should end the service", ^{ @@ -729,7 +729,7 @@ describe(@"the streaming video manager", ^{ testVideoHeader.serviceType = SDLServiceTypeVideo; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceACKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolEndServiceACKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -751,7 +751,7 @@ describe(@"the streaming video manager", ^{ testVideoHeader.serviceType = SDLServiceTypeVideo; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -837,7 +837,7 @@ describe(@"the streaming video manager", ^{ testVideoHeader.serviceType = SDLServiceTypeVideo; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceACKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolEndServiceACKMessage:testVideoMessage protocol:protocolMock]; }); it(@"should transistion to the stopped state", ^{ @@ -857,7 +857,7 @@ describe(@"the streaming video manager", ^{ testVideoHeader.serviceType = SDLServiceTypeVideo; testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:nil]; - [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testVideoMessage]; + [streamingLifecycleManager handleProtocolEndServiceNAKMessage:testVideoMessage protocol:protocolMock ]; }); it(@"should transistion to the stopped state", ^{ diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m index e6437a3b7..cd95ff9bb 100644 --- a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m +++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m @@ -129,7 +129,7 @@ describe(@"Send EndSession Tests", ^ { SDLV1ProtocolHeader *testHeader = [[SDLV1ProtocolHeader alloc] init]; testHeader.serviceType = SDLServiceTypeRPC; testHeader.sessionID = 0x03; - [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil]]; + [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil] protocol:testProtocol]; [testProtocol endServiceWithType:SDLServiceTypeRPC]; @@ -157,7 +157,7 @@ describe(@"Send EndSession Tests", ^ { SDLV2ProtocolHeader *testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:2]; testHeader.serviceType = SDLServiceTypeRPC; testHeader.sessionID = 0x61; - [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil]]; + [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil] protocol:testProtocol]; [testProtocol endServiceWithType:SDLServiceTypeRPC]; @@ -188,7 +188,7 @@ describe(@"Send Register Secondary Transport Tests", ^ { refHeader.serviceType = SDLServiceTypeRPC; refHeader.frameData = SDLFrameInfoStartServiceACK; refHeader.sessionID = 0x11; - [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:refHeader andPayload:nil]]; + [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:refHeader andPayload:nil] protocol:testProtocol]; // store the header to apply Session ID value to Register Secondary Transport frame [testProtocol storeHeader:refHeader forServiceType:SDLServiceTypeControl]; @@ -233,7 +233,7 @@ describe(@"SendRPCRequest Tests", ^ { SDLV1ProtocolHeader *testHeader = [[SDLV1ProtocolHeader alloc] init]; testHeader.serviceType = SDLServiceTypeRPC; testHeader.sessionID = 0xFF; - [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil]]; + [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil] protocol:testProtocol]; [testProtocol sendRPC:mockRequest]; @@ -279,7 +279,7 @@ describe(@"SendRPCRequest Tests", ^ { SDLV2ProtocolHeader *testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:2]; testHeader.serviceType = SDLServiceTypeRPC; testHeader.sessionID = 0x01; - [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil]]; + [testProtocol handleProtocolStartServiceACKMessage:[SDLProtocolMessage messageWithHeader:testHeader andPayload:nil] protocol:testProtocol]; [testProtocol sendRPC:mockRequest]; @@ -430,10 +430,10 @@ describe(@"HandleProtocolSessionStarted tests", ^ { testHeader.bytesInPayload = (UInt32)testData.length; SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData]; - OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage]); + OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolStartServiceACKMessage:ackMessage]; + [testProtocol handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]; OCMVerifyAllWithDelay(delegateMock, 0.1); @@ -454,10 +454,10 @@ describe(@"HandleProtocolSessionStarted tests", ^ { testHeader.bytesInPayload = (UInt32)testData.length; SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData]; - OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage]); + OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolStartServiceACKMessage:ackMessage]; + [testProtocol handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]; OCMVerifyAllWithDelay(delegateMock, 0.1); @@ -478,10 +478,10 @@ describe(@"HandleProtocolSessionStarted tests", ^ { testHeader.bytesInPayload = (UInt32)testData.length; SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData]; - OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage]); + OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolStartServiceACKMessage:ackMessage]; + [testProtocol handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]; OCMVerifyAllWithDelay(delegateMock, 0.1); @@ -504,10 +504,10 @@ describe(@"HandleProtocolSessionStarted tests", ^ { testHeader.bytesInPayload = (UInt32)testData.length; SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData]; - OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage]); + OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolStartServiceACKMessage:ackMessage]; + [testProtocol handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]; OCMVerifyAllWithDelay(delegateMock, 0.1); @@ -533,10 +533,10 @@ describe(@"HandleProtocolSessionStarted tests", ^ { testHeader.bytesInPayload = (UInt32)testData.length; SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData]; - OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage]); + OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolStartServiceACKMessage:ackMessage]; + [testProtocol handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]; OCMVerifyAllWithDelay(delegateMock, 0.1); @@ -558,10 +558,10 @@ describe(@"HandleProtocolSessionStarted tests", ^ { testHeader.bytesInPayload = (UInt32)testData.length; SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData]; - OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage]); + OCMExpect([delegateMock handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolStartServiceACKMessage:ackMessage]; + [testProtocol handleProtocolStartServiceACKMessage:ackMessage protocol:testProtocol]; // Should keep their default values expect([SDLGlobals sharedGlobals].protocolVersion.stringVersion).to(equal(@"1.0.0")); @@ -593,10 +593,10 @@ describe(@"HandleProtocolRegisterSecondaryTransport Tests", ^{ testHeader.bytesInPayload = 0; SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:nil]; - OCMExpect([delegateMock handleProtocolRegisterSecondaryTransportACKMessage:ackMessage]); + OCMExpect([delegateMock handleProtocolRegisterSecondaryTransportACKMessage:ackMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolRegisterSecondaryTransportACKMessage:ackMessage]; + [testProtocol handleProtocolRegisterSecondaryTransportACKMessage:ackMessage protocol:testProtocol]; OCMVerifyAllWithDelay(delegateMock, 0.1); }); @@ -615,10 +615,10 @@ describe(@"HandleProtocolRegisterSecondaryTransport Tests", ^{ NSData *payloadData = payload.data; SDLProtocolMessage *nakMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:payloadData]; - OCMExpect([delegateMock handleProtocolRegisterSecondaryTransportNAKMessage:nakMessage]); + OCMExpect([delegateMock handleProtocolRegisterSecondaryTransportNAKMessage:nakMessage protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol handleProtocolRegisterSecondaryTransportNAKMessage:nakMessage]; + [testProtocol handleProtocolRegisterSecondaryTransportNAKMessage:nakMessage protocol:testProtocol]; OCMVerifyAllWithDelay(delegateMock, 0.1); }); @@ -660,10 +660,10 @@ describe(@"OnProtocolMessageReceived Tests", ^ { testMessage.header = testHeader; id delegateMock = OCMProtocolMock(@protocol(SDLProtocolDelegate)); - OCMExpect([delegateMock onProtocolMessageReceived:[OCMArg any]]); + OCMExpect([delegateMock onProtocolMessageReceived:[OCMArg any] protocol:testProtocol]); [testProtocol.protocolDelegateTable addObject:delegateMock]; - [testProtocol onProtocolMessageReceived:testMessage]; + [testProtocol onProtocolMessageReceived:testMessage protocol:testProtocol]; }); it(@"Should pass information along to delegate", ^ { diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m index 0d6d44727..47ef47708 100644 --- a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m @@ -9,18 +9,25 @@ #import <Nimble/Nimble.h> #import <OCMock/OCMock.h> +#import "SDLProtocol.h" #import "SDLProtocolReceivedMessageRouter.h" +#import "SDLRPCParameterNames.h" #import "SDLV2ProtocolHeader.h" #import "SDLV2ProtocolMessage.h" -#import "SDLRPCParameterNames.h" QuickSpecBegin(SDLProtocolReceivedMessageRouterSpec) describe(@"HandleReceivedMessage Tests", ^ { + __block SDLProtocol *mockProtocol = nil; + + beforeEach(^{ + mockProtocol = OCMStrictClassMock([SDLProtocol class]); + }); + context(@"When handling control message", ^ { it(@"Should route message correctly", ^ { id delegateMock = OCMProtocolMock(@protocol(SDLProtocolDelegate)); - + SDLV2ProtocolMessage *testMessage = [[SDLV2ProtocolMessage alloc] init]; SDLV2ProtocolHeader *testHeader = [[SDLV2ProtocolHeader alloc] init]; @@ -35,16 +42,16 @@ describe(@"HandleReceivedMessage Tests", ^ { SDLProtocolReceivedMessageRouter* router = [[SDLProtocolReceivedMessageRouter alloc] init]; router.delegate = delegateMock; - [router handleReceivedMessage:testMessage]; + [router handleReceivedMessage:testMessage protocol:mockProtocol]; - OCMVerify([delegateMock handleProtocolStartServiceACKMessage:testMessage]); + OCMVerify([delegateMock handleProtocolStartServiceACKMessage:testMessage protocol:mockProtocol]); }); }); context(@"When handling single frame message", ^ { it(@"Should route message correctly", ^ { id delegateMock = OCMProtocolMock(@protocol(SDLProtocolDelegate)); - + SDLV2ProtocolMessage* testMessage = [[SDLV2ProtocolMessage alloc] init]; SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; @@ -69,12 +76,12 @@ describe(@"HandleReceivedMessage Tests", ^ { SDLV2ProtocolMessage* messageReceived = (SDLV2ProtocolMessage *)message; expect(messageReceived).to(beIdenticalTo(testMessage)); - }] ignoringNonObjectArgs] onProtocolMessageReceived:[OCMArg any]]; + }] ignoringNonObjectArgs] onProtocolMessageReceived:[OCMArg any] protocol:mockProtocol]; SDLProtocolReceivedMessageRouter* router = [[SDLProtocolReceivedMessageRouter alloc] init]; router.delegate = delegateMock; - [router handleReceivedMessage:testMessage]; + [router handleReceivedMessage:testMessage protocol:mockProtocol]; expect(@(verified)).to(beTruthy()); }); @@ -108,7 +115,7 @@ describe(@"HandleReceivedMessage Tests", ^ { SDLProtocolReceivedMessageRouter* router = [[SDLProtocolReceivedMessageRouter alloc] init]; - [router handleReceivedMessage:testMessage]; + [router handleReceivedMessage:testMessage protocol:mockProtocol]; testMessage.header.frameType = SDLFrameTypeConsecutive; testMessage.header.bytesInPayload = 500; @@ -119,7 +126,7 @@ describe(@"HandleReceivedMessage Tests", ^ { //Consectutive frames testMessage.header.frameData = frameNumber; testMessage.payload = [payloadData subdataWithRange:NSMakeRange(offset, 500)]; - [router handleReceivedMessage:testMessage]; + [router handleReceivedMessage:testMessage protocol:mockProtocol]; frameNumber++; offset += 500; @@ -146,10 +153,10 @@ describe(@"HandleReceivedMessage Tests", ^ { expect(@(assembledMessage.header.frameData)).to(equal(@(SDLFrameInfoSingleFrame))); expect(@(assembledMessage.header.sessionID)).to(equal(@0x33)); expect(@(assembledMessage.header.bytesInPayload)).to(equal(@(payloadData.length))); - }] onProtocolMessageReceived:[OCMArg any]]; + }] onProtocolMessageReceived:[OCMArg any] protocol:mockProtocol]; router.delegate = delegateMock; - [router handleReceivedMessage:testMessage]; + [router handleReceivedMessage:testMessage protocol:mockProtocol]; expect(@(verified)).to(beTruthy()); }); diff --git a/SmartDeviceLinkTests/SDLEncryptionLifecycleManagerSpec.m b/SmartDeviceLinkTests/SDLEncryptionLifecycleManagerSpec.m index 6bbc5b3e3..e58d1f108 100644 --- a/SmartDeviceLinkTests/SDLEncryptionLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/SDLEncryptionLifecycleManagerSpec.m @@ -91,7 +91,7 @@ describe(@"the encryption lifecycle manager", ^{ testRPCHeader.serviceType = SDLServiceTypeRPC; testRPCMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testRPCHeader andPayload:nil]; - [encryptionLifecycleManager handleProtocolStartServiceACKMessage:testRPCMessage]; + [encryptionLifecycleManager handleProtocolStartServiceACKMessage:testRPCMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -114,7 +114,7 @@ describe(@"the encryption lifecycle manager", ^{ testRPCHeader.serviceType = SDLServiceTypeRPC; testRPCMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testRPCHeader andPayload:nil]; - [encryptionLifecycleManager handleProtocolEndServiceACKMessage:testRPCMessage]; + [encryptionLifecycleManager handleProtocolEndServiceACKMessage:testRPCMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -136,7 +136,7 @@ describe(@"the encryption lifecycle manager", ^{ testRPCHeader.serviceType = SDLServiceTypeRPC; testRPCMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testRPCHeader andPayload:nil]; - [encryptionLifecycleManager handleProtocolEndServiceACKMessage:testRPCMessage]; + [encryptionLifecycleManager handleProtocolEndServiceACKMessage:testRPCMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ @@ -158,7 +158,7 @@ describe(@"the encryption lifecycle manager", ^{ testRPCHeader.serviceType = SDLServiceTypeRPC; testRPCMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testRPCHeader andPayload:nil]; - [encryptionLifecycleManager handleProtocolEndServiceNAKMessage:testRPCMessage]; + [encryptionLifecycleManager handleProtocolEndServiceNAKMessage:testRPCMessage protocol:protocolMock]; }); it(@"should have set all the right properties", ^{ |