diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-07-13 14:25:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 14:25:37 -0400 |
commit | 79cab6268016f6a3e5ea23d94789662188d6dbcd (patch) | |
tree | 50e6f8204b9f3e59ccc50dd30179bfedd353bb9b | |
parent | 093b7f5feeb0c9014d054b5c8e8f8562198bc230 (diff) | |
parent | c482fe3f06c41e0f899fa674f0a72790830f40ea (diff) | |
download | sdl_ios-79cab6268016f6a3e5ea23d94789662188d6dbcd.tar.gz |
Merge pull request #1004 from smartdevicelink/bugfix/issue_1000_softbuttons_disappear_HMI_none
Fix SoftButtons, Text, and Graphics disappearing on display layout change
-rw-r--r-- | SmartDeviceLink/SDLSoftButtonManager.m | 162 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSoftButtonObject.m | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTextAndGraphicManager.m | 96 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m | 34 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m | 4 |
5 files changed, 172 insertions, 132 deletions
diff --git a/SmartDeviceLink/SDLSoftButtonManager.m b/SmartDeviceLink/SDLSoftButtonManager.m index f65acb444..e3e9278b2 100644 --- a/SmartDeviceLink/SDLSoftButtonManager.m +++ b/SmartDeviceLink/SDLSoftButtonManager.m @@ -50,7 +50,8 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic, nullable) SDLDisplayCapabilities *displayCapabilities; @property (strong, nonatomic, nullable) SDLSoftButtonCapabilities *softButtonCapabilities; -@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToSetButtons; +@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToUpdate; +@property (assign, nonatomic) BOOL isDirty; @end @@ -65,7 +66,8 @@ NS_ASSUME_NONNULL_BEGIN _softButtonObjects = @[]; _currentLevel = nil; - _waitingOnHMILevelUpdateToSetButtons = NO; + _waitingOnHMILevelUpdateToUpdate = NO; + _isDirty = NO; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_registerResponse:) name:SDLDidReceiveRegisterAppInterfaceResponse object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_displayLayoutResponse:) name:SDLDidReceiveSetDisplayLayoutResponse object:nil]; @@ -85,14 +87,16 @@ NS_ASSUME_NONNULL_BEGIN _currentLevel = nil; _displayCapabilities = nil; _softButtonCapabilities = nil; - _waitingOnHMILevelUpdateToSetButtons = NO; + _waitingOnHMILevelUpdateToUpdate = NO; + _isDirty = NO; } - (void)setSoftButtonObjects:(NSArray<SDLSoftButtonObject *> *)softButtonObjects { - if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { - _waitingOnHMILevelUpdateToSetButtons = YES; - _softButtonObjects = softButtonObjects; + // Only update if something changed. This prevents, for example, an empty array being reset + if (_softButtonObjects == softButtonObjects) { return; + } else { + self.isDirty = YES; } self.inProgressUpdate = nil; @@ -119,57 +123,13 @@ NS_ASSUME_NONNULL_BEGIN } } - _softButtonObjects = softButtonObjects; - - for (SDLSoftButtonObject *button in _softButtonObjects) { + for (SDLSoftButtonObject *button in softButtonObjects) { button.manager = self; } - NSMutableArray<SDLArtwork *> *initialStatesToBeUploaded = [NSMutableArray array]; - NSMutableArray<SDLArtwork *> *otherStatesToBeUploaded = [NSMutableArray array]; - if (self.displayCapabilities ? self.displayCapabilities.graphicSupported.boolValue : YES) { - // Upload all soft button images, the initial state images first, then the other states. We need to send updates when the initial state is ready. - for (SDLSoftButtonObject *object in self.softButtonObjects) { - if (object.currentState.artwork != nil && ![self.fileManager hasUploadedFile:object.currentState.artwork]) { - [initialStatesToBeUploaded addObject:object.currentState.artwork]; - } - } - for (SDLSoftButtonObject *object in self.softButtonObjects) { - for (SDLSoftButtonState *state in object.states) { - if ([state.name isEqualToString:object.currentState.name]) { continue; } - if (state.artwork != nil && ![self.fileManager hasUploadedFile:state.artwork]) { - [otherStatesToBeUploaded addObject:state.artwork]; - } - } - } - } - - // Upload initial images, then other state images - if (initialStatesToBeUploaded.count > 0) { - SDLLogD(@"Uploading soft button initial artworks"); - [self.fileManager uploadArtworks:[initialStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { - if (error != nil) { - SDLLogE(@"Error uploading soft button artworks: %@", error); - } - - SDLLogD(@"Soft button initial artworks uploaded"); - [self sdl_updateWithCompletionHandler:nil]; - }]; - } - if (otherStatesToBeUploaded.count > 0) { - SDLLogD(@"Uploading soft button other state artworks"); - [self.fileManager uploadArtworks:[otherStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { - if (error != nil) { - SDLLogE(@"Error uploading soft button artworks: %@", error); - } - - SDLLogD(@"Soft button other state artworks uploaded"); - // In case our soft button states have changed in the meantime - [self sdl_updateWithCompletionHandler:nil]; - }]; - } + _softButtonObjects = softButtonObjects; - [self sdl_updateWithCompletionHandler:nil]; + [self updateWithCompletionHandler:nil]; } - (nullable SDLSoftButtonObject *)softButtonObjectNamed:(NSString *)name { @@ -182,19 +142,30 @@ NS_ASSUME_NONNULL_BEGIN return nil; } -- (void)updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { - if (self.isBatchingUpdates) { return; } - - [self sdl_updateWithCompletionHandler:handler]; +- (void)sdl_transitionSoftButton:(SDLSoftButtonObject *)softButton { + self.isDirty = YES; + [self updateWithCompletionHandler:nil]; } -- (void)sdl_updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { +- (void)updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { + // Don't send if we're batching + if (self.isBatchingUpdates || !self.isDirty) { return; } + // Don't send if we're in HMI NONE if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { + self.waitingOnHMILevelUpdateToUpdate = YES; return; + } else { + self.waitingOnHMILevelUpdateToUpdate = NO; } + [self sdl_updateWithCompletionHandler:handler]; +} + +- (void)sdl_updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { SDLLogD(@"Updating soft buttons"); + self.isDirty = NO; + if (self.inProgressUpdate != nil) { SDLLogV(@"In progress update exists, queueing update"); // If we already have a pending update, we're going to tell the old handler that it was superseded by a new update and then return @@ -217,13 +188,16 @@ NS_ASSUME_NONNULL_BEGIN self.inProgressUpdate = [[SDLShow alloc] init]; self.inProgressUpdate.mainField1 = self.currentMainField1 ?: @""; - BOOL headUnitSupportsImages = self.softButtonCapabilities ? self.softButtonCapabilities.imageSupported.boolValue : NO; + if ([self sdl_supportsSoftButtonImages]) { + [self sdl_uploadInitialStateImages]; + [self sdl_uploadOtherStateImages]; + } if (self.softButtonObjects == nil) { SDLLogV(@"Soft button objects are nil, sending an empty array"); self.inProgressUpdate.softButtons = @[]; } else if (([self sdl_currentStateHasImages] && ![self sdl_allCurrentStateImagesAreUploaded]) - || !headUnitSupportsImages) { + || ![self sdl_supportsSoftButtonImages]) { // The images don't yet exist on the head unit, or we cannot use images, send a text update, if possible. Otherwise, don't send anything yet. NSArray<SDLSoftButton *> *textOnlyButtons = [self sdl_textButtonsForCurrentState]; if (textOnlyButtons != nil) { @@ -283,6 +257,62 @@ NS_ASSUME_NONNULL_BEGIN return YES; } +- (BOOL)sdl_supportsSoftButtonImages { + BOOL supportsGraphics = self.displayCapabilities ? self.displayCapabilities.graphicSupported.boolValue : YES; + BOOL supportsSoftButtonImages = self.softButtonCapabilities ? self.softButtonCapabilities.imageSupported.boolValue : NO; + + return (supportsGraphics && supportsSoftButtonImages); +} + +- (void)sdl_uploadInitialStateImages { + NSMutableArray<SDLArtwork *> *initialStatesToBeUploaded = [NSMutableArray array]; + // Upload all soft button images, the initial state images first, then the other states. We need to send updates when the initial state is ready. + for (SDLSoftButtonObject *object in self.softButtonObjects) { + if (object.currentState.artwork != nil && ![self.fileManager hasUploadedFile:object.currentState.artwork]) { + [initialStatesToBeUploaded addObject:object.currentState.artwork]; + } + } + + // Upload initial images, then other state images + if (initialStatesToBeUploaded.count > 0) { + SDLLogD(@"Uploading soft button initial artworks"); + [self.fileManager uploadArtworks:[initialStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { + if (error != nil) { + SDLLogE(@"Error uploading soft button artworks: %@", error); + } + + SDLLogD(@"Soft button initial artworks uploaded"); + [self sdl_updateWithCompletionHandler:nil]; + }]; + } +} + +- (void)sdl_uploadOtherStateImages { + NSMutableArray<SDLArtwork *> *otherStatesToBeUploaded = [NSMutableArray array]; + // Upload all soft button images, the initial state images first, then the other states. We need to send updates when the initial state is ready. + for (SDLSoftButtonObject *object in self.softButtonObjects) { + for (SDLSoftButtonState *state in object.states) { + if ([state.name isEqualToString:object.currentState.name]) { continue; } + if (state.artwork != nil && ![self.fileManager hasUploadedFile:state.artwork]) { + [otherStatesToBeUploaded addObject:state.artwork]; + } + } + } + + if (otherStatesToBeUploaded.count > 0) { + SDLLogD(@"Uploading soft button other state artworks"); + [self.fileManager uploadArtworks:[otherStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { + if (error != nil) { + SDLLogE(@"Error uploading soft button artworks: %@", error); + } + + SDLLogD(@"Soft button other state artworks uploaded"); + // In case our soft button states have changed in the meantime + [self sdl_updateWithCompletionHandler:nil]; + }]; + } +} + #pragma mark - Creating Soft Buttons /** @@ -336,7 +366,9 @@ NS_ASSUME_NONNULL_BEGIN self.displayCapabilities = response.displayCapabilities; // Auto-send an updated Show - [self updateWithCompletionHandler:nil]; + if (self.softButtonObjects.count > 0) { + [self updateWithCompletionHandler:nil]; + } } - (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification { @@ -346,12 +378,8 @@ NS_ASSUME_NONNULL_BEGIN self.currentLevel = hmiStatus.hmiLevel; // Auto-send an updated show if we were in NONE and now we are not - if ([oldHMILevel isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone]) { - if (self.waitingOnHMILevelUpdateToSetButtons) { - [self setSoftButtonObjects:_softButtonObjects]; - } else { - [self sdl_updateWithCompletionHandler:nil]; - } + if ([oldHMILevel isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone] && self.waitingOnHMILevelUpdateToUpdate) { + [self updateWithCompletionHandler:nil]; } } diff --git a/SmartDeviceLink/SDLSoftButtonObject.m b/SmartDeviceLink/SDLSoftButtonObject.m index be7915a55..427421590 100644 --- a/SmartDeviceLink/SDLSoftButtonObject.m +++ b/SmartDeviceLink/SDLSoftButtonObject.m @@ -16,6 +16,12 @@ NS_ASSUME_NONNULL_BEGIN +@interface SDLSoftButtonManager() + +- (void)sdl_transitionSoftButton:(SDLSoftButtonObject *)softButton; + +@end + @interface SDLSoftButtonObject() @property (assign, nonatomic) NSUInteger buttonId; @@ -55,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN SDLLogD(@"Transitioning button %@ to state %@", self.name, stateName); self.currentStateName = stateName; - [self.manager updateWithCompletionHandler:nil]; + [self.manager sdl_transitionSoftButton:self]; return YES; } diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m index eadc37992..64a3a5ffb 100644 --- a/SmartDeviceLink/SDLTextAndGraphicManager.m +++ b/SmartDeviceLink/SDLTextAndGraphicManager.m @@ -54,6 +54,7 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic, nullable) SDLArtwork *blankArtwork; +@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToUpdate; @property (assign, nonatomic) BOOL isDirty; @end @@ -72,6 +73,9 @@ NS_ASSUME_NONNULL_BEGIN _currentScreenData = [[SDLShow alloc] init]; _currentLevel = SDLHMILevelNone; + _waitingOnHMILevelUpdateToUpdate = NO; + _isDirty = NO; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_registerResponse:) name:SDLDidReceiveRegisterAppInterfaceResponse object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_displayLayoutResponse:) name:SDLDidReceiveSetDisplayLayoutResponse object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_hmiStatusNotification:) name:SDLDidChangeHMIStatusNotification object:nil]; @@ -102,6 +106,7 @@ NS_ASSUME_NONNULL_BEGIN _displayCapabilities = nil; _currentLevel = SDLHMILevelNone; _blankArtwork = nil; + _waitingOnHMILevelUpdateToUpdate = NO; _isDirty = NO; } @@ -110,6 +115,14 @@ NS_ASSUME_NONNULL_BEGIN - (void)updateWithCompletionHandler:(nullable SDLTextAndGraphicUpdateCompletionHandler)handler { if (self.isBatchingUpdates) { return; } + // Don't send if we're in HMI NONE + if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { + self.waitingOnHMILevelUpdateToUpdate = YES; + return; + } else { + self.waitingOnHMILevelUpdateToUpdate = NO; + } + if (self.isDirty) { self.isDirty = NO; [self sdl_updateWithCompletionHandler:handler]; @@ -117,11 +130,6 @@ NS_ASSUME_NONNULL_BEGIN } - (void)sdl_updateWithCompletionHandler:(nullable SDLTextAndGraphicUpdateCompletionHandler)handler { - // Don't send if we're in HMI NONE - if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { - return; - } - SDLLogD(@"Updating text and graphics"); if (self.inProgressUpdate != nil) { SDLLogV(@"In progress update exists, queueing update"); @@ -487,6 +495,13 @@ NS_ASSUME_NONNULL_BEGIN return [array copy]; } +- (BOOL)sdl_hasData { + BOOL hasTextFields = ([self sdl_findNonNilTextFields].count > 0); + BOOL hasImageFields = (self.primaryGraphic != nil) || (self.secondaryGraphic != nil); + + return hasTextFields || hasImageFields; +} + #pragma mark - Equality - (BOOL)sdl_showImages:(SDLShow *)show isEqualToShowImages:(SDLShow *)show2 { @@ -507,110 +522,98 @@ NS_ASSUME_NONNULL_BEGIN - (void)setTextField1:(nullable NSString *)textField1 { _textField1 = textField1; + _isDirty = YES; if (!self.isBatchingUpdates) { // If we aren't batching, send the update immediately, if we are, set ourselves as dirty (so we know we should send an update after the batch ends) - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField2:(nullable NSString *)textField2 { _textField2 = textField2; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField3:(nullable NSString *)textField3 { _textField3 = textField3; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField4:(nullable NSString *)textField4 { _textField4 = textField4; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setMediaTrackTextField:(nullable NSString *)mediaTrackTextField { _mediaTrackTextField = mediaTrackTextField; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setPrimaryGraphic:(nullable SDLArtwork *)primaryGraphic { _primaryGraphic = primaryGraphic; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setSecondaryGraphic:(nullable SDLArtwork *)secondaryGraphic { _secondaryGraphic = secondaryGraphic; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setAlignment:(nullable SDLTextAlignment)alignment { _alignment = alignment ? alignment : SDLTextAlignmentCenter; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField1Type:(nullable SDLMetadataType)textField1Type { _textField1Type = textField1Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField2Type:(nullable SDLMetadataType)textField2Type { _textField2Type = textField2Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField3Type:(nullable SDLMetadataType)textField3Type { _textField3Type = textField3Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField4Type:(nullable SDLMetadataType)textField4Type { _textField4Type = textField4Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } @@ -644,18 +647,21 @@ NS_ASSUME_NONNULL_BEGIN self.displayCapabilities = response.displayCapabilities; // Auto-send an updated show - [self sdl_updateWithCompletionHandler:nil]; + if ([self sdl_hasData]) { + [self sdl_updateWithCompletionHandler:nil]; + } } - (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification { SDLOnHMIStatus *hmiStatus = (SDLOnHMIStatus *)notification.notification; + SDLHMILevel oldLevel = self.currentLevel; + self.currentLevel = hmiStatus.hmiLevel; + // Auto-send an updated show if we were in NONE and now we are not - if ([self.currentLevel isEqualToString:SDLHMILevelNone] && ![hmiStatus.hmiLevel isEqualToString:SDLHMILevelNone]) { + if ([oldLevel isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone] && self.waitingOnHMILevelUpdateToUpdate) { [self sdl_updateWithCompletionHandler:nil]; } - - self.currentLevel = hmiStatus.hmiLevel; } @end diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index 7eaad7142..17be53b19 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -24,23 +24,23 @@ @interface SDLSoftButtonManager() +@property (strong, nonatomic) NSArray<SDLSoftButton *> *currentSoftButtons; + @property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager; @property (weak, nonatomic) SDLFileManager *fileManager; -@property (strong, nonatomic) NSArray<SDLSoftButton *> *currentSoftButtons; - @property (strong, nonatomic, nullable) SDLShow *inProgressUpdate; @property (copy, nonatomic, nullable) SDLSoftButtonUpdateCompletionHandler inProgressHandler; -@property (strong, nonatomic, nullable) SDLShow *queuedImageUpdate; @property (assign, nonatomic) BOOL hasQueuedUpdate; @property (copy, nonatomic, nullable) SDLSoftButtonUpdateCompletionHandler queuedUpdateHandler; -@property (strong, nonatomic, nullable) SDLHMILevel currentLevel; -@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToSetButtons; +@property (copy, nonatomic, nullable) SDLHMILevel currentLevel; @property (strong, nonatomic, nullable) SDLDisplayCapabilities *displayCapabilities; @property (strong, nonatomic, nullable) SDLSoftButtonCapabilities *softButtonCapabilities; +@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToUpdate; + @end QuickSpecBegin(SDLSoftButtonManagerSpec) @@ -91,22 +91,22 @@ describe(@"a soft button manager", ^{ expect(testManager.hasQueuedUpdate).to(beFalse()); expect(testManager.displayCapabilities).to(beNil()); expect(testManager.softButtonCapabilities).to(beNil()); - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beFalse()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beFalse()); }); context(@"when in HMI NONE", ^{ beforeEach(^{ testManager.currentLevel = SDLHMILevelNone; - NSString *sameName = @"Same name"; - testObject1 = [[SDLSoftButtonObject alloc] initWithName:sameName states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; - testObject2 = [[SDLSoftButtonObject alloc] initWithName:sameName state:object2State1 handler:nil]; + testObject1 = [[SDLSoftButtonObject alloc] initWithName:@"name1" states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; + testObject2 = [[SDLSoftButtonObject alloc] initWithName:@"name2" state:object2State1 handler:nil]; testManager.softButtonObjects = @[testObject1, testObject2]; }); - it(@"should not set the soft buttons", ^{ - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beTrue()); + it(@"should set the soft buttons, but not update", ^{ + expect(testManager.softButtonObjects).toNot(beEmpty()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beTrue()); expect(testManager.inProgressUpdate).to(beNil()); }); }); @@ -115,15 +115,15 @@ describe(@"a soft button manager", ^{ beforeEach(^{ testManager.currentLevel = nil; - NSString *sameName = @"Same name"; - testObject1 = [[SDLSoftButtonObject alloc] initWithName:sameName states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; - testObject2 = [[SDLSoftButtonObject alloc] initWithName:sameName state:object2State1 handler:nil]; + testObject1 = [[SDLSoftButtonObject alloc] initWithName:@"name1" states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; + testObject2 = [[SDLSoftButtonObject alloc] initWithName:@"name2" state:object2State1 handler:nil]; testManager.softButtonObjects = @[testObject1, testObject2]; }); - it(@"should not set the soft buttons", ^{ - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beTrue()); + it(@"should set the soft buttons, but not update", ^{ + expect(testManager.softButtonObjects).toNot(beEmpty()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beTrue()); expect(testManager.inProgressUpdate).to(beNil()); }); }); @@ -359,7 +359,7 @@ describe(@"a soft button manager", ^{ expect(testManager.currentLevel).to(beNil()); expect(testManager.displayCapabilities).to(beNil()); expect(testManager.softButtonCapabilities).to(beNil()); - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beFalse()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beFalse()); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m index 5005483d0..ef5b18623 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m @@ -94,7 +94,7 @@ describe(@"text and graphic manager", ^{ expect(testManager.textField1).to(equal(testString)); expect(testManager.inProgressUpdate).to(beNil()); - expect(testManager.isDirty).to(beFalse()); + expect(testManager.isDirty).to(beTrue()); }); }); @@ -108,7 +108,7 @@ describe(@"text and graphic manager", ^{ expect(testManager.textField1).to(equal(testString)); expect(testManager.inProgressUpdate).to(beNil()); - expect(testManager.isDirty).to(beFalse()); + expect(testManager.isDirty).to(beTrue()); }); }); |