summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-06-05 14:36:41 -0400
committerGitHub <noreply@github.com>2020-06-05 14:36:41 -0400
commitef12e261638cfda8852303e3570a3905d29cef3e (patch)
treee8e6cd268ead39ee44c0b4bdb73aa5bc77457bde
parent679ea9d031b56f83b60f15f61b70000547d6b70c (diff)
parent9386de839fd0a10b24c4644eee1e47b7fd1d6368 (diff)
downloadsdl_ios-ef12e261638cfda8852303e3570a3905d29cef3e.tar.gz
Merge pull request #1674 from smartdevicelink/feature/issue-1606-sdl-0289-set-language-separately
Implement SDL-0289 Unit Tests
-rw-r--r--Example Apps/Example ObjC/ProxyManager.m21
-rw-r--r--Example Apps/Example Swift/ProxyManager.swift23
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj20
-rw-r--r--SmartDeviceLink/SDLLifecycleConfigurationUpdate.m4
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m43
-rw-r--r--SmartDeviceLink/SDLManagerDelegate.h11
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m175
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h19
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m24
-rw-r--r--SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h19
-rw-r--r--SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m21
11 files changed, 324 insertions, 56 deletions
diff --git a/Example Apps/Example ObjC/ProxyManager.m b/Example Apps/Example ObjC/ProxyManager.m
index ea4a58757..2c5c05357 100644
--- a/Example Apps/Example ObjC/ProxyManager.m
+++ b/Example Apps/Example ObjC/ProxyManager.m
@@ -290,6 +290,8 @@ NS_ASSUME_NONNULL_BEGIN
}
}
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language {
SDLLifecycleConfigurationUpdate *update = [[SDLLifecycleConfigurationUpdate alloc] init];
@@ -306,6 +308,25 @@ NS_ASSUME_NONNULL_BEGIN
update.ttsName = [SDLTTSChunk textChunksFromString:update.appName];
return update;
}
+#pragma clang diagnostic pop
+
+- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language hmiLanguage:(SDLLanguage)hmiLanguage {
+ SDLLifecycleConfigurationUpdate *update = [[SDLLifecycleConfigurationUpdate alloc] init];
+
+ if ([hmiLanguage isEqualToEnum:SDLLanguageEnUs]) {
+ update.appName = ExampleAppName;
+ } else if ([hmiLanguage isEqualToEnum:SDLLanguageEsMx]) {
+ update.appName = ExampleAppNameSpanish;
+ } else if ([hmiLanguage isEqualToEnum:SDLLanguageFrCa]) {
+ update.appName = ExampleAppNameFrench;
+ } else {
+ return nil;
+ }
+
+ update.ttsName = @[[SDLTTSChunk textChunksFromString:update.appName]];
+
+ return update;
+}
@end
diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift
index 4238251bf..3b7ed1ef5 100644
--- a/Example Apps/Example Swift/ProxyManager.swift
+++ b/Example Apps/Example Swift/ProxyManager.swift
@@ -228,6 +228,29 @@ extension ProxyManager: SDLManagerDelegate {
return SDLLifecycleConfigurationUpdate(appName: appName, shortAppName: nil, ttsName: [SDLTTSChunk(text: appName, type: .text)], voiceRecognitionCommandNames: nil)
}
+
+ /// Called when the car's head unit language is different from the default langage set in the SDLConfiguration AND the head unit language is supported by the app (as set in `languagesSupported` of SDLConfiguration). This method is only called when a connection to Core is first established. If desired, you can update the app's name and text-to-speech name to reflect the head unit's language.
+ ///
+ /// - Parameter language: The head unit's current VR+TTS language
+ /// - Parameter hmiLanguage: The head unit's current HMI language
+ /// - Returns: A SDLLifecycleConfigurationUpdate object
+ func managerShouldUpdateLifecycle(toLanguage language: SDLLanguage, hmiLanguage: SDLLanguage) -> SDLLifecycleConfigurationUpdate? {
+ let update = SDLLifecycleConfigurationUpdate()
+ switch hmiLanguage {
+ case .enUs:
+ update.appName = ExampleAppName
+ case .esMx:
+ update.appName = ExampleAppNameSpanish
+ case .frCa:
+ update.appName = ExampleAppNameFrench
+ default:
+ return nil
+ }
+
+ update.ttsName = [SDLTTSChunk(text: update.appName!, type: .text)]
+
+ return update
+ }
}
// MARK: - SDL UI
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index 378ad6ac0..91b4f85a9 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -416,6 +416,8 @@
2BF2F85220ED068200A26EF2 /* SDLAudioStreamingIndicatorSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BF2F85120ED068200A26EF2 /* SDLAudioStreamingIndicatorSpec.m */; };
332A914F1CED9CC60043824C /* SDLAppInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 332A913D1CED87F80043824C /* SDLAppInfo.m */; };
332A91501CED9CF10043824C /* SDLAppInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 332A913C1CED87F80043824C /* SDLAppInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 4A4AD8A424894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A4AD8A324894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m */; };
+ 4A4AD8A724894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A4AD8A624894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m */; };
4A99D00E247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A99D00C247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h */; };
4A99D00F247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A99D00D247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m */; };
4A99D0122475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A99D0102475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h */; };
@@ -2131,6 +2133,10 @@
2BF2F85120ED068200A26EF2 /* SDLAudioStreamingIndicatorSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLAudioStreamingIndicatorSpec.m; sourceTree = "<group>"; };
332A913C1CED87F80043824C /* SDLAppInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLAppInfo.h; sourceTree = "<group>"; };
332A913D1CED87F80043824C /* SDLAppInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAppInfo.m; sourceTree = "<group>"; };
+ 4A4AD8A224894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TestOldConfigurationUpdateManagerDelegate.h; path = DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h; sourceTree = "<group>"; };
+ 4A4AD8A324894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = TestOldConfigurationUpdateManagerDelegate.m; path = DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m; sourceTree = "<group>"; };
+ 4A4AD8A524894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestNewConfigurationUpdateManagerDelegate.h; sourceTree = "<group>"; };
+ 4A4AD8A624894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestNewConfigurationUpdateManagerDelegate.m; sourceTree = "<group>"; };
4A99D00C247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SDLTextField+ScreenManagerExtensions.h"; sourceTree = "<group>"; };
4A99D00D247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SDLTextField+ScreenManagerExtensions.m"; sourceTree = "<group>"; };
4A99D0102475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SDLImageField+ScreenManagerExtensions.h"; sourceTree = "<group>"; };
@@ -3985,6 +3991,17 @@
path = MessageSpecs;
sourceTree = "<group>";
};
+ 4A4AD8A12489422F008FC414 /* Utilities */ = {
+ isa = PBXGroup;
+ children = (
+ 4A4AD8A224894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.h */,
+ 4A4AD8A324894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m */,
+ 4A4AD8A524894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.h */,
+ 4A4AD8A624894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m */,
+ );
+ name = Utilities;
+ sourceTree = "<group>";
+ };
5D0218EB1A8E795700D1BF62 /* UI */ = {
isa = PBXGroup;
children = (
@@ -4088,6 +4105,7 @@
5D1654541D3E753100554D93 /* Lifecycle */ = {
isa = PBXGroup;
children = (
+ 4A4AD8A12489422F008FC414 /* Utilities */,
5D1654551D3E754F00554D93 /* SDLLifecycleManagerSpec.m */,
888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */,
5D60DF23202B7A80001EDA01 /* SDLAsynchronousRPCRequestOperationSpec.m */,
@@ -7930,6 +7948,7 @@
1EAA47722036AEF5000FE74B /* SDLLightNameSpec.m in Sources */,
5DB92D2F1AC59F0000C15BB0 /* SDLObjectWithPrioritySpec.m in Sources */,
88DF999122035D5A00477AC1 /* SDLIAPTransportSpec.m in Sources */,
+ 4A4AD8A424894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m in Sources */,
162E838A1A9BDE8B00906325 /* SDLSingleTireStatusSpec.m in Sources */,
5D6EB4CC1BF28DC600693731 /* NSMapTable+SubscriptingSpec.m in Sources */,
88F37A4D226F84BE00DF119B /* SDLIAPDataSessionSpec.m in Sources */,
@@ -8211,6 +8230,7 @@
162E838F1A9BDE8B00906325 /* SDLTextFieldSpec.m in Sources */,
8818ADDD2100FE0C007D6F19 /* SDLTurnSignalSpec.m in Sources */,
162E82CA1A9BDE8A00906325 /* SDLAmbientLightStatusSpec.m in Sources */,
+ 4A4AD8A724894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m in Sources */,
162E83091A9BDE8B00906325 /* SDLVehicleDataStatusSpec.m in Sources */,
5DAD5F8D20508F220025624C /* SDLSoftButtonManagerSpec.m in Sources */,
162E83741A9BDE8B00906325 /* SDLBodyInformationSpec.m in Sources */,
diff --git a/SmartDeviceLink/SDLLifecycleConfigurationUpdate.m b/SmartDeviceLink/SDLLifecycleConfigurationUpdate.m
index b81b14d03..b86688445 100644
--- a/SmartDeviceLink/SDLLifecycleConfigurationUpdate.m
+++ b/SmartDeviceLink/SDLLifecycleConfigurationUpdate.m
@@ -25,4 +25,8 @@
return self;
}
+- (NSString *)description {
+ return [NSString stringWithFormat:@"Lifecycle Configuration Update: new app name: %@, new short app name: %@, new tts name: %@, new voice commands: %@", self.appName, self.shortAppName, self.ttsName, self.voiceRecognitionCommandNames];
+}
+
@end
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index c0f47177c..f4d9daa22 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -101,6 +101,7 @@ NSString *const BackgroundTaskTransportName = @"com.sdl.transport.backgroundTask
@property (assign, nonatomic) int32_t lastCorrelationId;
@property (copy, nonatomic) SDLBackgroundTaskManager *backgroundTaskManager;
@property (copy, nonatomic) SDLEncryptionLifecycleManager *encryptionLifecycleManager;
+@property (strong, nonatomic) SDLLanguage currentVRLanguage;
@end
@@ -145,6 +146,8 @@ NSString *const BackgroundTaskTransportName = @"com.sdl.transport.backgroundTask
_lifecycleQueue = [SDLGlobals sharedGlobals].sdlProcessingQueue;
}
+ _currentVRLanguage = _configuration.lifecycleConfig.language;
+
// Managers
_fileManager = [[SDLFileManager alloc] initWithConnectionManager:self configuration:_configuration.fileManagerConfig];
_permissionManager = [[SDLPermissionManager alloc] init];
@@ -372,12 +375,20 @@ NSString *const BackgroundTaskTransportName = @"com.sdl.transport.backgroundTask
}
NSArray<SDLLanguage> *supportedLanguages = self.configuration.lifecycleConfig.languagesSupported;
- SDLLanguage desiredLanguage = self.configuration.lifecycleConfig.language;
- SDLLanguage actualLanguage = self.registerResponse.language;
- BOOL delegateCanUpdateLifecycle = [self.delegate respondsToSelector:@selector(managerShouldUpdateLifecycleToLanguage:)];
-
+ SDLLanguage desiredHMILanguage = self.configuration.lifecycleConfig.language;
+ SDLLanguage desiredVRLanguage = self.currentVRLanguage;
+
+ SDLLanguage actualHMILanguage = self.registerResponse.hmiDisplayLanguage;
+ SDLLanguage actualVRLanguage = self.registerResponse.language;
+
+ BOOL oldDelegateCanUpdateLifecycle = [self.delegate respondsToSelector:@selector(managerShouldUpdateLifecycleToLanguage:)];
+ BOOL delegateCanUpdateLifecycle = [self.delegate respondsToSelector:@selector(managerShouldUpdateLifecycleToLanguage:hmiLanguage:)];
+
// language mismatch? but actual language is a supported language? and delegate has implemented method?
- if (![actualLanguage isEqualToEnum:desiredLanguage] && [supportedLanguages containsObject:actualLanguage] && delegateCanUpdateLifecycle) {
+ if ((delegateCanUpdateLifecycle || oldDelegateCanUpdateLifecycle)
+ && ([supportedLanguages containsObject:actualHMILanguage] || [supportedLanguages containsObject:actualVRLanguage])
+ && (![actualHMILanguage isEqualToEnum:desiredHMILanguage] || ![actualVRLanguage isEqualToEnum:desiredVRLanguage])) {
+ // If the delegate is implemented, AND the new HMI / VR language is a supported language, AND the new HMI / VR language is not the current language, THEN go to the updating configuration state and see if the dev wants to change the registration.
[self sdl_transitionToState:SDLLifecycleStateUpdatingConfiguration];
} else {
[self sdl_transitionToState:SDLLifecycleStateSettingUpManagers];
@@ -386,13 +397,25 @@ NSString *const BackgroundTaskTransportName = @"com.sdl.transport.backgroundTask
- (void)didEnterStateUpdatingConfiguration {
// We can expect that the delegate has implemented the update method and the actual language is a supported language
+ SDLLanguage actualHMILanguage = self.registerResponse.hmiDisplayLanguage;
SDLLanguage actualLanguage = self.registerResponse.language;
- SDLLogD(@"Updating configuration due to language mismatch. New langugage: %@", actualLanguage);
-
- SDLLifecycleConfigurationUpdate *configUpdate = [self.delegate managerShouldUpdateLifecycleToLanguage:actualLanguage];
+ SDLLogD(@"Updating configuration due to language mismatch. New language: %@, new hmiLanguage: %@", actualLanguage, actualHMILanguage);
+
+ SDLLifecycleConfigurationUpdate *configUpdate = nil;
+ BOOL supportsNewDelegate = [self.delegate respondsToSelector:@selector(managerShouldUpdateLifecycleToLanguage:hmiLanguage:)];
+ BOOL supportsOldDelegate = [self.delegate respondsToSelector:@selector(managerShouldUpdateLifecycleToLanguage:)];
+ if (supportsNewDelegate) {
+ configUpdate = [self.delegate managerShouldUpdateLifecycleToLanguage:actualLanguage hmiLanguage:actualHMILanguage];
+ } else if (supportsOldDelegate) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ configUpdate = [self.delegate managerShouldUpdateLifecycleToLanguage:actualLanguage];
+#pragma clang diagnostic pop
+ }
if (configUpdate) {
- self.configuration.lifecycleConfig.language = actualLanguage;
+ self.configuration.lifecycleConfig.language = actualHMILanguage;
+ self.currentVRLanguage = actualLanguage;
if (configUpdate.appName) {
self.configuration.lifecycleConfig.appName = configUpdate.appName;
}
@@ -406,7 +429,7 @@ NSString *const BackgroundTaskTransportName = @"com.sdl.transport.backgroundTask
self.configuration.lifecycleConfig.voiceRecognitionCommandNames = configUpdate.voiceRecognitionCommandNames;
}
- SDLChangeRegistration *changeRegistration = [[SDLChangeRegistration alloc] initWithLanguage:actualLanguage hmiDisplayLanguage:actualLanguage];
+ SDLChangeRegistration *changeRegistration = [[SDLChangeRegistration alloc] initWithLanguage:actualLanguage hmiDisplayLanguage:actualHMILanguage];
changeRegistration.appName = configUpdate.appName;
changeRegistration.ngnMediaScreenAppName = configUpdate.shortAppName;
changeRegistration.ttsName = configUpdate.ttsName;
diff --git a/SmartDeviceLink/SDLManagerDelegate.h b/SmartDeviceLink/SDLManagerDelegate.h
index 9cf795e37..f91a5ecb9 100644
--- a/SmartDeviceLink/SDLManagerDelegate.h
+++ b/SmartDeviceLink/SDLManagerDelegate.h
@@ -64,7 +64,16 @@ NS_ASSUME_NONNULL_BEGIN
* @param language The language of the connected head unit the manager is trying to update the configuration.
* @return An object of SDLLifecycleConfigurationUpdate if the head unit language is supported, otherwise nil to indicate that the language is not supported.
*/
-- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language;
+- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language __deprecated_msg("Use managerShouldUpdateLifecycleToLanguage:hmiLanguage");
+
+/**
+ * Called when the lifecycle manager detected a language mismatch. In case of a language mismatch the manager should change the apps registration by updating the lifecycle configuration to the specified language. If the app can support the specified language it should return an Object of SDLLifecycleConfigurationUpdate, otherwise it should return nil to indicate that the language is not supported.
+ *
+ * @param language The VR+TTS language of the connected head unit the manager is trying to update the configuration.
+ * @param hmiLanguage The HMI display language of the connected head unit the manager is trying to update the configuration.
+ * @return An object of SDLLifecycleConfigurationUpdate if the head unit language is supported, otherwise nil to indicate that the language is not supported.
+ */
+- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language hmiLanguage:(SDLLanguage)hmiLanguage;
@end
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
index cda5285c4..0c1219cdb 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
@@ -42,6 +42,9 @@
#import "SDLVersion.h"
#import "SDLVideoStreamingState.h"
+#import "TestOldConfigurationUpdateManagerDelegate.h"
+#import "TestNewConfigurationUpdateManagerDelegate.h"
+
// Ignore the deprecated proxy methods
#pragma clang diagnostic push
@@ -58,6 +61,7 @@
// this private property is used for testing
@property (copy, nonatomic) dispatch_queue_t lifecycleQueue;
@property (assign, nonatomic) int32_t lastCorrelationId;
+@property (strong, nonatomic) SDLLanguage currentVRLanguage;
@end
QuickConfigurationBegin(SendingRPCsConfiguration)
@@ -147,6 +151,7 @@ describe(@"a lifecycle manager", ^{
expect(testManager.rpcOperationQueue).toNot(beNil());
expect(@([testManager conformsToProtocol:@protocol(SDLConnectionManagerType)])).to(equal(@YES));
expect(testManager.authToken).to(beNil());
+ expect(testManager.currentVRLanguage).toNot(beNil());
});
itBehavesLike(@"unable to send an RPC", ^{ return @{ @"manager": testManager }; });
@@ -425,57 +430,137 @@ describe(@"a lifecycle manager", ^{
});
context(@"when the register response returns different language than the one passed with the lifecycle configuration", ^{
- beforeEach(^{
- expect(testManager.configuration.lifecycleConfig.appName).to(equal(testConfig.lifecycleConfig.appName));
- expect(testManager.configuration.lifecycleConfig.shortAppName).to(equal(testConfig.lifecycleConfig.shortAppName));
- expect(testManager.configuration.lifecycleConfig.ttsName).to(beNil());
- expect(testManager.configuration.lifecycleConfig.language).to(equal(testConfig.lifecycleConfig.language));
- expect(testManager.configuration.lifecycleConfig.languagesSupported).to(equal(testConfig.lifecycleConfig.languagesSupported));
- });
-
- it(@"should should update the configuration when the app supports the head unit language", ^{
- SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
- registerAppInterfaceResponse.success = @YES;
- registerAppInterfaceResponse.resultCode = SDLResultWrongLanguage;
- registerAppInterfaceResponse.info = @"Language mismatch";
- registerAppInterfaceResponse.language = SDLLanguageEnGb;
- testManager.registerResponse = registerAppInterfaceResponse;
-
- SDLLifecycleConfigurationUpdate *update = [[SDLLifecycleConfigurationUpdate alloc] initWithAppName:@"EnGb" shortAppName:@"E" ttsName:[SDLTTSChunk textChunksFromString:@"EnGb ttsName"] voiceRecognitionCommandNames:nil];
- OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]).andReturn(update);
-
- setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration);
- // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine
- [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO];
-
- expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnGb));
- expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"EnGb"));
- expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"E"));
- expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(equal([SDLTTSChunk textChunksFromString:@"EnGb ttsName"]));
-
- OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]);
+ context(@"using the deprecated delegate method", ^{
+ __block TestOldConfigurationUpdateManagerDelegate *oldDelegate = nil;
+ beforeEach(^{
+ oldDelegate = OCMClassMock([TestOldConfigurationUpdateManagerDelegate class]);
+ testManager.delegate = oldDelegate;
+ });
+
+ it(@"should should update the configuration when the app supports the head unit language", ^{
+ SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
+ registerAppInterfaceResponse.success = @YES;
+ registerAppInterfaceResponse.resultCode = SDLResultWrongLanguage;
+ registerAppInterfaceResponse.info = @"Language mismatch";
+ registerAppInterfaceResponse.language = SDLLanguageEnGb;
+ registerAppInterfaceResponse.hmiDisplayLanguage = SDLLanguageEnGb;
+ testManager.registerResponse = registerAppInterfaceResponse;
+
+ SDLLifecycleConfigurationUpdate *update = [[SDLLifecycleConfigurationUpdate alloc] initWithAppName:@"EnGb" shortAppName:@"E" ttsName:[SDLTTSChunk textChunksFromString:@"EnGb ttsName"] voiceRecognitionCommandNames:nil];
+ OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]).andReturn(update);
+
+ setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration);
+ // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine
+ [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO];
+
+ expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnGb));
+ expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"EnGb"));
+ expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"E"));
+ expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(equal([SDLTTSChunk textChunksFromString:@"EnGb ttsName"]));
+
+ OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]);
+ });
+
+ it(@"should not update the configuration when the app does not support the head unit language", ^{
+ SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
+ registerAppInterfaceResponse.success = @YES;
+ registerAppInterfaceResponse.resultCode = SDLResultWrongLanguage;
+ registerAppInterfaceResponse.info = @"Language mismatch";
+ registerAppInterfaceResponse.language = SDLLanguageDeDe;
+ registerAppInterfaceResponse.hmiDisplayLanguage = SDLLanguageDeDe;
+ testManager.registerResponse = registerAppInterfaceResponse;
+
+ OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]).andReturn(nil);
+
+ setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration);
+ // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine
+ [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO];
+
+ expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnUs));
+ expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"Test App"));
+ expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"Short Name"));
+ expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(beNil());
+
+ OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]);
+ });
});
- it(@"should not update the configuration when the app does not support the head unit language", ^{
- SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
- registerAppInterfaceResponse.success = @YES;
- registerAppInterfaceResponse.resultCode = SDLResultWrongLanguage;
- registerAppInterfaceResponse.info = @"Language mismatch";
- registerAppInterfaceResponse.language = SDLLanguageDeDe;
- testManager.registerResponse = registerAppInterfaceResponse;
+ context(@"using the updated delegate method", ^{
+ __block TestNewConfigurationUpdateManagerDelegate *newDelegate = nil;
+ beforeEach(^{
+ newDelegate = OCMClassMock([TestNewConfigurationUpdateManagerDelegate class]);
+ testManager.delegate = newDelegate;
+ });
+
+ it(@"should should update the configuration when the app supports the head unit language", ^{
+ SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
+ registerAppInterfaceResponse.success = @YES;
+ registerAppInterfaceResponse.resultCode = SDLResultWrongLanguage;
+ registerAppInterfaceResponse.info = @"Language mismatch";
+ registerAppInterfaceResponse.language = SDLLanguageEnGb;
+ registerAppInterfaceResponse.hmiDisplayLanguage = SDLLanguageEnGb;
+ testManager.registerResponse = registerAppInterfaceResponse;
+
+ SDLLifecycleConfigurationUpdate *update = [[SDLLifecycleConfigurationUpdate alloc] initWithAppName:@"EnGb" shortAppName:@"E" ttsName:[SDLTTSChunk textChunksFromString:@"EnGb ttsName"] voiceRecognitionCommandNames:nil];
+ OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]).andReturn(update);
+
+ setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration);
+ // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine
+ [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO];
+
+ expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnGb));
+ expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"EnGb"));
+ expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"E"));
+ expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(equal([SDLTTSChunk textChunksFromString:@"EnGb ttsName"]));
+
+ OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]);
+ });
- OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]).andReturn(nil);
+ it(@"should not update the configuration when the app does not support the head unit language", ^{
+ SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
+ registerAppInterfaceResponse.success = @YES;
+ registerAppInterfaceResponse.resultCode = SDLResultWrongLanguage;
+ registerAppInterfaceResponse.info = @"Language mismatch";
+ registerAppInterfaceResponse.language = SDLLanguageDeDe;
+ registerAppInterfaceResponse.hmiDisplayLanguage = SDLLanguageDeDe;
+ testManager.registerResponse = registerAppInterfaceResponse;
- setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration);
- // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine
- [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO];
+ OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]).andReturn(nil);
- expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnUs));
- expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"Test App"));
- expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"Short Name"));
- expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(beNil());
+ setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration);
+ // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine
+ [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO];
- OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any]]);
+ expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnUs));
+ expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"Test App"));
+ expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"Short Name"));
+ expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(beNil());
+
+ OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]);
+ });
+
+ it(@"should update if the hmi display language changes", ^{
+ SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init];
+ registerAppInterfaceResponse.success = @YES;
+ registerAppInterfaceResponse.resultCode = SDLResultWrongLanguage;
+ registerAppInterfaceResponse.info = @"Language mismatch";
+ registerAppInterfaceResponse.language = SDLLanguageEnUs;
+ registerAppInterfaceResponse.hmiDisplayLanguage = SDLLanguageEnGb;
+ testManager.registerResponse = registerAppInterfaceResponse;
+
+ OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]).andReturn(nil);
+
+ setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration);
+ // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine
+ [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO];
+
+ expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnUs));
+ expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"Test App"));
+ expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"Short Name"));
+ expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(beNil());
+
+ OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]);
+ });
});
});
});
diff --git a/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h b/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h
new file mode 100644
index 000000000..f527decea
--- /dev/null
+++ b/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h
@@ -0,0 +1,19 @@
+//
+// TestOldConfigurationUpdateManagerDelegate.h
+// SmartDeviceLinkTests
+//
+// Created by Joel Fischer on 6/4/20.
+// Copyright © 2020 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import "SDLManagerDelegate.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface TestOldConfigurationUpdateManagerDelegate : NSObject <SDLManagerDelegate>
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m b/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m
new file mode 100644
index 000000000..765df8172
--- /dev/null
+++ b/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m
@@ -0,0 +1,24 @@
+//
+// TestOldConfigurationUpdateManagerDelegate.m
+// SmartDeviceLinkTests
+//
+// Created by Joel Fischer on 6/4/20.
+// Copyright © 2020 smartdevicelink. All rights reserved.
+//
+
+#import "TestOldConfigurationUpdateManagerDelegate.h"
+
+@implementation TestOldConfigurationUpdateManagerDelegate
+
+- (void)hmiLevel:(nonnull SDLHMILevel)oldLevel didChangeToLevel:(nonnull SDLHMILevel)newLevel { }
+
+- (void)managerDidDisconnect { }
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
+- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language {
+ return nil;
+}
+#pragma mark diagnostic pop
+
+@end
diff --git a/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h b/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h
new file mode 100644
index 000000000..67e3c8948
--- /dev/null
+++ b/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h
@@ -0,0 +1,19 @@
+//
+// TestNewConfigurationUpdateManagerDelegate.h
+// SmartDeviceLinkTests
+//
+// Created by Joel Fischer on 6/4/20.
+// Copyright © 2020 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import "SDLManagerDelegate.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface TestNewConfigurationUpdateManagerDelegate : NSObject <SDLManagerDelegate>
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m b/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m
new file mode 100644
index 000000000..fee42d105
--- /dev/null
+++ b/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m
@@ -0,0 +1,21 @@
+//
+// TestNewConfigurationUpdateManagerDelegate.m
+// SmartDeviceLinkTests
+//
+// Created by Joel Fischer on 6/4/20.
+// Copyright © 2020 smartdevicelink. All rights reserved.
+//
+
+#import "TestNewConfigurationUpdateManagerDelegate.h"
+
+@implementation TestNewConfigurationUpdateManagerDelegate
+
+- (void)hmiLevel:(nonnull SDLHMILevel)oldLevel didChangeToLevel:(nonnull SDLHMILevel)newLevel { }
+
+- (void)managerDidDisconnect { }
+
+- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language hmiLanguage:(SDLLanguage)hmiLanguage {
+ return nil;
+}
+
+@end