diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-02-20 11:16:57 -0500 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-02-20 11:16:57 -0500 |
commit | 089da67e74ac654d2e851565cab23de0bc58d973 (patch) | |
tree | 2da7c372471dbde8c923766af7475bd392a6ca59 | |
parent | 91d10089763785dce19c8520ecab77ee8a15cec0 (diff) | |
parent | 198f1615c20aedb4efe312efd80fce170ed88c9a (diff) | |
download | sdl_ios-feature/issue_723_sequential_send_rpcs.tar.gz |
Merge branch 'develop' into feature/issue_723_sequential_send_rpcsfeature/issue_723_sequential_send_rpcs
# Conflicts:
# SmartDeviceLink/SDLLifecycleManager.m
-rw-r--r-- | SmartDeviceLink/SDLAddCommand.h | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLAddCommand.m | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLConfiguration.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLFileManager.m | 10 | ||||
-rw-r--r-- | SmartDeviceLink/SDLIAPSession.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleConfiguration.h | 5 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleConfiguration.m | 3 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.m | 12 | ||||
-rw-r--r-- | SmartDeviceLink/SDLProxy.m | 9 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRegisterAppInterface.h | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRegisterAppInterface.m | 34 | ||||
-rw-r--r-- | SmartDeviceLink/SDLUploadFileOperation.m | 3 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m | 8 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m | 5 | ||||
-rw-r--r-- | SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m | 81 |
15 files changed, 169 insertions, 29 deletions
diff --git a/SmartDeviceLink/SDLAddCommand.h b/SmartDeviceLink/SDLAddCommand.h index 509ea80fa..f7c494df9 100644 --- a/SmartDeviceLink/SDLAddCommand.h +++ b/SmartDeviceLink/SDLAddCommand.h @@ -49,9 +49,9 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands handler:(nullable SDLRPCCommandNotificationHandler)handler; -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCCommandNotificationHandler)handler; +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(nullable SDLRPCCommandNotificationHandler)handler; -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(NSString *)iconValue iconType:(SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler; +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(nullable NSString *)iconValue iconType:(nullable SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler; /** * A handler that will let you know when the button you created is subscribed. diff --git a/SmartDeviceLink/SDLAddCommand.m b/SmartDeviceLink/SDLAddCommand.m index bfec12164..28c60219d 100644 --- a/SmartDeviceLink/SDLAddCommand.m +++ b/SmartDeviceLink/SDLAddCommand.m @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCCommandNotificationHandler)handler { +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(nullable SDLRPCCommandNotificationHandler)handler { self = [self initWithId:commandId vrCommands:vrCommands handler:handler]; if (!self) { return nil; @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(NSString *)iconValue iconType:(SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler { +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(nullable NSString *)iconValue iconType:(nullable SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler { self = [self initWithId:commandId vrCommands:vrCommands menuName:menuName handler:handler]; if (!self) { return nil; @@ -63,7 +63,9 @@ NS_ASSUME_NONNULL_BEGIN self.menuParams.parentID = @(parentId); self.menuParams.position = @(position); - self.cmdIcon = [[SDLImage alloc] initWithName:iconValue ofType:iconType]; + if (iconValue != nil && iconType != nil) { + self.cmdIcon = [[SDLImage alloc] initWithName:iconValue ofType:iconType]; + } return self; } diff --git a/SmartDeviceLink/SDLConfiguration.m b/SmartDeviceLink/SDLConfiguration.m index cbf700ba9..98fddadc1 100644 --- a/SmartDeviceLink/SDLConfiguration.m +++ b/SmartDeviceLink/SDLConfiguration.m @@ -63,11 +63,11 @@ NS_ASSUME_NONNULL_BEGIN if (_streamingMediaConfig != nil) { // If we have a streaming config, the apptype MUST be navigation or projection - NSAssert(([_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeNavigation] || [_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeProjection]), @"You should only set a streaming media configuration if your app is a NAVIGATION or PROJECTION HMI type"); + NSAssert(([_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeNavigation] || [_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeProjection] || [_lifecycleConfig.additionalAppTypes containsObject:SDLAppHMITypeNavigation] || [_lifecycleConfig.additionalAppTypes containsObject:SDLAppHMITypeProjection]), @"You should only set a streaming media configuration if your app is a NAVIGATION or PROJECTION HMI type"); _streamingMediaConfig = streamingMediaConfig; } else { // If we don't have a streaming config, we MUST NOT be navigation or projection - NSAssert(!([_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeNavigation] || [_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeProjection]), @"If your app is a NAVIGATION or PROJECTION HMI type, you must set a streaming media configuration on SDLConfiguration"); + NSAssert(!([_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeNavigation] || [_lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeProjection] || [_lifecycleConfig.additionalAppTypes containsObject:SDLAppHMITypeNavigation] || [_lifecycleConfig.additionalAppTypes containsObject:SDLAppHMITypeProjection]), @"If your app is a NAVIGATION or PROJECTION HMI type, you must set a streaming media configuration on SDLConfiguration"); } return self; diff --git a/SmartDeviceLink/SDLFileManager.m b/SmartDeviceLink/SDLFileManager.m index 25ec7aec0..8942ec2d7 100644 --- a/SmartDeviceLink/SDLFileManager.m +++ b/SmartDeviceLink/SDLFileManager.m @@ -40,12 +40,13 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; @property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager; // Remote state -@property (strong, nonatomic, readwrite) NSMutableSet<SDLFileName *> *mutableRemoteFileNames; +@property (strong, nonatomic) NSMutableSet<SDLFileName *> *mutableRemoteFileNames; @property (assign, nonatomic, readwrite) NSUInteger bytesAvailable; // Local state @property (strong, nonatomic) NSOperationQueue *transactionQueue; @property (strong, nonatomic) NSMutableDictionary<SDLFileName *, NSOperation *> *uploadsInProgress; +@property (strong, nonatomic) NSMutableSet<SDLFileName *> *uploadedEphemeralFileNames; @property (strong, nonatomic) SDLStateMachine *stateMachine; @property (copy, nonatomic, nullable) SDLFileManagerStartupCompletionHandler startupCompletionHandler; @@ -71,6 +72,7 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; _transactionQueue.name = @"SDLFileManager Transaction Queue"; _transactionQueue.maxConcurrentOperationCount = 1; _uploadsInProgress = [[NSMutableDictionary alloc] init]; + _uploadedEphemeralFileNames = [[NSMutableSet<SDLFileName *> alloc] init]; _stateMachine = [[SDLStateMachine alloc] initWithTarget:self initialState:SDLFileManagerStateShutdown states:[self.class sdl_stateTransitionDictionary]]; @@ -272,6 +274,11 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; for(SDLFile *file in files) { dispatch_group_enter(uploadFilesTask); + // HAX: [#827](https://github.com/smartdevicelink/sdl_ios/issues/827) Older versions of Core had a bug where list files would cache incorrectly. This led to attempted uploads failing due to the system thinking they were already there when they were not. + if (!file.persistent && [self.remoteFileNames containsObject:file.name] && ![self.uploadedEphemeralFileNames containsObject:file.name]) { + file.overwrite = true; + } + [self uploadFile:file completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { if(!success) { failedUploads[file.name] = error; @@ -383,6 +390,7 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; } if (success) { [weakSelf.mutableRemoteFileNames addObject:fileName]; + [weakSelf.uploadedEphemeralFileNames addObject:fileName]; } if (uploadCompletion != nil) { uploadCompletion(success, bytesAvailable, error); diff --git a/SmartDeviceLink/SDLIAPSession.m b/SmartDeviceLink/SDLIAPSession.m index 33a7cf1f1..47047ece9 100644 --- a/SmartDeviceLink/SDLIAPSession.m +++ b/SmartDeviceLink/SDLIAPSession.m @@ -125,6 +125,10 @@ NSTimeInterval const StreamThreadWaitSecs = 1.0; - (void)sdl_dequeueAndWriteToOutputStream { NSOutputStream *ostream = self.easession.outputStream; + if (!ostream.hasSpaceAvailable) { + return; + } + NSMutableData *remainder = [self.sendDataQueue frontBuffer]; if (remainder != nil && ostream.streamStatus == NSStreamStatusOpen) { diff --git a/SmartDeviceLink/SDLLifecycleConfiguration.h b/SmartDeviceLink/SDLLifecycleConfiguration.h index 57c0470ac..8c79039e0 100644 --- a/SmartDeviceLink/SDLLifecycleConfiguration.h +++ b/SmartDeviceLink/SDLLifecycleConfiguration.h @@ -87,6 +87,11 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic, null_resettable) SDLAppHMIType appType; /** + Additional application types beyond `appType` + */ +@property (copy, nonatomic, nullable) NSArray<SDLAppHMIType> *additionalAppTypes; + +/** * The default language to use */ @property (strong, nonatomic) SDLLanguage language; diff --git a/SmartDeviceLink/SDLLifecycleConfiguration.m b/SmartDeviceLink/SDLLifecycleConfiguration.m index c5b9e7071..d14f0b01b 100644 --- a/SmartDeviceLink/SDLLifecycleConfiguration.m +++ b/SmartDeviceLink/SDLLifecycleConfiguration.m @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Computed Properties - (BOOL)isMedia { - if ([self.appType isEqualToEnum:SDLAppHMITypeMedia]) { + if ([self.appType isEqualToEnum:SDLAppHMITypeMedia] || [self.additionalAppTypes containsObject:SDLAppHMITypeMedia]) { return YES; } @@ -102,6 +102,7 @@ NS_ASSUME_NONNULL_BEGIN newConfig->_tcpDebugIPAddress = _tcpDebugIPAddress; newConfig->_tcpDebugPort = _tcpDebugPort; newConfig->_appType = _appType; + newConfig->_additionalAppTypes = _additionalAppTypes; newConfig->_language = _language; newConfig->_languagesSupported = _languagesSupported; newConfig->_appIcon = _appIcon; diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m index e2ad6291b..22eb77da3 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -118,8 +118,10 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; _permissionManager = [[SDLPermissionManager alloc] init]; _lockScreenManager = [[SDLLockScreenManager alloc] initWithConfiguration:_configuration.lockScreenConfig notificationDispatcher:_notificationDispatcher presenter:[[SDLLockScreenPresenter alloc] init]]; - if ([configuration.lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeNavigation] - || [configuration.lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeProjection]) { + if ([configuration.lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeNavigation] || + [configuration.lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeProjection] || + [configuration.lifecycleConfig.additionalAppTypes containsObject:SDLAppHMITypeNavigation] || + [configuration.lifecycleConfig.additionalAppTypes containsObject:SDLAppHMITypeProjection]) { _streamManager = [[SDLStreamingMediaManager alloc] initWithConnectionManager:self configuration:configuration.streamingMediaConfig]; } else { SDLLogV(@"Skipping StreamingMediaManager setup due to app type"); @@ -358,6 +360,11 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; // Send the hmi level going from NONE to whatever we're at now (could still be NONE) dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate hmiLevel:SDLHMILevelNone didChangeToLevel:self.hmiLevel]; + + // Send the audio streaming state going from NOT_AUDIBLE to whatever we're at now (could still be NOT_AUDIBLE) + if ([self.delegate respondsToSelector:@selector(audioStreamingState:didChangeToState:)]) { + [self.delegate audioStreamingState:SDLAudioStreamingStateNotAudible didChangeToState:self.audioStreamingState]; + } }); } @@ -547,6 +554,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; self.systemContext = hmiStatusNotification.systemContext; SDLLogD(@"HMI level changed from %@ to %@", oldHMILevel, self.hmiLevel); + SDLLogD(@"Audio streaming state changed from %@ to %@", oldStreamingState, self.audioStreamingState); if ([self.lifecycleStateMachine isCurrentState:SDLLifecycleStateSettingUpHMI]) { [self.lifecycleStateMachine transitionToState:SDLLifecycleStateReady]; diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m index 30e96c354..24301c412 100644 --- a/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink/SDLProxy.m @@ -119,6 +119,12 @@ static float DefaultConnectionTimeout = 45.0; #pragma mark - Application Lifecycle - (void)sendMobileHMIState { + dispatch_async(dispatch_get_main_queue(), ^{ + [self sdl_sendMobileHMIState]; + }); +} + +- (void)sdl_sendMobileHMIState { UIApplicationState appState = [UIApplication sharedApplication].applicationState; SDLOnHMIStatus *HMIStatusRPC = [[SDLOnHMIStatus alloc] init]; @@ -133,8 +139,7 @@ static float DefaultConnectionTimeout = 45.0; case UIApplicationStateInactive: { HMIStatusRPC.hmiLevel = SDLHMILevelBackground; } break; - default: - break; + default: break; } SDLLogD(@"Mobile UIApplication state changed, sending to remote system: %@", HMIStatusRPC.hmiLevel); diff --git a/SmartDeviceLink/SDLRegisterAppInterface.h b/SmartDeviceLink/SDLRegisterAppInterface.h index 6201dfbfe..c86e23532 100644 --- a/SmartDeviceLink/SDLRegisterAppInterface.h +++ b/SmartDeviceLink/SDLRegisterAppInterface.h @@ -92,9 +92,13 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired; -- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appType:(SDLAppHMIType)appType shortAppName:(nullable NSString *)shortAppName; +- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appType:(SDLAppHMIType)appType shortAppName:(nullable NSString *)shortAppName __deprecated_msg(("use initWithAppName:appId:languageDesired:isMediaApp:appTypes:shortAppName:")); -- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appType:(SDLAppHMIType)appType shortAppName:(nullable NSString *)shortAppName ttsName:(nullable NSArray<SDLTTSChunk *> *)ttsName vrSynonyms:(nullable NSArray<NSString *> *)vrSynonyms hmiDisplayLanguageDesired:(SDLLanguage)hmiDisplayLanguageDesired resumeHash:(nullable NSString *)resumeHash; +- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appTypes:(NSArray<SDLAppHMIType> *)appTypes shortAppName:(nullable NSString *)shortAppName; + +- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appType:(SDLAppHMIType)appType shortAppName:(nullable NSString *)shortAppName ttsName:(nullable NSArray<SDLTTSChunk *> *)ttsName vrSynonyms:(nullable NSArray<NSString *> *)vrSynonyms hmiDisplayLanguageDesired:(SDLLanguage)hmiDisplayLanguageDesired resumeHash:(nullable NSString *)resumeHash __deprecated_msg(("use initWithAppName:appId:languageDesired:isMediaApp:appTypes:shortAppName:ttsName:vrSynonyms:hmiDisplayLanguageDesired:resumeHash:")); + +- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appTypes:(NSArray<SDLAppHMIType> *)appTypes shortAppName:(nullable NSString *)shortAppName ttsName:(nullable NSArray<SDLTTSChunk *> *)ttsName vrSynonyms:(nullable NSArray<NSString *> *)vrSynonyms hmiDisplayLanguageDesired:(SDLLanguage)hmiDisplayLanguageDesired resumeHash:(nullable NSString *)resumeHash; /** * @abstract The version of the SDL interface diff --git a/SmartDeviceLink/SDLRegisterAppInterface.m b/SmartDeviceLink/SDLRegisterAppInterface.m index 12aab2283..6729176d2 100644 --- a/SmartDeviceLink/SDLRegisterAppInterface.m +++ b/SmartDeviceLink/SDLRegisterAppInterface.m @@ -25,7 +25,18 @@ NS_ASSUME_NONNULL_BEGIN } - (instancetype)initWithLifecycleConfiguration:(SDLLifecycleConfiguration *)lifecycleConfiguration { - return [self initWithAppName:lifecycleConfiguration.appName appId:lifecycleConfiguration.appId languageDesired:lifecycleConfiguration.language isMediaApp:lifecycleConfiguration.isMedia appType:lifecycleConfiguration.appType shortAppName:lifecycleConfiguration.shortAppName ttsName:lifecycleConfiguration.ttsName vrSynonyms:lifecycleConfiguration.voiceRecognitionCommandNames hmiDisplayLanguageDesired:lifecycleConfiguration.language resumeHash:lifecycleConfiguration.resumeHash]; + NSArray<SDLAppHMIType> *allHMITypes = [lifecycleConfiguration.additionalAppTypes arrayByAddingObject:lifecycleConfiguration.appType]; + + return [self initWithAppName:lifecycleConfiguration.appName + appId:lifecycleConfiguration.appId + languageDesired:lifecycleConfiguration.language + isMediaApp:lifecycleConfiguration.isMedia + appTypes:allHMITypes + shortAppName:lifecycleConfiguration.shortAppName + ttsName:lifecycleConfiguration.ttsName + vrSynonyms:lifecycleConfiguration.voiceRecognitionCommandNames + hmiDisplayLanguageDesired:lifecycleConfiguration.language + resumeHash:lifecycleConfiguration.resumeHash]; } - (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired { @@ -44,28 +55,31 @@ NS_ASSUME_NONNULL_BEGIN self.correlationID = @1; return self; - } - (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appType:(SDLAppHMIType)appType shortAppName:(nullable NSString *)shortAppName { + return [self initWithAppName:appName appId:appId languageDesired:languageDesired isMediaApp:isMediaApp appTypes:@[appType] shortAppName:shortAppName]; +} + +- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appTypes:(NSArray<SDLAppHMIType> *)appTypes shortAppName:(nullable NSString *)shortAppName { self = [self initWithAppName:appName appId:appId languageDesired:languageDesired]; if (!self) { return nil; } - - self.isMediaApplication = @(isMediaApp); - if (appType != nil) { - self.appHMIType = [NSArray arrayWithObject:appType]; - } - + self.isMediaApplication = @(isMediaApp); + self.appHMIType = appTypes; self.ngnMediaScreenAppName = shortAppName; - + return self; } - (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appType:(SDLAppHMIType)appType shortAppName:(nullable NSString *)shortAppName ttsName:(nullable NSArray<SDLTTSChunk *> *)ttsName vrSynonyms:(nullable NSArray<NSString *> *)vrSynonyms hmiDisplayLanguageDesired:(SDLLanguage)hmiDisplayLanguageDesired resumeHash:(nullable NSString *)resumeHash { - self = [self initWithAppName:appName appId:appId languageDesired:languageDesired isMediaApp:isMediaApp appType:appType shortAppName:shortAppName]; + return [self initWithAppName:appName appId:appId languageDesired:languageDesired isMediaApp:isMediaApp appTypes:@[appType] shortAppName:shortAppName ttsName:ttsName vrSynonyms:vrSynonyms hmiDisplayLanguageDesired:hmiDisplayLanguageDesired resumeHash:resumeHash]; +} + +- (instancetype)initWithAppName:(NSString *)appName appId:(NSString *)appId languageDesired:(SDLLanguage)languageDesired isMediaApp:(BOOL)isMediaApp appTypes:(NSArray<SDLAppHMIType> *)appTypes shortAppName:(nullable NSString *)shortAppName ttsName:(nullable NSArray<SDLTTSChunk *> *)ttsName vrSynonyms:(nullable NSArray<NSString *> *)vrSynonyms hmiDisplayLanguageDesired:(SDLLanguage)hmiDisplayLanguageDesired resumeHash:(nullable NSString *)resumeHash { + self = [self initWithAppName:appName appId:appId languageDesired:languageDesired isMediaApp:isMediaApp appTypes:appTypes shortAppName:shortAppName]; if (!self) { return nil; } diff --git a/SmartDeviceLink/SDLUploadFileOperation.m b/SmartDeviceLink/SDLUploadFileOperation.m index efc62b0a0..a084bd16a 100644 --- a/SmartDeviceLink/SDLUploadFileOperation.m +++ b/SmartDeviceLink/SDLUploadFileOperation.m @@ -70,10 +70,12 @@ NS_ASSUME_NONNULL_BEGIN __block NSInteger highestCorrelationIDReceived = -1; if (self.isCancelled) { + [self finishOperation]; return completion(NO, bytesAvailable, [NSError sdl_fileManager_fileUploadCanceled]); } if (file == nil) { + [self finishOperation]; return completion(NO, bytesAvailable, [NSError sdl_fileManager_fileDoesNotExistError]); } @@ -81,6 +83,7 @@ NS_ASSUME_NONNULL_BEGIN if (self.inputStream == nil || ![self.inputStream hasBytesAvailable]) { // If the file does not exist or the passed data is nil, return an error [self sdl_closeInputStream]; + [self finishOperation]; return completion(NO, bytesAvailable, [NSError sdl_fileManager_fileDoesNotExistError]); } diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m index a27b6d6da..9a582b54b 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m @@ -25,6 +25,7 @@ SDLFileManagerState *const SDLFileManagerStateReady = @"Ready"; @interface SDLFileManager () @property (strong, nonatomic) NSOperationQueue *transactionQueue; +@property (strong, nonatomic) NSMutableSet<SDLFileName *> *uploadedEphemeralFileNames; @end QuickSpecBegin(SDLFileManagerSpec) @@ -225,6 +226,7 @@ describe(@"SDLFileManager", ^{ it(@"should set the file manager state to be waiting", ^{ expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + expect(testFileManager.uploadedEphemeralFileNames).to(beEmpty()); }); it(@"should create a putfile with the correct data", ^{ @@ -253,6 +255,7 @@ describe(@"SDLFileManager", ^{ expect(@(testFileManager.bytesAvailable)).toEventually(equal(testResponseBytesAvailable)); expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady)); expect(testFileManager.remoteFileNames).toEventually(contain(testFileName)); + expect(testFileManager.uploadedEphemeralFileNames).toEventually(contain(testFileName)); }); it(@"should call the completion handler with the correct data", ^{ @@ -282,6 +285,7 @@ describe(@"SDLFileManager", ^{ expect(@(testFileManager.bytesAvailable)).toEventually(equal(@(initialSpaceAvailable))); expect(testFileManager.remoteFileNames).toEventually(contain(testFileName)); expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady)); + expect(testFileManager.uploadedEphemeralFileNames).to(beEmpty()); }); it(@"should call the completion handler with the correct data", ^{ @@ -307,7 +311,7 @@ describe(@"SDLFileManager", ^{ }); }); - context(@"when allow overwrite is false", ^{ + context(@"when allow overwrite is NO", ^{ __block SDLRPCRequest *lastRequest = nil; beforeEach(^{ @@ -373,6 +377,7 @@ describe(@"SDLFileManager", ^{ it(@"should set the file manager state correctly", ^{ expect(@(testFileManager.bytesAvailable)).toEventually(equal(testResponseBytesAvailable)); expect(testFileManager.remoteFileNames).toEventually(contain(testFileName)); + expect(testFileManager.uploadedEphemeralFileNames).toEventually(contain(testUploadFile.name)); expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady)); }); @@ -404,6 +409,7 @@ describe(@"SDLFileManager", ^{ it(@"should set the file manager state correctly", ^{ expect(@(testFileManager.bytesAvailable)).toEventually(equal(@(initialSpaceAvailable))); expect(testFileManager.remoteFileNames).toEventuallyNot(contain(testFileName)); + expect(testFileManager.uploadedEphemeralFileNames).toEventuallyNot(contain(testUploadFile.name)); expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady)); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m index 16be756f0..117d7e0ca 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m @@ -30,6 +30,7 @@ describe(@"a lifecycle configuration", ^{ expect(testConfig.tcpDebugIPAddress).to(match(@"192.168.0.1")); expect(@(testConfig.tcpDebugPort)).to(equal(@12345)); expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeDefault])).to(equal(@YES)); + expect(testConfig.additionalAppTypes).to(beNil()); expect(@(testConfig.isMedia)).to(beFalsy()); expect(@([testConfig.language isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); expect(@([[testConfig.languagesSupported firstObject] isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); @@ -57,6 +58,7 @@ describe(@"a lifecycle configuration", ^{ someResumeHashString = @"testing"; testConfig.appType = SDLAppHMITypeMedia; + testConfig.additionalAppTypes = @[SDLAppHMITypeProjection]; testConfig.language = SDLLanguageArSa; testConfig.languagesSupported = @[SDLLanguageArSa, SDLLanguageEnAu, SDLLanguageEnUs]; testConfig.shortAppName = someShortAppName; @@ -72,6 +74,7 @@ describe(@"a lifecycle configuration", ^{ expect(testConfig.tcpDebugIPAddress).to(match(@"192.168.0.1")); expect(@(testConfig.tcpDebugPort)).to(equal(@12345)); expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeMedia])).to(equal(@YES)); + expect(testConfig.additionalAppTypes.firstObject).to(match(SDLAppHMITypeProjection)); expect(@(testConfig.isMedia)).to(beTruthy()); expect(@([testConfig.language isEqualToEnum:SDLLanguageArSa])).to(equal(@YES)); expect(testConfig.languagesSupported).to(haveCount(@3)); @@ -106,6 +109,7 @@ describe(@"a lifecycle configuration", ^{ expect(testConfig.tcpDebugIPAddress).to(match(someIPAddress)); expect(@(testConfig.tcpDebugPort)).to(equal(@(somePort))); expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeDefault])).to(equal(@YES)); + expect(testConfig.additionalAppTypes).to(beNil()); expect(@([testConfig.language isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); expect(@([[testConfig.languagesSupported firstObject] isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); expect(testConfig.shortAppName).to(beNil()); @@ -146,6 +150,7 @@ describe(@"a lifecycle configuration", ^{ expect(testConfig.tcpDebugIPAddress).to(match(someIPAddress)); expect(@(testConfig.tcpDebugPort)).to(equal(@(somePort))); expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeMedia])).to(equal(@YES)); + expect(testConfig.additionalAppTypes).to(beNil()); expect(@(testConfig.isMedia)).to(beTruthy()); expect(@([testConfig.language isEqualToEnum:SDLLanguageArSa])).to(equal(@YES)); expect(testConfig.languagesSupported).to(haveCount(@3)); diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m index 0119291d9..919932f18 100644 --- a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m @@ -15,10 +15,10 @@ QuickSpecBegin(SDLAddCommandSpec) -SDLMenuParams* menu = [[SDLMenuParams alloc] init]; -SDLImage* image = [[SDLImage alloc] init]; - describe(@"Getter/Setter Tests", ^ { + SDLMenuParams* menu = [[SDLMenuParams alloc] init]; + SDLImage* image = [[SDLImage alloc] init]; + it(@"Should set and get correctly", ^ { SDLAddCommand* testRequest = [[SDLAddCommand alloc] init]; @@ -60,4 +60,79 @@ describe(@"Getter/Setter Tests", ^ { }); }); +describe(@"initializers", ^{ + __block SDLAddCommand *testCommand = nil; + __block UInt32 commandId = 1234; + __block NSArray<NSString *> *vrCommands = @[@"commands"]; + __block NSString *menuName = @"Menu Name"; + void (^handler)(SDLOnCommand *) = ^(SDLOnCommand *command) {}; + + beforeEach(^{ + testCommand = nil; + }); + + context(@"initWithHandler", ^{ + it(@"should initialize correctly", ^{ + testCommand = [[SDLAddCommand alloc] initWithHandler:handler]; + + expect(testCommand).toNot(beNil()); + expect(testCommand.vrCommands).to(beNil()); + expect(testCommand.menuParams).to(beNil()); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); + + context(@"initWithId:vrCommands:handler:", ^{ + it(@"should initialize correctly", ^{ + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams).to(beNil()); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); + + context(@"initWithId:vrCommands:menuName:handler:", ^{ + it(@"should initialize correctly", ^{ + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands menuName:menuName handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams).toNot(beNil()); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); + + context(@"initWithId:vrCommands:menuName:parentId:position:iconValue:iconType:handler:", ^{ + __block UInt32 parentId = 1234; + __block UInt16 position = 2; + + it(@"should initialize with an image", ^{ + NSString *iconValue = @"Icon"; + SDLImageType imageType = SDLImageTypeDynamic; + + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands menuName:menuName parentId:parentId position:position iconValue:iconValue iconType:imageType handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams.menuName).toNot(beNil()); + expect(testCommand.menuParams.parentID).to(equal(parentId)); + expect(testCommand.menuParams.position).to(equal(position)); + expect(testCommand.cmdIcon).toNot(beNil()); + }); + + it(@"should initialize without an image", ^{ + testCommand = [[SDLAddCommand alloc] initWithId:commandId vrCommands:vrCommands menuName:menuName parentId:parentId position:position iconValue:nil iconType:nil handler:nil]; + + expect(testCommand.cmdID).to(equal(commandId)); + expect(testCommand.vrCommands).to(equal(vrCommands)); + expect(testCommand.menuParams.menuName).toNot(beNil()); + expect(testCommand.menuParams.parentID).to(equal(parentId)); + expect(testCommand.menuParams.position).to(equal(position)); + expect(testCommand.cmdIcon).to(beNil()); + }); + }); +}); + QuickSpecEnd |