diff options
author | NicoleYarroch <nicole@livio.io> | 2019-03-06 14:49:13 -0500 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-03-06 14:49:13 -0500 |
commit | a1c2dc6240fa0fd12041825847bcae96c196f457 (patch) | |
tree | 0851b0ad8a0fd4d8daf75c000423c3f4a5cd8610 | |
parent | f51f1efc44d80fdfb7fe721fc8325b446550d87a (diff) | |
download | sdl_ios-a1c2dc6240fa0fd12041825847bcae96c196f457.tar.gz |
Modified methods in `SDLConnectionManagerType`
* Removed method `sendConnectionRPC:withResponseHandler:`
* Added method `sendConnectionRequest:withResponseHandler:`
* Added method `sendConnectionRPC:`
* Renamed the `SDLAsynchronousRPCOperationSpec` so it matches the class it testing.
-rw-r--r-- | SmartDeviceLink-iOS.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLAsynchronousRPCOperation.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLAsynchronousRPCRequestOperation.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLConnectionManagerType.h | 17 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.m | 17 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPresentChoiceSetOperation.m | 6 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPresentKeyboardOperation.m | 6 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSequentialRPCRequestOperation.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSoftButtonManager.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSystemCapabilityManager.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTextAndGraphicManager.m | 2 | ||||
-rw-r--r-- | SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m (renamed from SmartDeviceLinkTests/SDLRPCResponseOperationSpec.m) | 4 | ||||
-rw-r--r-- | SmartDeviceLinkTests/TestMultipleFilesConnectionManager.m | 4 | ||||
-rw-r--r-- | SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m | 22 | ||||
-rw-r--r-- | SmartDeviceLinkTests/TestUtilities/TestMultipleRequestsConnectionManager.m | 8 |
15 files changed, 65 insertions, 39 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 53562bdbc..e456cdbd4 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -1297,7 +1297,7 @@ 8880D24822205B1B00964F6A /* SDLNavigationInstruction.m in Sources */ = {isa = PBXBuildFile; fileRef = 8880D24622205B1B00964F6A /* SDLNavigationInstruction.m */; }; 8886EB982111F4FA008294A5 /* SDLFileManagerConfigurationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8886EB972111F4FA008294A5 /* SDLFileManagerConfigurationSpec.m */; }; 888F86FE221DEE200052FE4C /* SDLAsynchronousRPCOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 888F86FD221DEE1F0052FE4C /* SDLAsynchronousRPCOperation.m */; }; - 888F8700221DF4880052FE4C /* SDLRPCResponseOperationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 888F86FF221DF4880052FE4C /* SDLRPCResponseOperationSpec.m */; }; + 888F8700221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */; }; 88A1CF1E21669AC7001ACC75 /* SDLLifecycleConfigurationUpdateSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A1CF1D21669AC7001ACC75 /* SDLLifecycleConfigurationUpdateSpec.m */; }; 88A4A0FA22242AB400C6F01D /* SDLNavigationServiceDataSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A4A0F922242AB400C6F01D /* SDLNavigationServiceDataSpec.m */; }; 88A5E7F4220B57F900495E8A /* SDLOnSystemCapabilityUpdatedSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A5E7F3220B57F900495E8A /* SDLOnSystemCapabilityUpdatedSpec.m */; }; @@ -2900,7 +2900,7 @@ 8880D24622205B1B00964F6A /* SDLNavigationInstruction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLNavigationInstruction.m; sourceTree = "<group>"; }; 8886EB972111F4FA008294A5 /* SDLFileManagerConfigurationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLFileManagerConfigurationSpec.m; sourceTree = "<group>"; }; 888F86FD221DEE1F0052FE4C /* SDLAsynchronousRPCOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAsynchronousRPCOperation.m; sourceTree = "<group>"; }; - 888F86FF221DF4880052FE4C /* SDLRPCResponseOperationSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLRPCResponseOperationSpec.m; sourceTree = "<group>"; }; + 888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLAsynchronousRPCOperationSpec.m; sourceTree = "<group>"; }; 88A1CF1D21669AC7001ACC75 /* SDLLifecycleConfigurationUpdateSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLLifecycleConfigurationUpdateSpec.m; sourceTree = "<group>"; }; 88A4A0F922242AB400C6F01D /* SDLNavigationServiceDataSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLNavigationServiceDataSpec.m; sourceTree = "<group>"; }; 88A5E7F3220B57F900495E8A /* SDLOnSystemCapabilityUpdatedSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLOnSystemCapabilityUpdatedSpec.m; sourceTree = "<group>"; }; @@ -3694,10 +3694,10 @@ isa = PBXGroup; children = ( 5D1654551D3E754F00554D93 /* SDLLifecycleManagerSpec.m */, + 888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */, 5D60DF23202B7A80001EDA01 /* SDLAsynchronousRPCRequestOperationSpec.m */, 5D60DF25202B7A97001EDA01 /* SDLSequentialRPCRequestOperationSpec.m */, 88A1CF1D21669AC7001ACC75 /* SDLLifecycleConfigurationUpdateSpec.m */, - 888F86FF221DF4880052FE4C /* SDLRPCResponseOperationSpec.m */, ); name = Lifecycle; sourceTree = "<group>"; @@ -7249,7 +7249,7 @@ 5D6EB4CC1BF28DC600693731 /* NSMapTable+SubscriptingSpec.m in Sources */, 162E83051A9BDE8B00906325 /* SDLVehicleDataActiveStatusSpec.m in Sources */, 162E82E61A9BDE8B00906325 /* SDLInteractionModeSpec.m in Sources */, - 888F8700221DF4880052FE4C /* SDLRPCResponseOperationSpec.m in Sources */, + 888F8700221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m in Sources */, 162E83931A9BDE8B00906325 /* SDLTouchEventSpec.m in Sources */, 5DCF76FE1ACDDB5A00BB647B /* SDLSendLocationResponseSpec.m in Sources */, 162E837D1A9BDE8B00906325 /* SDLEmergencyEventSpec.m in Sources */, diff --git a/SmartDeviceLink/SDLAsynchronousRPCOperation.m b/SmartDeviceLink/SDLAsynchronousRPCOperation.m index 10c02ce63..4fe43a91e 100644 --- a/SmartDeviceLink/SDLAsynchronousRPCOperation.m +++ b/SmartDeviceLink/SDLAsynchronousRPCOperation.m @@ -58,7 +58,7 @@ NS_ASSUME_NONNULL_BEGIN return; } - [self.connectionManager sendConnectionRPC:rpc withResponseHandler:nil]; + [self.connectionManager sendConnectionRPC:rpc]; [self finishOperation]; } diff --git a/SmartDeviceLink/SDLAsynchronousRPCRequestOperation.m b/SmartDeviceLink/SDLAsynchronousRPCRequestOperation.m index 116e130a8..5c67e3e8a 100644 --- a/SmartDeviceLink/SDLAsynchronousRPCRequestOperation.m +++ b/SmartDeviceLink/SDLAsynchronousRPCRequestOperation.m @@ -90,7 +90,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)sdl_sendRequest:(SDLRPCRequest *)request { __weak typeof(self) weakSelf = self; - [self.connectionManager sendConnectionRPC:(__kindof SDLRPCMessage *)request withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:request withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { __strong typeof(self) strongSelf = weakSelf; if (strongSelf.isCancelled) { diff --git a/SmartDeviceLink/SDLConnectionManagerType.h b/SmartDeviceLink/SDLConnectionManagerType.h index aa0d8f0eb..d0e7f7f84 100644 --- a/SmartDeviceLink/SDLConnectionManagerType.h +++ b/SmartDeviceLink/SDLConnectionManagerType.h @@ -27,12 +27,21 @@ NS_ASSUME_NONNULL_BEGIN - (void)sendConnectionManagerRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler; /** - * Sends an RPC of type `SDLRPCRequest`, `SDLRPCResponse`, or `SDLRPCNotification` without bypassing the block on RPC sends before managers complete setup. + * Sends an RPC of type `SDLRPCRequest` without bypassing the block on RPC sends before managers complete setup. * - * @param rpc An RPC of type `SDLRPCRequest`, `SDLRPCResponse`, or `SDLRPCNotification` to be sent to the remote head unit. - * @param handler A completion block called when the response is received. + * @param request An RPC of type `SDLRPCRequest` be sent to Core. + * @param handler Called when the response is received by Core */ -- (void)sendConnectionRPC:(__kindof SDLRPCMessage *)rpc withResponseHandler:(nullable SDLResponseHandler)handler; +- (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler; + +/** + * Sends an RPC of type `SDLRPCResponse` or `SDLRPCNotification` without bypassing the block on RPC sends before managers complete setup. Unlike requests, responses and notifications sent to Core do not get a response from Core, so no handler is needed. + * + * Do not use to send an RPC of type `SDLRPCRequest`. Instead use `sendConnectionRequest:withResponseHandler:` to send a request. + * + * @param rpc An RPC of type `SDLRPCResponse` or `SDLRPCNotification` to be sent to Core. + */ +- (void)sendConnectionRPC:(__kindof SDLRPCMessage *)rpc; /** * Sends an array of RPCs of type `Request` asynchronously. The requests are sent without bypassing the block on RPC sends before managers complete setup. diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m index 841c5e705..59319a3fa 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -580,9 +580,22 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; [self.rpcOperationQueue addOperation:op]; } -- (void)sendConnectionRPC:(__kindof SDLRPCMessage *)request withResponseHandler:(nullable SDLResponseHandler)handler { +- (void)sendConnectionRPC:(__kindof SDLRPCMessage *)rpc { + NSAssert(([rpc isKindOfClass:SDLRPCResponse.class] || [rpc isKindOfClass:SDLRPCNotification.class]), @"Only RPCs of type `Response` or `Notfication` can be sent using this method. To send RPCs of type `Request` use sendConnectionRequest:withResponseHandler:."); + + if (![self.lifecycleStateMachine isCurrentState:SDLLifecycleStateReady]) { + SDLLogW(@"Manager not ready, message not sent (%@)", rpc); + return; + } + + dispatch_async(_lifecycleQueue, ^{ + [self sdl_sendRequest:rpc withResponseHandler:nil]; + }); +} + +- (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler { if (![self.lifecycleStateMachine isCurrentState:SDLLifecycleStateReady]) { - SDLLogW(@"Manager not ready, message not sent (%@)", request); + SDLLogW(@"Manager not ready, request not sent (%@)", request); if (handler) { dispatch_async(dispatch_get_main_queue(), ^{ handler(request, nil, [NSError sdl_lifecycle_notReadyError]); diff --git a/SmartDeviceLink/SDLPresentChoiceSetOperation.m b/SmartDeviceLink/SDLPresentChoiceSetOperation.m index 9b377b78e..4e923b8e1 100644 --- a/SmartDeviceLink/SDLPresentChoiceSetOperation.m +++ b/SmartDeviceLink/SDLPresentChoiceSetOperation.m @@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN setProperties.keyboardProperties = self.keyboardProperties; __weak typeof(self) weakself = self; - [self.connectionManager sendConnectionRPC:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (error != nil) { SDLLogE(@"Error setting keyboard properties to new value: %@, with error: %@", request, error); } @@ -126,7 +126,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)sdl_presentChoiceSet { __weak typeof(self) weakself = self; - [self.connectionManager sendConnectionRPC:self.performInteraction withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:self.performInteraction withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (error != nil) { SDLLogE(@"Presenting choice set failed with response: %@, error: %@", response, error); weakself.internalError = error; @@ -244,7 +244,7 @@ NS_ASSUME_NONNULL_BEGIN SDLSetGlobalProperties *setProperties = [[SDLSetGlobalProperties alloc] init]; setProperties.keyboardProperties = self.originalKeyboardProperties; - [self.connectionManager sendConnectionRPC:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (error != nil) { SDLLogE(@"Error resetting keyboard properties to values: %@, with error: %@", request, error); } diff --git a/SmartDeviceLink/SDLPresentKeyboardOperation.m b/SmartDeviceLink/SDLPresentKeyboardOperation.m index 75a9b5e83..b81284ebe 100644 --- a/SmartDeviceLink/SDLPresentKeyboardOperation.m +++ b/SmartDeviceLink/SDLPresentKeyboardOperation.m @@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN SDLSetGlobalProperties *setProperties = [[SDLSetGlobalProperties alloc] init]; setProperties.keyboardProperties = self.keyboardProperties; - [self.connectionManager sendConnectionRPC:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (error != nil) { SDLLogE(@"Error setting keyboard properties to new value: %@, with error: %@", request, error); } @@ -94,7 +94,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)sdl_presentKeyboard { - [self.connectionManager sendConnectionRPC:self.performInteraction withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:self.performInteraction withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (self.isCancelled) { [self finishOperation]; return; @@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN SDLSetGlobalProperties *setProperties = [[SDLSetGlobalProperties alloc] init]; setProperties.keyboardProperties = self.originalKeyboardProperties; - [self.connectionManager sendConnectionRPC:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:setProperties withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (error != nil) { SDLLogE(@"Error resetting keyboard properties to values: %@, with error: %@", request, error); } diff --git a/SmartDeviceLink/SDLSequentialRPCRequestOperation.m b/SmartDeviceLink/SDLSequentialRPCRequestOperation.m index aa4e9209c..43b025947 100644 --- a/SmartDeviceLink/SDLSequentialRPCRequestOperation.m +++ b/SmartDeviceLink/SDLSequentialRPCRequestOperation.m @@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN // Send the next request SDLRPCRequest *request = self.requests[self.currentRequestIndex]; - [self.connectionManager sendConnectionRPC:(__kindof SDLRPCMessage *)request withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { self.requestsComplete++; // If this request failed and no request has yet failed, set our internal request failed to YES diff --git a/SmartDeviceLink/SDLSoftButtonManager.m b/SmartDeviceLink/SDLSoftButtonManager.m index 1918ab93e..3f19ff1e1 100644 --- a/SmartDeviceLink/SDLSoftButtonManager.m +++ b/SmartDeviceLink/SDLSoftButtonManager.m @@ -214,7 +214,7 @@ NS_ASSUME_NONNULL_BEGIN } __weak typeof(self) weakSelf = self; - [self.connectionManager sendConnectionRPC:self.inProgressUpdate withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:self.inProgressUpdate withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { __strong typeof(weakSelf) strongSelf = weakSelf; SDLLogD(@"Soft button update completed"); diff --git a/SmartDeviceLink/SDLSystemCapabilityManager.m b/SmartDeviceLink/SDLSystemCapabilityManager.m index a9a185367..cd9db463a 100644 --- a/SmartDeviceLink/SDLSystemCapabilityManager.m +++ b/SmartDeviceLink/SDLSystemCapabilityManager.m @@ -144,7 +144,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)updateCapabilityType:(SDLSystemCapabilityType)type completionHandler:(SDLUpdateCapabilityHandler)handler { self.systemCapabilityHandler = handler; SDLGetSystemCapability *getSystemCapability = [[SDLGetSystemCapability alloc] initWithType:type]; - [self.connectionManager sendConnectionRPC:getSystemCapability withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:getSystemCapability withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { if (error == nil) { return; } // An error is returned if the request was unsuccessful or a Generic Response is returned handler(error, self); diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m index aadd40bdb..3c3395f14 100644 --- a/SmartDeviceLink/SDLTextAndGraphicManager.m +++ b/SmartDeviceLink/SDLTextAndGraphicManager.m @@ -205,7 +205,7 @@ NS_ASSUME_NONNULL_BEGIN if (self.inProgressUpdate == nil) { return; } - [self.connectionManager sendConnectionRPC:self.inProgressUpdate withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.connectionManager sendConnectionRequest:self.inProgressUpdate withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { __strong typeof(weakSelf) strongSelf = weakSelf; SDLLogD(@"Text and Graphic update completed"); diff --git a/SmartDeviceLinkTests/SDLRPCResponseOperationSpec.m b/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m index d7ef9cf98..40fff1d7a 100644 --- a/SmartDeviceLinkTests/SDLRPCResponseOperationSpec.m +++ b/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m @@ -1,5 +1,5 @@ // -// SDLRPCResponseOperationSpec.m +// SDLAsynchronousRPCOperationSpec.m // SmartDeviceLinkTests // // Created by Nicole on 2/20/19. @@ -14,7 +14,7 @@ #import "SDLAsynchronousRPCOperation.h" #import "TestConnectionManager.h" -QuickSpecBegin(SDLRPCResponseOperationSpec) +QuickSpecBegin(SDLAsynchronousRPCOperationSpec) describe(@"sending responses and notifications", ^{ __block TestConnectionManager *testConnectionManager = nil; diff --git a/SmartDeviceLinkTests/TestMultipleFilesConnectionManager.m b/SmartDeviceLinkTests/TestMultipleFilesConnectionManager.m index 50f7beda1..ef4756bda 100644 --- a/SmartDeviceLinkTests/TestMultipleFilesConnectionManager.m +++ b/SmartDeviceLinkTests/TestMultipleFilesConnectionManager.m @@ -19,8 +19,8 @@ NS_ASSUME_NONNULL_BEGIN @implementation TestMultipleFilesConnectionManager -- (void)sendConnectionRPC:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler { - [super sendConnectionRPC:request withResponseHandler:handler]; +- (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler { + [super sendConnectionRequest:request withResponseHandler:handler]; if ([[request name] isEqualToString:SDLRPCFunctionNamePutFile]) { SDLPutFile *putfileRequest = (SDLPutFile *)request; diff --git a/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m b/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m index 8f6f4660e..5ba813171 100644 --- a/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m +++ b/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m @@ -26,24 +26,24 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (void)sendConnectionRPC:(__kindof SDLRPCMessage *)request withResponseHandler:(nullable SDLResponseHandler)handler { +- (void)sendConnectionRPC:(__kindof SDLRPCMessage *)rpc { + [self.receivedRequests addObject:rpc]; +} + +- (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler { self.lastRequestBlock = handler; - if ([request isKindOfClass:SDLRPCRequest.class]) { - SDLRPCRequest *requestRPC = (SDLRPCRequest *)request; - requestRPC.correlationID = [self test_nextCorrelationID]; - [self.receivedRequests addObject:requestRPC]; - } else { - [self.receivedRequests addObject:request]; - } + SDLRPCRequest *requestRPC = (SDLRPCRequest *)request; + requestRPC.correlationID = [self test_nextCorrelationID]; + [self.receivedRequests addObject:requestRPC]; } - (void)sendConnectionManagerRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler { - [self sendConnectionRPC:request withResponseHandler:handler]; + [self sendConnectionRequest:request withResponseHandler:handler]; } - (void)sendRequests:(nonnull NSArray<SDLRPCRequest *> *)requests progressHandler:(nullable SDLMultipleAsyncRequestProgressHandler)progressHandler completionHandler:(nullable SDLMultipleRequestCompletionHandler)completionHandler { [requests enumerateObjectsUsingBlock:^(SDLRPCRequest * _Nonnull request, NSUInteger idx, BOOL * _Nonnull stop) { - [self sendConnectionRPC:request withResponseHandler:nil]; + [self sendConnectionRequest:request withResponseHandler:nil]; if (progressHandler != nil) { progressHandler(request, nil, nil, (double)idx / (double)requests.count); @@ -55,7 +55,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)sendSequentialRequests:(nonnull NSArray<SDLRPCRequest *> *)requests progressHandler:(nullable SDLMultipleSequentialRequestProgressHandler)progressHandler completionHandler:(nullable SDLMultipleRequestCompletionHandler)completionHandler { [requests enumerateObjectsUsingBlock:^(SDLRPCRequest * _Nonnull request, NSUInteger idx, BOOL * _Nonnull stop) { - [self sendConnectionRPC:request withResponseHandler:nil]; + [self sendConnectionRequest:request withResponseHandler:nil]; progressHandler(request, nil, nil, (double)idx / (double)requests.count); }]; diff --git a/SmartDeviceLinkTests/TestUtilities/TestMultipleRequestsConnectionManager.m b/SmartDeviceLinkTests/TestUtilities/TestMultipleRequestsConnectionManager.m index 49f4d620c..b1935a8ab 100644 --- a/SmartDeviceLinkTests/TestUtilities/TestMultipleRequestsConnectionManager.m +++ b/SmartDeviceLinkTests/TestUtilities/TestMultipleRequestsConnectionManager.m @@ -24,8 +24,12 @@ return self; } -- (void)sendConnectionRPC:(__kindof SDLRPCRequest *)request withResponseHandler:(SDLResponseHandler)handler { - [super sendConnectionRPC:request withResponseHandler:handler]; +- (void)sendConnectionRPC:(__kindof SDLRPCMessage *)rpc { + [super sendConnectionRPC:rpc]; +} + +- (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler { + [super sendConnectionRequest:request withResponseHandler:handler]; NSAssert([request.name isEqualToString:SDLRPCFunctionNameAddCommand], @"The TestMultipleRequestsConnectionManager is only setup for SDLAddCommand"); |