summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-04-05 09:09:59 -0400
committerJoel Fischer <joeljfischer@gmail.com>2019-04-05 09:09:59 -0400
commit70497db06775f97a5d448c34c4ea60516fc7237d (patch)
treeaf314cc1e67e08889613b50db7ec82f361be8d06
parentb6e1e9fa6c3e62c1e1bcd202acd89616e68cc221 (diff)
downloadsdl_ios-70497db06775f97a5d448c34c4ea60516fc7237d.tar.gz
Only handle GetSystemCapabilityResponse from inside the SCM, not outside as well
-rw-r--r--SmartDeviceLink/SDLSystemCapabilityManager.m12
-rw-r--r--SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m103
2 files changed, 21 insertions, 94 deletions
diff --git a/SmartDeviceLink/SDLSystemCapabilityManager.m b/SmartDeviceLink/SDLSystemCapabilityManager.m
index f8ad12bc1..6d68573b4 100644
--- a/SmartDeviceLink/SDLSystemCapabilityManager.m
+++ b/SmartDeviceLink/SDLSystemCapabilityManager.m
@@ -160,13 +160,6 @@ typedef NSString * SDLServiceID;
self.presetBankCapabilities = response.presetBankCapabilities;
}
-- (void)sdl_getSystemCapabilityResponse:(SDLRPCResponseNotification *)notification {
- SDLGetSystemCapabilityResponse *response = (SDLGetSystemCapabilityResponse *)notification.response;
- if (!response.success.boolValue) { return; }
-
- [self sdl_saveSystemCapability:response.systemCapability completionHandler:nil];
-}
-
/**
* Called when an `OnSystemCapabilityUpdated` notification is received from Core. The updated system capabilty is saved.
*
@@ -221,7 +214,7 @@ typedef NSString * SDLServiceID;
*/
- (void)sdl_subscribeToSystemCapabilityUpdates {
for (SDLSystemCapabilityType type in [self.class sdl_systemCapabilityTypes]) {
- SDLGetSystemCapability *getSystemCapability = [[SDLGetSystemCapability alloc] initWithType:type subscribe:true];
+ SDLGetSystemCapability *getSystemCapability = [[SDLGetSystemCapability alloc] initWithType:type subscribe:YES];
[self sdl_sendGetSystemCapability:getSystemCapability completionHandler:nil];
}
}
@@ -240,7 +233,6 @@ typedef NSString * SDLServiceID;
return;
}
- // TODO: Still do this even though we do it in `sdl_getSystemCapabilityResponse`? Will the handler be called before the changes are applied if we don't?
SDLGetSystemCapabilityResponse *getSystemCapabilityResponse = (SDLGetSystemCapabilityResponse *)response;
if (!getSystemCapabilityResponse.success.boolValue) { return; }
[self sdl_saveSystemCapability:getSystemCapabilityResponse.systemCapability completionHandler:handler];
@@ -270,6 +262,8 @@ typedef NSString * SDLServiceID;
return;
}
+ SDLLogD(@"Updated system capability manager with new data: %@", systemCapability);
+
if (handler == nil) { return; }
handler(nil, self);
}
diff --git a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m
index 14dfadd06..c6586c2c5 100644
--- a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m
+++ b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m
@@ -335,93 +335,26 @@ describe(@"System capability manager", ^{
context(@"When the system capability manager is stopped after being started", ^{
beforeEach(^{
- SDLRegisterAppInterfaceResponse *testRegisterAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
- testRegisterAppInterfaceResponse.displayCapabilities = [[SDLDisplayCapabilities alloc] init];
- testRegisterAppInterfaceResponse.hmiCapabilities = [[SDLHMICapabilities alloc] init];
- testRegisterAppInterfaceResponse.softButtonCapabilities = @[[[SDLSoftButtonCapabilities alloc] init]];
- testRegisterAppInterfaceResponse.buttonCapabilities = @[[[SDLButtonCapabilities alloc] init]];
- testRegisterAppInterfaceResponse.presetBankCapabilities = [[SDLPresetBankCapabilities alloc] init];
- testRegisterAppInterfaceResponse.hmiZoneCapabilities = @[SDLHMIZoneCapabilitiesFront];
- testRegisterAppInterfaceResponse.speechCapabilities = @[SDLSpeechCapabilitiesPrerecorded];
- testRegisterAppInterfaceResponse.prerecordedSpeech = @[SDLPrerecordedSpeechHelp];
- testRegisterAppInterfaceResponse.vrCapabilities = @[SDLVRCapabilitiesText];
- testRegisterAppInterfaceResponse.audioPassThruCapabilities = @[[[SDLAudioPassThruCapabilities alloc] init]];
- testRegisterAppInterfaceResponse.pcmStreamCapabilities = [[SDLAudioPassThruCapabilities alloc] init];
- testRegisterAppInterfaceResponse.success = @YES;
- SDLRPCResponseNotification *registerAppInterfaceNotification = [[SDLRPCResponseNotification alloc] initWithName:SDLDidReceiveRegisterAppInterfaceResponse object:self rpcResponse:testRegisterAppInterfaceResponse];
- [[NSNotificationCenter defaultCenter] postNotification:registerAppInterfaceNotification];
-
- SDLGetSystemCapabilityResponse *testAppServicesGetSystemCapabilityResponse = [[SDLGetSystemCapabilityResponse alloc] init];
- testAppServicesGetSystemCapabilityResponse.systemCapability = [[SDLSystemCapability alloc] initWithAppServicesCapabilities:[[SDLAppServicesCapabilities alloc] init]];
- testAppServicesGetSystemCapabilityResponse.success = @YES;
- SDLRPCResponseNotification *appServicesGetSystemCapabilityNotification = [[SDLRPCResponseNotification alloc] initWithName:SDLDidReceiveGetSystemCapabilitiesResponse object:self rpcResponse:testAppServicesGetSystemCapabilityResponse];
- [[NSNotificationCenter defaultCenter] postNotification:appServicesGetSystemCapabilityNotification];
-
- SDLGetSystemCapabilityResponse *testNavGetSystemCapabilityResponse = [[SDLGetSystemCapabilityResponse alloc] init];
- testNavGetSystemCapabilityResponse.systemCapability = [[SDLSystemCapability alloc] initWithNavigationCapability:[[SDLNavigationCapability alloc] init]];
- testNavGetSystemCapabilityResponse.success = @YES;
- SDLRPCResponseNotification *navGetSystemCapabilityNotification = [[SDLRPCResponseNotification alloc] initWithName:SDLDidReceiveGetSystemCapabilitiesResponse object:self rpcResponse:testNavGetSystemCapabilityResponse];
- [[NSNotificationCenter defaultCenter] postNotification:navGetSystemCapabilityNotification];
-
- SDLGetSystemCapabilityResponse *testPhoneGetSystemCapabilityResponse = [[SDLGetSystemCapabilityResponse alloc] init];
- testPhoneGetSystemCapabilityResponse.systemCapability = [[SDLSystemCapability alloc] initWithPhoneCapability:[[SDLPhoneCapability alloc] initWithDialNumber:YES]];
- testPhoneGetSystemCapabilityResponse.success = @YES;
- SDLRPCResponseNotification *phoneGetSystemCapabilityNotification = [[SDLRPCResponseNotification alloc] initWithName:SDLDidReceiveGetSystemCapabilitiesResponse object:self rpcResponse:testPhoneGetSystemCapabilityResponse];
- [[NSNotificationCenter defaultCenter] postNotification:phoneGetSystemCapabilityNotification];
-
- SDLGetSystemCapabilityResponse *testVideoGetSystemCapabilityResponse = [[SDLGetSystemCapabilityResponse alloc] init];
- testVideoGetSystemCapabilityResponse.systemCapability = [[SDLSystemCapability alloc] initWithVideoStreamingCapability:[[SDLVideoStreamingCapability alloc] init]];
- testVideoGetSystemCapabilityResponse.success = @YES;
- SDLRPCResponseNotification *videoGetSystemCapabilityNotification = [[SDLRPCResponseNotification alloc] initWithName:SDLDidReceiveGetSystemCapabilitiesResponse object:self rpcResponse:testVideoGetSystemCapabilityResponse];
- [[NSNotificationCenter defaultCenter] postNotification:videoGetSystemCapabilityNotification];
-
- SDLGetSystemCapabilityResponse *testRemoteControlGetSystemCapabilityResponse = [[SDLGetSystemCapabilityResponse alloc] init];
- testRemoteControlGetSystemCapabilityResponse.systemCapability = [[SDLSystemCapability alloc] initWithRemoteControlCapability:[[SDLRemoteControlCapabilities alloc] init]];
- testRemoteControlGetSystemCapabilityResponse.success = @YES;
- SDLRPCResponseNotification *remoteControlGetSystemCapabilityNotification = [[SDLRPCResponseNotification alloc] initWithName:SDLDidReceiveGetSystemCapabilitiesResponse object:self rpcResponse:testRemoteControlGetSystemCapabilityResponse];
- [[NSNotificationCenter defaultCenter] postNotification:remoteControlGetSystemCapabilityNotification];
-
- expect(testSystemCapabilityManager.displayCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.hmiCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.softButtonCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.buttonCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.presetBankCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.hmiZoneCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.speechCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.prerecordedSpeechCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.vrCapability).toNot(beFalse());
- expect(testSystemCapabilityManager.audioPassThruCapabilities).toNot(beNil());
- expect(testSystemCapabilityManager.pcmStreamCapability).toNot(beNil());
- expect(testSystemCapabilityManager.phoneCapability).toNot(beNil());
- expect(testSystemCapabilityManager.navigationCapability).toNot(beNil());
- expect(testSystemCapabilityManager.videoStreamingCapability).toNot(beNil());
- expect(testSystemCapabilityManager.remoteControlCapability).toNot(beNil());
- expect(testSystemCapabilityManager.appServicesCapabilities).toNot(beNil());
+ [testSystemCapabilityManager stop];
});
- describe(@"When stopped", ^{
- beforeEach(^{
- [testSystemCapabilityManager stop];
- });
-
- it(@"It should reset the system capability manager properties correctly", ^{
- expect(testSystemCapabilityManager.displayCapabilities).to(beNil());
- expect(testSystemCapabilityManager.hmiCapabilities).to(beNil());
- expect(testSystemCapabilityManager.softButtonCapabilities).to(beNil());
- expect(testSystemCapabilityManager.buttonCapabilities).to(beNil());
- expect(testSystemCapabilityManager.presetBankCapabilities).to(beNil());
- expect(testSystemCapabilityManager.hmiZoneCapabilities).to(beNil());
- expect(testSystemCapabilityManager.speechCapabilities).to(beNil());
- expect(testSystemCapabilityManager.prerecordedSpeechCapabilities).to(beNil());
- expect(testSystemCapabilityManager.vrCapability).to(beFalse());
- expect(testSystemCapabilityManager.audioPassThruCapabilities).to(beNil());
- expect(testSystemCapabilityManager.pcmStreamCapability).to(beNil());
- expect(testSystemCapabilityManager.phoneCapability).to(beNil());
- expect(testSystemCapabilityManager.navigationCapability).to(beNil());
- expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil());
- expect(testSystemCapabilityManager.remoteControlCapability).to(beNil());
- expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil());
- });
+ it(@"It should reset the system capability manager properties correctly", ^{
+ expect(testSystemCapabilityManager.displayCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.hmiCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.softButtonCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.buttonCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.presetBankCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.hmiZoneCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.speechCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.prerecordedSpeechCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.vrCapability).to(beFalse());
+ expect(testSystemCapabilityManager.audioPassThruCapabilities).to(beNil());
+ expect(testSystemCapabilityManager.pcmStreamCapability).to(beNil());
+ expect(testSystemCapabilityManager.phoneCapability).to(beNil());
+ expect(testSystemCapabilityManager.navigationCapability).to(beNil());
+ expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil());
+ expect(testSystemCapabilityManager.remoteControlCapability).to(beNil());
+ expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil());
});
});
});