diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2021-11-19 11:46:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 11:46:01 -0500 |
commit | 312c588441da000e4fe076148f8260354d59ed2c (patch) | |
tree | 14b44a863784b9a2aa9cd39a3e3067dc5510c61e | |
parent | bc3054b4d8dea08326d2054bef6055aeb0bc5fff (diff) | |
parent | db417c5993d6a3ee75f6302c88f0dac253f405f6 (diff) | |
download | sdl_ios-312c588441da000e4fe076148f8260354d59ed2c.tar.gz |
Merge pull request #2056 from smartdevicelink/bugfix/issue-2047-menu-manager-cell-image-rpc-5.0-to-7.0
Fix never upload AddSubmenu RPC (menu cell w/ subcells) primary image on RPC connections v5.0 - v7.0
9 files changed, 177 insertions, 62 deletions
diff --git a/SmartDeviceLink/private/SDLImageField+ScreenManagerExtensions.m b/SmartDeviceLink/private/SDLImageField+ScreenManagerExtensions.m index 1c7cc09c1..bc1c42d15 100644 --- a/SmartDeviceLink/private/SDLImageField+ScreenManagerExtensions.m +++ b/SmartDeviceLink/private/SDLImageField+ScreenManagerExtensions.m @@ -11,7 +11,24 @@ @implementation SDLImageField (ScreenManagerExtensions) + (NSArray<SDLImageFieldName> *)sdl_allImageFieldNames { - return @[SDLImageFieldNameAppIcon, SDLImageFieldNameGraphic, SDLImageFieldNameMenuIcon, SDLImageFieldNameTurnIcon, SDLImageFieldNameAlertIcon, SDLImageFieldNameChoiceImage, SDLImageFieldNameCommandIcon, SDLImageFieldNameLocationImage, SDLImageFieldNameSoftButtonImage, SDLImageFieldNameSecondaryGraphic, SDLImageFieldNameShowConstantTBTIcon, SDLImageFieldNameChoiceSecondaryImage, SDLImageFieldNameVoiceRecognitionHelpItem, SDLImageFieldNameShowConstantTBTNextTurnIcon]; + return @[SDLImageFieldNameAlertIcon, + SDLImageFieldNameAppIcon, + SDLImageFieldNameChoiceImage, + SDLImageFieldNameChoiceSecondaryImage, + SDLImageFieldNameCommandIcon, + SDLImageFieldNameGraphic, + SDLImageFieldNameLocationImage, + SDLImageFieldNameMenuCommandSecondaryImage, + SDLImageFieldNameMenuIcon, + SDLImageFieldNameMenuSubMenuSecondaryImage, + SDLImageFieldNameSecondaryGraphic, + SDLImageFieldNameShowConstantTBTIcon, + SDLImageFieldNameShowConstantTBTNextTurnIcon, + SDLImageFieldNameSoftButtonImage, + SDLImageFieldNameSubMenuIcon, + SDLImageFieldNameSubtleAlertIcon, + SDLImageFieldNameTurnIcon, + SDLImageFieldNameVoiceRecognitionHelpItem]; } + (NSArray<SDLFileType> *)sdl_allImageFileTypes { diff --git a/SmartDeviceLink/private/SDLMenuReplaceOperation.m b/SmartDeviceLink/private/SDLMenuReplaceOperation.m index 8f656c8a5..93d92cc75 100644 --- a/SmartDeviceLink/private/SDLMenuReplaceOperation.m +++ b/SmartDeviceLink/private/SDLMenuReplaceOperation.m @@ -341,10 +341,12 @@ NS_ASSUME_NONNULL_BEGIN // Strip away fields that cannot be used to determine uniqueness visually including fields not supported by the HMI cell.voiceCommands = nil; - // Don't check SDLImageFieldNameSubMenuIcon because it was added in 7.0 when the feature was added in 5.0. Just assume that if CommandIcon is not available, the submenu icon is not either. - if (![windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]) { + if (![SDLMenuReplaceUtilities windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell]) { cell.icon = nil; } + if (![SDLMenuReplaceUtilities windowCapabilitySupportsSecondaryImage:windowCapability forCell:cell]) { + cell.secondaryArtwork = nil; + } if (cell.subCells != nil) { if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuSubMenuSecondaryText]) { @@ -353,9 +355,6 @@ NS_ASSUME_NONNULL_BEGIN if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuSubMenuTertiaryText]) { cell.tertiaryText = nil; } - if (![windowCapability hasImageFieldOfName:SDLImageFieldNameMenuSubMenuSecondaryImage]) { - cell.secondaryArtwork = nil; - } cell.subCells = [self sdl_cellsWithRemovedPropertiesFromCells:cell.subCells basedOnWindowCapability:windowCapability]; } else { if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuCommandSecondaryText]) { @@ -364,9 +363,6 @@ NS_ASSUME_NONNULL_BEGIN if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuCommandTertiaryText]) { cell.tertiaryText = nil; } - if (![windowCapability hasImageFieldOfName:SDLImageFieldNameMenuCommandSecondaryImage]) { - cell.secondaryArtwork = nil; - } } } diff --git a/SmartDeviceLink/private/SDLMenuReplaceUtilities.h b/SmartDeviceLink/private/SDLMenuReplaceUtilities.h index 4488d0d4b..42216eb42 100644 --- a/SmartDeviceLink/private/SDLMenuReplaceUtilities.h +++ b/SmartDeviceLink/private/SDLMenuReplaceUtilities.h @@ -37,6 +37,16 @@ NS_ASSUME_NONNULL_BEGIN /// @param windowCapability The window capability to check available image fields + (NSArray<SDLArtwork *> *)findAllArtworksToBeUploadedFromCells:(NSArray<SDLMenuCell *> *)cells fileManager:(SDLFileManager *)fileManager windowCapability:(SDLWindowCapability *)windowCapability; +/// Whether or not a given window capability supports the primary image for a given cell +/// @param windowCapability The window capability to use for the comparison +/// @param cell The cell to use for the comparison ++ (BOOL)windowCapabilitySupportsPrimaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell; + +/// Whether or not a given window capability supports the secondary image for a given cell +/// @param windowCapability The window capability to use for the comparison +/// @param cell The cell to use for the comparison ++ (BOOL)windowCapabilitySupportsSecondaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell; + #pragma mark - RPC Commands /// Finds and returns the command id for a given RPC request, assuming that request is an SDLDeleteSubMenu, SDLDeleteCommand, SDLAddSubMenu, or SDLAddCommand diff --git a/SmartDeviceLink/private/SDLMenuReplaceUtilities.m b/SmartDeviceLink/private/SDLMenuReplaceUtilities.m index 4977a4794..f42c2b995 100644 --- a/SmartDeviceLink/private/SDLMenuReplaceUtilities.m +++ b/SmartDeviceLink/private/SDLMenuReplaceUtilities.m @@ -14,12 +14,14 @@ #import "SDLDeleteCommand.h" #import "SDLDeleteSubMenu.h" #import "SDLFileManager.h" +#import "SDLGlobals.h" #import "SDLImage.h" #import "SDLImageFieldName.h" #import "SDLMenuCell.h" #import "SDLMenuParams.h" #import "SDLMenuManagerPrivateConstants.h" #import "SDLRPCRequest.h" +#import "SDLVersion.h" #import "SDLWindowCapability.h" #import "SDLWindowCapability+ScreenManagerExtensions.h" @@ -96,11 +98,15 @@ static UInt32 _menuId = 0; NSMutableSet<SDLArtwork *> *mutableArtworks = [NSMutableSet set]; for (SDLMenuCell *cell in cells) { - if ((cell.icon != nil) && [fileManager fileNeedsUpload:cell.icon]) { + if ((cell.icon != nil) + && [self windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell] + && [fileManager fileNeedsUpload:cell.icon]) { [mutableArtworks addObject:cell.icon]; } - if ((cell.secondaryArtwork != nil) && [fileManager fileNeedsUpload:cell.secondaryArtwork]) { + if ((cell.secondaryArtwork != nil) + && [self windowCapabilitySupportsSecondaryImage:windowCapability forCell:cell] + && [fileManager fileNeedsUpload:cell.secondaryArtwork]) { [mutableArtworks addObject:cell.secondaryArtwork]; } @@ -112,16 +118,35 @@ static UInt32 _menuId = 0; return [mutableArtworks allObjects]; } ++ (BOOL)windowCapabilitySupportsPrimaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell { + BOOL supportsImage = NO; + if (cell.subCells != nil) { + if ([[SDLGlobals sharedGlobals].rpcVersion isGreaterThanOrEqualToVersion:[SDLVersion versionWithMajor:5 minor:0 patch:0]] + && [[SDLGlobals sharedGlobals].rpcVersion isLessThanVersion:[SDLVersion versionWithMajor:7 minor:0 patch:0]] + && [windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]) { + supportsImage = YES; + } else { + supportsImage = [windowCapability hasImageFieldOfName:SDLImageFieldNameSubMenuIcon]; + } + } else { + supportsImage = [windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]; + } + + return supportsImage; +} + ++ (BOOL)windowCapabilitySupportsSecondaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell { + return (cell.subCells != nil) ? [windowCapability hasImageFieldOfName:SDLImageFieldNameMenuSubMenuSecondaryImage] : [windowCapability hasImageFieldOfName:SDLImageFieldNameMenuCommandSecondaryImage]; +} + /// If there is an icon and the icon has been uploaded, or if the icon is a static icon, it should include the image + (BOOL)sdl_shouldCellIncludePrimaryImageFromCell:(SDLMenuCell *)cell fileManager:(SDLFileManager *)fileManager windowCapability:(SDLWindowCapability *)windowCapability { - BOOL supportsImage = (cell.subCells != nil) ? [windowCapability hasImageFieldOfName:SDLImageFieldNameSubMenuIcon] : [windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]; - return (cell.icon != nil) && supportsImage && ([fileManager hasUploadedFile:cell.icon] || cell.icon.isStaticIcon); + return (cell.icon != nil) && [self windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell] && ([fileManager hasUploadedFile:cell.icon] || cell.icon.isStaticIcon); } /// If there is an icon and the icon has been uploaded, or if the icon is a static icon, it should include the image + (BOOL)sdl_shouldCellIncludeSecondaryImageFromCell:(SDLMenuCell *)cell fileManager:(SDLFileManager *)fileManager windowCapability:(SDLWindowCapability *)windowCapability { - BOOL supportsImage = (cell.subCells != nil) ? [windowCapability hasImageFieldOfName:SDLImageFieldNameMenuSubMenuSecondaryImage] : [windowCapability hasImageFieldOfName:SDLImageFieldNameMenuCommandSecondaryImage]; - return (cell.secondaryArtwork != nil) && supportsImage && ([fileManager hasUploadedFile:cell.secondaryArtwork] || cell.secondaryArtwork.isStaticIcon); + return (cell.secondaryArtwork != nil) && [self windowCapabilitySupportsSecondaryImage:windowCapability forCell:cell] && ([fileManager hasUploadedFile:cell.secondaryArtwork] || cell.secondaryArtwork.isStaticIcon); } #pragma mark - RPC Commands diff --git a/SmartDeviceLink/private/SDLTextField+ScreenManagerExtensions.m b/SmartDeviceLink/private/SDLTextField+ScreenManagerExtensions.m index 3086e67e9..cf632d3d9 100644 --- a/SmartDeviceLink/private/SDLTextField+ScreenManagerExtensions.m +++ b/SmartDeviceLink/private/SDLTextField+ScreenManagerExtensions.m @@ -13,7 +13,44 @@ + (NSArray<SDLTextFieldName> *)sdl_allTextFieldNames { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - return @[SDLTextFieldNameETA, SDLTextFieldNameMenuName, SDLTextFieldNameMenuTitle, SDLTextFieldNameStatusBar, SDLTextFieldNameAlertText1, SDLTextFieldNameAlertText2, SDLTextFieldNameAlertText3, SDLTextFieldNameMainField1, SDLTextFieldNameMainField2, SDLTextFieldNameMainField3, SDLTextFieldNameMainField4, SDLTextFieldNameMediaClock, SDLTextFieldNameMediaTrack, SDLTextFieldNamePhoneNumber, SDLTextFieldNameAddressLines, SDLTextFieldNameLocationName, SDLTextFieldNameSliderFooter, SDLTextFieldNameSliderHeader, SDLTextFieldNameTertiaryText, SDLTextFieldNameSecondaryText, SDLTextFieldNameTemplateTitle, SDLTextFieldNameTotalDistance, SDLTextFieldNameNavigationText1, SDLTextFieldNameNavigationText2, SDLTextFieldNameLocationDescription, SDLTextFieldNameScrollableMessageBody, SDLTextFieldNameInitialInteractionText, SDLTextFieldNameAudioPassThruDisplayText1, SDLTextFieldNameAudioPassThruDisplayText2, SDLTextFieldNameTimeToDestination, SDLTextFieldNameTurnText]; + return @[SDLTextFieldNameAddressLines, + SDLTextFieldNameAlertText1, + SDLTextFieldNameAlertText2, + SDLTextFieldNameAlertText3, + SDLTextFieldNameAudioPassThruDisplayText1, + SDLTextFieldNameAudioPassThruDisplayText2, + SDLTextFieldNameETA, + SDLTextFieldNameInitialInteractionText, + SDLTextFieldNameLocationDescription, + SDLTextFieldNameLocationName, + SDLTextFieldNameMainField1, + SDLTextFieldNameMainField2, + SDLTextFieldNameMainField3, + SDLTextFieldNameMainField4, + SDLTextFieldNameMediaClock, + SDLTextFieldNameMediaTrack, + SDLTextFieldNameMenuCommandSecondaryText, + SDLTextFieldNameMenuCommandTertiaryText, + SDLTextFieldNameMenuName, + SDLTextFieldNameMenuSubMenuSecondaryText, + SDLTextFieldNameMenuSubMenuTertiaryText, + SDLTextFieldNameMenuTitle, + SDLTextFieldNameNavigationText1, + SDLTextFieldNameNavigationText2, + SDLTextFieldNamePhoneNumber, + SDLTextFieldNameScrollableMessageBody, + SDLTextFieldNameSecondaryText, + SDLTextFieldNameSliderFooter, + SDLTextFieldNameSliderHeader, + SDLTextFieldNameStatusBar, + SDLTextFieldNameSubtleAlertSoftButtonText, + SDLTextFieldNameSubtleAlertText1, + SDLTextFieldNameSubtleAlertText2, + SDLTextFieldNameTemplateTitle, + SDLTextFieldNameTertiaryText, + SDLTextFieldNameTimeToDestination, + SDLTextFieldNameTotalDistance, + SDLTextFieldNameTurnText]; } #pragma clang diagnostic pop diff --git a/SmartDeviceLink/public/SDLImageFieldName.m b/SmartDeviceLink/public/SDLImageFieldName.m index ecefa251b..75e677bcc 100644 --- a/SmartDeviceLink/public/SDLImageFieldName.m +++ b/SmartDeviceLink/public/SDLImageFieldName.m @@ -34,20 +34,20 @@ #import "SDLImageFieldName.h" SDLImageFieldName const SDLImageFieldNameAlertIcon = @"alertIcon"; -SDLImageFieldName const SDLImageFieldNameSoftButtonImage = @"softButtonImage"; +SDLImageFieldName const SDLImageFieldNameAppIcon = @"appIcon"; SDLImageFieldName const SDLImageFieldNameChoiceImage = @"choiceImage"; SDLImageFieldName const SDLImageFieldNameChoiceSecondaryImage = @"choiceSecondaryImage"; -SDLImageFieldName const SDLImageFieldNameVoiceRecognitionHelpItem = @"vrHelpItem"; -SDLImageFieldName const SDLImageFieldNameTurnIcon = @"turnIcon"; -SDLImageFieldName const SDLImageFieldNameMenuIcon = @"menuIcon"; SDLImageFieldName const SDLImageFieldNameCommandIcon = @"cmdIcon"; -SDLImageFieldName const SDLImageFieldNameAppIcon = @"appIcon"; SDLImageFieldName const SDLImageFieldNameGraphic = @"graphic"; +SDLImageFieldName const SDLImageFieldNameLocationImage = @"locationImage"; +SDLImageFieldName const SDLImageFieldNameMenuCommandSecondaryImage = @"menuCommandSecondaryImage"; +SDLImageFieldName const SDLImageFieldNameMenuIcon = @"menuIcon"; +SDLImageFieldName const SDLImageFieldNameMenuSubMenuSecondaryImage = @"menuSubMenuSecondaryImage"; SDLImageFieldName const SDLImageFieldNameSecondaryGraphic = @"secondaryGraphic"; SDLImageFieldName const SDLImageFieldNameShowConstantTBTIcon = @"showConstantTBTIcon"; SDLImageFieldName const SDLImageFieldNameShowConstantTBTNextTurnIcon = @"showConstantTBTNextTurnIcon"; -SDLImageFieldName const SDLImageFieldNameLocationImage = @"locationImage"; +SDLImageFieldName const SDLImageFieldNameSoftButtonImage = @"softButtonImage"; SDLImageFieldName const SDLImageFieldNameSubMenuIcon = @"subMenuIcon"; SDLImageFieldName const SDLImageFieldNameSubtleAlertIcon = @"subtleAlertIcon"; -SDLImageFieldName const SDLImageFieldNameMenuCommandSecondaryImage = @"menuCommandSecondaryImage"; -SDLImageFieldName const SDLImageFieldNameMenuSubMenuSecondaryImage = @"menuSubMenuSecondaryImage"; +SDLImageFieldName const SDLImageFieldNameTurnIcon = @"turnIcon"; +SDLImageFieldName const SDLImageFieldNameVoiceRecognitionHelpItem = @"vrHelpItem"; diff --git a/SmartDeviceLink/public/SDLTextFieldName.m b/SmartDeviceLink/public/SDLTextFieldName.m index d02826ca2..06260e782 100644 --- a/SmartDeviceLink/public/SDLTextFieldName.m +++ b/SmartDeviceLink/public/SDLTextFieldName.m @@ -32,41 +32,41 @@ #import "SDLTextFieldName.h" +SDLTextFieldName const SDLTextFieldNameAddressLines = @"addressLines"; +SDLTextFieldName const SDLTextFieldNameAlertText1 = @"alertText1"; +SDLTextFieldName const SDLTextFieldNameAlertText2 = @"alertText2"; +SDLTextFieldName const SDLTextFieldNameAlertText3 = @"alertText3"; +SDLTextFieldName const SDLTextFieldNameAudioPassThruDisplayText1 = @"audioPassThruDisplayText1"; +SDLTextFieldName const SDLTextFieldNameAudioPassThruDisplayText2 = @"audioPassThruDisplayText2"; +SDLTextFieldName const SDLTextFieldNameETA = @"ETA"; +SDLTextFieldName const SDLTextFieldNameInitialInteractionText = @"initialInteractionText"; +SDLTextFieldName const SDLTextFieldNameLocationDescription = @"locationDescription"; +SDLTextFieldName const SDLTextFieldNameLocationName = @"locationName"; SDLTextFieldName const SDLTextFieldNameMainField1 = @"mainField1"; SDLTextFieldName const SDLTextFieldNameMainField2 = @"mainField2"; SDLTextFieldName const SDLTextFieldNameMainField3 = @"mainField3"; SDLTextFieldName const SDLTextFieldNameMainField4 = @"mainField4"; -SDLTextFieldName const SDLTextFieldNameTemplateTitle = @"templateTitle"; -SDLTextFieldName const SDLTextFieldNameStatusBar = @"statusBar"; SDLTextFieldName const SDLTextFieldNameMediaClock = @"mediaClock"; SDLTextFieldName const SDLTextFieldNameMediaTrack = @"mediaTrack"; -SDLTextFieldName const SDLTextFieldNameAlertText1 = @"alertText1"; -SDLTextFieldName const SDLTextFieldNameAlertText2 = @"alertText2"; -SDLTextFieldName const SDLTextFieldNameAlertText3 = @"alertText3"; -SDLTextFieldName const SDLTextFieldNameScrollableMessageBody = @"scrollableMessageBody"; -SDLTextFieldName const SDLTextFieldNameInitialInteractionText = @"initialInteractionText"; +SDLTextFieldName const SDLTextFieldNameMenuCommandSecondaryText = @"menuCommandSecondaryText"; +SDLTextFieldName const SDLTextFieldNameMenuCommandTertiaryText = @"menuCommandTertiaryText"; +SDLTextFieldName const SDLTextFieldNameMenuName = @"menuName"; +SDLTextFieldName const SDLTextFieldNameMenuSubMenuSecondaryText = @"menuSubMenuSecondaryText"; +SDLTextFieldName const SDLTextFieldNameMenuSubMenuTertiaryText = @"menuSubMenuTertiaryText"; +SDLTextFieldName const SDLTextFieldNameMenuTitle = @"menuTitle"; SDLTextFieldName const SDLTextFieldNameNavigationText1 = @"navigationText1"; SDLTextFieldName const SDLTextFieldNameNavigationText2 = @"navigationText2"; -SDLTextFieldName const SDLTextFieldNameETA = @"ETA"; -SDLTextFieldName const SDLTextFieldNameTotalDistance = @"totalDistance"; -SDLTextFieldName const SDLTextFieldNameAudioPassThruDisplayText1 = @"audioPassThruDisplayText1"; -SDLTextFieldName const SDLTextFieldNameAudioPassThruDisplayText2 = @"audioPassThruDisplayText2"; -SDLTextFieldName const SDLTextFieldNameSliderHeader = @"sliderHeader"; -SDLTextFieldName const SDLTextFieldNameSliderFooter = @"sliderFooter"; -SDLTextFieldName const SDLTextFieldNameMenuName = @"menuName"; +SDLTextFieldName const SDLTextFieldNamePhoneNumber = @"phoneNumber"; +SDLTextFieldName const SDLTextFieldNameScrollableMessageBody = @"scrollableMessageBody"; SDLTextFieldName const SDLTextFieldNameSecondaryText = @"secondaryText"; +SDLTextFieldName const SDLTextFieldNameSliderFooter = @"sliderFooter"; +SDLTextFieldName const SDLTextFieldNameSliderHeader = @"sliderHeader"; +SDLTextFieldName const SDLTextFieldNameStatusBar = @"statusBar"; +SDLTextFieldName const SDLTextFieldNameSubtleAlertSoftButtonText = @"subtleAlertSoftButtonText"; +SDLTextFieldName const SDLTextFieldNameSubtleAlertText1 = @"subtleAlertText1"; +SDLTextFieldName const SDLTextFieldNameSubtleAlertText2 = @"subtleAlertText2"; +SDLTextFieldName const SDLTextFieldNameTemplateTitle = @"templateTitle"; SDLTextFieldName const SDLTextFieldNameTertiaryText = @"tertiaryText"; -SDLTextFieldName const SDLTextFieldNameMenuTitle = @"menuTitle"; -SDLTextFieldName const SDLTextFieldNameLocationName = @"locationName"; -SDLTextFieldName const SDLTextFieldNameLocationDescription = @"locationDescription"; -SDLTextFieldName const SDLTextFieldNameAddressLines = @"addressLines"; -SDLTextFieldName const SDLTextFieldNamePhoneNumber = @"phoneNumber"; SDLTextFieldName const SDLTextFieldNameTimeToDestination = @"timeToDestination"; +SDLTextFieldName const SDLTextFieldNameTotalDistance = @"totalDistance"; SDLTextFieldName const SDLTextFieldNameTurnText = @"turnText"; -SDLTextFieldName const SDLTextFieldNameSubtleAlertText1 = @"subtleAlertText1"; -SDLTextFieldName const SDLTextFieldNameSubtleAlertText2 = @"subtleAlertText2"; -SDLTextFieldName const SDLTextFieldNameSubtleAlertSoftButtonText = @"subtleAlertSoftButtonText"; -SDLTextFieldName const SDLTextFieldNameMenuCommandSecondaryText = @"menuCommandSecondaryText"; -SDLTextFieldName const SDLTextFieldNameMenuCommandTertiaryText = @"menuCommandTertiaryText"; -SDLTextFieldName const SDLTextFieldNameMenuSubMenuSecondaryText = @"menuSubMenuSecondaryText"; -SDLTextFieldName const SDLTextFieldNameMenuSubMenuTertiaryText = @"menuSubMenuTertiaryText"; diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuReplaceUtilitiesSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuReplaceUtilitiesSpec.m index 51f6bca6a..dc0abb1f6 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuReplaceUtilitiesSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuReplaceUtilitiesSpec.m @@ -5,9 +5,11 @@ #import "SDLMenuReplaceUtilities.h" #import "SDLFileManager.h" +#import "SDLGlobals.h" #import "SDLMenuCell.h" #import "SDLMenuReplaceUtilitiesSpecHelpers.h" #import "SDLMenuManagerPrivateConstants.h" +#import "SDLVersion.h" #import "SDLWindowCapability.h" #import "TestConnectionManager.h" @@ -127,6 +129,21 @@ describe(@"finding all artworks from cells", ^{ beforeEach(^{ mockFileManager = OCMClassMock([SDLFileManager class]); testWindowCapability = [[SDLWindowCapability alloc] init]; + [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:@"8.0.0"]; + }); + + context(@"when checking a submenu cell artwork on RPC 5.0–7.0 without the submenu image field but with the command image field", ^{ + beforeEach(^{ + OCMStub([mockFileManager fileNeedsUpload:[OCMArg any]]).andReturn(YES); + OCMStub([mockFileManager hasUploadedFile:[OCMArg any]]).andReturn(YES); + [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:@"6.0.0"]; + testWindowCapability.imageFields = @[allSupportedImageFields[0]]; + }); + + it(@"should include the submenu primary artwork", ^{ + NSArray<SDLArtwork *> *artworksToUpload = [SDLMenuReplaceUtilities findAllArtworksToBeUploadedFromCells:SDLMenuReplaceUtilitiesSpecHelpers.deepMenu fileManager:mockFileManager windowCapability:testWindowCapability]; + expect(artworksToUpload).to(haveCount(3)); + }); }); context(@"when all the files need to be uploaded", ^{ @@ -137,6 +154,7 @@ describe(@"finding all artworks from cells", ^{ context(@"when the window capability doesn't support the primary image", ^{ beforeEach(^{ testWindowCapability.textFields = allSupportedTextFields; + testWindowCapability.imageFields = @[]; }); it(@"should return an empty list of artworks to upload", ^{ @@ -155,7 +173,7 @@ describe(@"finding all artworks from cells", ^{ it(@"should only return primary images to upload", ^{ NSArray<SDLArtwork *> *artworksToUpload = [SDLMenuReplaceUtilities findAllArtworksToBeUploadedFromCells:SDLMenuReplaceUtilitiesSpecHelpers.topLevelOnlyMenu fileManager:mockFileManager windowCapability:testWindowCapability]; - expect(artworksToUpload).to(haveCount(2)); + expect(artworksToUpload).to(haveCount(1)); }); }); @@ -268,7 +286,9 @@ describe(@"generating RPCs", ^{ beforeEach(^{ mockFileManager = OCMClassMock([SDLFileManager class]); + OCMStub([mockFileManager hasUploadedFile:[OCMArg any]]).andReturn(YES); testWindowCapability = [[SDLWindowCapability alloc] init]; + testWindowCapability.imageFields = @[[[SDLImageField alloc] initWithName:SDLImageFieldNameCommandIcon imageTypeSupported:@[SDLImageTypeDynamic] imageResolution:nil]]; }); context(@"delete commands", ^{ @@ -302,6 +322,10 @@ describe(@"generating RPCs", ^{ }); context(@"main menu commands", ^{ + beforeEach(^{ + [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:@"8.0.0"]; + }); + context(@"shallow menu", ^{ beforeEach(^{ testMenuCells = SDLMenuReplaceUtilitiesSpecHelpers.topLevelOnlyMenu; @@ -325,28 +349,34 @@ describe(@"generating RPCs", ^{ NSArray<SDLRPCRequest *> *requests = [SDLMenuReplaceUtilities mainMenuCommandsForCells:testMenuCells fileManager:mockFileManager usingPositionsFromFullMenu:testMenuCells windowCapability:testWindowCapability defaultSubmenuLayout:testMenuLayout]; expect(requests).to(haveCount(3)); expect(requests[0]).to(beAnInstanceOf(SDLAddSubMenu.class)); + SDLAddSubMenu *request0 = (SDLAddSubMenu *)requests[0]; + expect(request0.menuIcon).to(beNil()); + expect(requests[1]).to(beAnInstanceOf(SDLAddCommand.class)); expect(requests[2]).to(beAnInstanceOf(SDLAddSubMenu.class)); }); }); - }); - context(@"sub menu commands", ^{ - context(@"shallow menu", ^{ + context(@"deep menu on RPC >= 5.0 && < 7.0", ^{ beforeEach(^{ - testMenuCells = SDLMenuReplaceUtilitiesSpecHelpers.topLevelOnlyMenu; + testMenuCells = SDLMenuReplaceUtilitiesSpecHelpers.deepMenu; + [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:@"6.0.0"]; }); - }); - context(@"deep menu", ^{ - beforeEach(^{ - testMenuCells = SDLMenuReplaceUtilitiesSpecHelpers.deepMenu; + it(@"should generate the correct RPCs", ^{ + NSArray<SDLRPCRequest *> *requests = [SDLMenuReplaceUtilities mainMenuCommandsForCells:testMenuCells fileManager:mockFileManager usingPositionsFromFullMenu:testMenuCells windowCapability:testWindowCapability defaultSubmenuLayout:testMenuLayout]; + expect(requests).to(haveCount(3)); + expect(requests[0]).to(beAnInstanceOf(SDLAddSubMenu.class)); + SDLAddSubMenu *request0 = (SDLAddSubMenu *)requests[0]; + expect(request0.menuIcon).toNot(beNil()); + + expect(requests[1]).to(beAnInstanceOf(SDLAddCommand.class)); + expect(requests[2]).to(beAnInstanceOf(SDLAddSubMenu.class)); }); }); }); }); -// updating menu cells describe(@"updating menu cell lists", ^{ __block UInt32 testCommandId = 0; diff --git a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m index 681e074b5..613030611 100644 --- a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m +++ b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m @@ -699,8 +699,8 @@ describe(@"a system capability manager", ^{ it(@"should should save the capabilities", ^{ // All the text fields and image fields should be available - expect(testSystemCapabilityManager.defaultMainWindowCapability.textFields).to(haveCount(31)); - expect(testSystemCapabilityManager.defaultMainWindowCapability.imageFields).to(haveCount(14)); + expect(testSystemCapabilityManager.defaultMainWindowCapability.textFields).to(haveCount(38)); + expect(testSystemCapabilityManager.defaultMainWindowCapability.imageFields).to(haveCount(18)); }); }); }); |